docstr: Validate that AWS credentials to and python package exists in environment.
docstr_tok: ["Validate","that","AWS","credentials","to","and","python","package","exists","in","environment","."]
code: def validate_environment(cls, values: typing.Dict) -> typing.Dict:
      """Validate that AWS credentials to and python package exists in environment."""
      try:
          import boto3
  
          try:
              if values["credentials_profile_name"] is not None:
                  session = boto3.Session(
                      profile_name=values["credentials_profile_name"]
                  )
              else:
                  # use default credentials
                  session = boto3.Session()
  
              values["client"] = session.client(
                  "sagemaker-runtime",
                  region_name=values["region_name"],
                  aws_access_key_id=values["aws_access_key_id"],
                  aws_secret_access_key=values["aws_secret_access_key"],
              )
  
          except Exception as e:
              raise ValueError(
                  "Could not load credentials to authenticate with AWS client. "
                  "Please check that credentials in the specified "
                  "profile name are valid."
              ) from e
  
      except ImportError:
          raise ImportError(
              "Could not import boto3 python package. "
              "Please install it with `pip install boto3`."
          )
      return values
  
file_path: h2ogpt/src/sagemaker.py
imports: import os
  import typing
  import json
  from langchain.llms import SagemakerEndpoint
  from langchain.llms.sagemaker_endpoint import LLMContentHandler
  from pydantic.v1 import root_validator
  from src.utils import FakeTokenizer
label_desc: Use image node_id 1 for calling the H2OSagemakerEndpoint obj's underlying member method code with example usage: obj.validate_environment(cls, values) and returns: values