클라이언트 설정

Backend.AI API 설정에는 endpoint URL과 API keypair (access 및 secret key) 등이 포함됩니다.

설정 방법은 2가지가 있습니다:

  1. 이 SDK를 사용하는 여러분의 프로그램이 실행되기 전 환경변수를 미리 설정해두기

  2. 직접 APIConfig 인스턴스를 만들고 그로부터 세션을 초기화하기

다음과 같은 환경변수들을 사용할 수 있습니다:

  • BACKEND_ENDPOINT

  • BACKEND_ACCESS_KEY

  • BACKEND_SECRET_KEY

  • BACKEND_VFOLDER_MOUNTS

다른 설정들은 기본값을 사용합니다.

클라이언트측 Jupyter 통합 플러그인을 사용하는 경우, BACKEND_VFOLDER_MOUNTS 변수는 가상폴더를 노트북 커널 안에서 사용하기 위한 유일한 방법입니다.

ai.backend.client.config.get_env(key, default=None, clean=<function <lambda>>)[소스]

환경변수에서 설정값을 가져옵니다. 설정 이름을 대문자화한 후 먼저 "BACKEND_" 접두어를 붙여서 찾아보고, 없으면 "SORNA_"를 붙여서 찾아봅니다.

매개변수
  • key (str) -- 설정 이름

  • default (Optional[Any]) -- 환경변수에 대응하는 값이 없을 때 반환되는 기본값

  • clean (Callable[[str], Any]) -- A single-argument function that is applied to the result of lookup (in both successes and the default value for failures). The default is returning the value as-is.

반환값

clean 함수를 거쳐 처리된 값

ai.backend.client.config.get_config()[소스]

Returns the configuration for the current process. If there is no explicitly set APIConfig instance, it will generate a new one from the current environment variables and defaults.

ai.backend.client.config.set_config(conf)[소스]

현재 프로세스 전체에서 사용될 전역 설정을 지정합니다.

class ai.backend.client.config.APIConfig(*, endpoint=None, version=None, user_agent=None, access_key=None, secret_key=None, hash_type=None, vfolder_mounts=None, skip_sslcert_validation=None)[소스]

Represents a set of API client configurations. The access key and secret key are mandatory -- they must be set in either environment variables or as the explicit arguments.

매개변수
  • endpoint (Union[URL, str, None]) -- API 서버의 주소

  • version (Optional[str]) -- API 프로토콜 버전

  • user_agent (Optional[str]) -- User-Agent HTTP 헤더로 전송될 사용자 에이전트 문자열

  • access_key (Optional[str]) -- API access key

  • secret_key (Optional[str]) -- API secret key

  • hash_type (Optional[str]) -- API 요청별 인증 서명 생성 알고리즘을 위한 해쉬 알고리즘 종류

  • vfolder_mounts (Optional[Iterable[str]]) -- Kernel.get_or_create()와 같이 세션 생성 API 호출 시 자동으로 탑재될 가상폴더의 목록 (반드시 요청자의 access key가 소유 또는 접근 가능한 것이어야 함)

DEFAULTS = {'endpoint': 'https://api.backend.ai', 'hash_type': 'sha256', 'version': 'v4.20190315'}

access key와 secret key를 제외한 기본값