Artifact Registry에 Conda 패키지 저장

이 빠른 시작에서는 비공개 Artifact Registry Conda 저장소를 설정하고 저장소에 패키지를 업로드하는 방법을 보여줍니다.

시작하기 전에

  1. Google Cloud 계정에 로그인합니다. Google Cloud를 처음 사용하는 경우 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $300의 무료 크레딧이 제공됩니다.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Artifact Registry API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  5. Make sure that you have the following role or roles on the project: Artifact Registry Administrator

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. Click Select a role, then search for the role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.
  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. Verify that billing is enabled for your Google Cloud project.

  8. Enable the Artifact Registry API, if it is not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  9. Make sure that you have the following role or roles on the project: Artifact Registry Administrator

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. Click Select a role, then search for the role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.
  10. Google Cloud 환경 내에서 Conda CLI를 사용하려면 다음 Conda 패키지 관리자 중 하나를 설치하세요.

Cloud Shell 실행

이 빠른 시작에서는Google Cloud에서 호스팅되는 리소스를 관리하기 위한 셸 환경인 Cloud Shell을 사용합니다.

Cloud Shell에는 Google Cloud CLI 및 Conda가 사전 설치되어 있습니다. gcloud CLI는 Google Cloud의 기본 명령줄 인터페이스를 제공합니다.

Cloud Shell 시작:

  1. Google Cloud 콘솔로 이동합니다.

    Google Cloud 콘솔

  2. Google Cloud 콘솔 툴바에서 Cloud Shell 활성화를 클릭합니다.

Console 하단의 프레임에서 Cloud Shell 세션이 열립니다. 이 셸을 사용하여 gcloud 명령어를 실행합니다.

인증 구성

Conda 채널은 하나 이상의 Conda 패키지가 저장된 위치의 주소입니다. Conda 환경에 패키지를 설치하려면 먼저 해당 패키지의 채널을 Conda 구성 파일에 추가해야 합니다.

Conda CLI가 Artifact Registry를 직접 호출하도록 허용하려면 다음을 실행하여 Google Cloud 에서 Conda 채널을 인증해야 합니다.

  1. gcloud CLI에서 다음 명령어를 실행하여 oauth 토큰의 ID를 TOKEN 변수에 저장합니다.

    export TOKEN="oauth2accesstoken:$(gcloud auth print-access-token)"
    
  2. Conda 저장소를 Conda 구성 파일의 채널로 추가합니다.

    Conda

    conda config --add channels \
    https://$TOKEN@LOCATION-conda.pkg.dev/PROJECT/REPOSITORY
    

    Miniforge

    conda config --add channels \
    https://$TOKEN@LOCATION-conda.pkg.dev/PROJECT/REPOSITORY
    

    Mamba

    mamba config --add channels \
    https://$TOKEN@LOCATION-conda.pkg.dev/PROJECT/REPOSITORY
    

    Micromamba

    micromamba config --add channels \
    https://$TOKEN@LOCATION-conda.pkg.dev/PROJECT/REPOSITORY
    

    각 항목의 의미는 다음과 같습니다.

    • TOKEN은 oauth2accesstoken:$(gcloud auth print-access-token)을 실행하여 생성된 oauth 토큰의 값을 저장합니다.
    • LOCATION은 저장소의 리전 또는 멀티 리전 위치입니다.
    • PROJECT는 저장소가 포함된 프로젝트의 ID입니다.
    • REPOSITORY는 저장소 ID입니다.

만료된 oauth 토큰 갱신

oauth 토큰은 1시간 후에 만료됩니다. 새 토큰으로 채널을 다시 인증하려면 다음 단계를 따르세요.

  1. 구성 파일에서 채널을 삭제합니다.

    Conda

    conda config --remove channels CHANNEL_NAME
    

    Miniforge

    conda config --remove channels CHANNEL_NAME
    

    Mamba

    mamba config --remove channels CHANNEL_NAME
    

    Micromamba

    micromamba config --remove channels CHANNEL_NAME
    
  2. 새 oauth 토큰을 만드는 방법을 설명한 이전 단계를 따릅니다.

  3. 새 토큰 값을 사용하여 Conda 구성 파일에 Conda 저장소를 다시 추가합니다.

저장소 만들기

패키지의 저장소를 만듭니다.

  1. 다음 명령어를 실행하여 quickstart-conda-repo라는 현재 프로젝트의 새로운 Conda 저장소를 위치 us-west1에 만듭니다.

    gcloud artifacts repositories create quickstart-conda-repo \
        --repository-format=conda \
        --location=us-west1 \
        --description="Conda repository"
    
  2. 다음 명령어를 실행하여 저장소가 생성되었는지 확인합니다.

    gcloud artifacts repositories list
    
  3. gcloud 명령어를 단순화하려면 기본 저장소를 quickstart-conda-repo로 설정하고 기본 위치를 us-west1로 설정합니다. 이 값을 설정하면 저장소나 위치가 필요한 gcloud 명령어에 값을 지정할 필요가 없습니다.

    저장소를 설정하려면 다음 명령어를 실행합니다.

    gcloud config set artifacts/repository quickstart-conda-repo
    

    위치를 설정하려면 다음 명령어를 실행하세요.

    gcloud config set artifacts/location us-west1
    

    이러한 명령어에 대한 자세한 내용은 gcloud config set 문서를 참조하세요.

저장소에 패키지 업로드

저장소에 패키지를 업로드하려면 다음 명령어를 실행합니다.

gcloud artifacts files upload \
    --source=PACKAGE_NAME \
    --repository=REPO_NAME\
    --project=PROJECT \
    --location=LOCATION

각 항목의 의미는 다음과 같습니다.

  • REPO_NAME는 저장소 ID입니다.
  • PROJECT는 저장소가 포함된 프로젝트의 ID입니다.
  • LOCATION은 저장소의 리전 또는 멀티 리전 위치입니다.

한 번에 여러 패키지를 업로드하려면 다음 단계를 따르세요.

gcloud artifacts files upload \
    --source-directory="DIRECTORY" \
    --repository="REPO_NAME"\
    --project="PROJECT" \
    --location="LOCATION"

각 항목의 의미는 다음과 같습니다.

  • DIRECTORY은 Conda 패키지가 포함된 로컬 폴더의 주소입니다.

저장소에서 패키지 보기

패키지가 추가되었는지 확인하려면 quickstart-conda-repo 저장소의 패키지를 나열합니다.

다음 명령어를 실행합니다.

gcloud artifacts packages list --repository=quickstart-conda-repo

패키지 버전을 보려면 다음 명령어를 실행합니다.

gcloud artifacts versions list --package=PACKAGE_NAME

패키지 버전의 파일을 보려면 다음 명령어를 실행합니다.

gcloud artifacts files list --package=PACKAGE_NAME --version=VERSION

패키지 설치

Artifact Registry 저장소에 방금 추가한 패키지를 설치하려면 다음 명령어를 실행합니다.

Conda

conda install -n ENVIRONMENT_NAME PACKAGE_NAME

Miniforge

conda install -n ENVIRONMENT_NAME PACKAGE_NAME

Mamba

mamba install -n ENVIRONMENT_NAME PACKAGE_NAME

Micromamba

micromamba install -n ENVIRONMENT_NAME PACKAGE_NAME

각 항목의 의미는 다음과 같습니다.

  • ENVIRONMENT_NAME은 Conda 환경의 이름입니다.
  • PACKAGE_NAME은 저장소에 설치할 패키지의 이름입니다.

문제 해결

자세한 내용은 Conda 패키지 문제 해결을 참고하세요.

삭제

이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 다음 단계를 수행합니다.

저장소를 삭제하기 전에, 보관할 패키지를 다른 위치에서 사용할 수 있는지 확인합니다.

  1. quickstart-conda-repo 저장소를 삭제하려면 다음 명령어를 실행합니다.

    gcloud artifacts repositories delete quickstart-conda-repo
    
  2. 활성 gcloud 구성에 지정한 기본 저장소 및 위치 설정을 삭제하려면 다음 명령어를 실행합니다.

    gcloud config unset artifacts/repository
    gcloud config unset artifacts/location
    

다음 단계