ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ์ํฌํ๋ก ์ ์๋ฅผ ๊ฒ์ํ๋ ๋ฐ ์ฌ์ฉํ๋ ๋ฆฌ์์ค๋ก์ ๋จ์ผ ์ฌ์ฉ์ ๋๋ ์ฌ๋ฌ ์ฌ์ฉ์๊ฐ ์ฌ๋ฌ ๋ฒ ์ฌ์ฌ์ฉํ ์ ์๋ ๋ฆฌ์์ค์ ๋๋ค.
Kubeflow Pipelines SDK ๋ ์ง์คํธ๋ฆฌ ํด๋ผ์ด์ธํธ๋ Artifact Registry์ ๊ฐ์ด ํธํ๋๋ ๋ ์ง์คํธ๋ฆฌ ์๋ฒ์์ Kubeflow Pipelines(KFP) ํ ํ๋ฆฟ์ ๋ฒ์ ์ ์ด์ ์ฌ์ฉํ ์ ์๋ ์ ํด๋ผ์ด์ธํธ ์ธํฐํ์ด์ค์ ๋๋ค. ์์ธํ ๋ด์ฉ์ Kubeflow Pipelines SDK ๋ ์ง์คํธ๋ฆฌ ํด๋ผ์ด์ธํธ์์ ํ ํ๋ฆฟ ์ฌ์ฉ์ ์ฐธ์กฐํ์ธ์.
์ด ํ์ด์ง์์๋ ๋ค์ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค.
- KFP ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ ์์ฑ
- Kubeflow Pipelines SDK ๋ ์ง์คํธ๋ฆฌ ํด๋ผ์ด์ธํธ๋ฅผ ์ฌ์ฉํ์ฌ ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ ์ ์ฅ์์ ํ ํ๋ฆฟ ์ ๋ก๋
- Kubeflow Pipelines ํด๋ผ์ด์ธํธ์์ ํ ํ๋ฆฟ ์ฌ์ฉ
์์ํ๊ธฐ ์ ์
ํ์ดํ๋ผ์ธ์ ๋น๋ํ๊ณ ์คํํ๊ธฐ ์ ์ ๋ค์ ์๋ด์ ๋ฐ๋ผ Google Cloud ์ฝ์์์ Google Cloud ํ๋ก์ ํธ ๋ฐ ๊ฐ๋ฐ ํ๊ฒฝ์ ์ค์ ํ์ธ์.
Kubeflow Pipelines SDK v2 ์ด์์ ์ค์นํฉ๋๋ค.
pip install --upgrade kfp>=2,<3
Vertex AI SDK for Python v1.15.0 ์ด์์ ์ค์นํฉ๋๋ค.
(์ ํ์ฌํญ) ์ค์นํ๊ธฐ ์ ์ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํ์ฌ ํ์ฌ ์ค์น๋ Python์ฉ Vertex AI SDK ๋ฒ์ ์ ํ์ธํฉ๋๋ค.pip freeze | grep google-cloud-aiplatform
(์ ํ์ฌํญ) Google Cloud CLI 390.0.0 ์ด์์ ์ค์นํฉ๋๋ค.
๊ถํ ๊ตฌ์ฑ
Vertex AI Pipelines๋ฅผ ์ํ gcloud CLI ํ๋ก์ ํธ๋ฅผ ์์ง ์ค์ ํ์ง ์์ ๊ฒฝ์ฐ Vertex AI Pipelines์ฉ Google Cloud ํ๋ก์ ํธ ๊ตฌ์ฑ์ ์๋ด๋ฅผ ๋ฐ๋ฆ ๋๋ค.
๋ํ Artifact Registry๋ฅผ ํ ํ๋ฆฟ ๋ ์ง์คํธ๋ฆฌ๋ก ์ฌ์ฉํ๋๋ก ๋ค์ ์ฌ์ ์ ์๋ Identity and Access Management ๊ถํ์ ํ ๋นํฉ๋๋ค.
roles/artifactregistry.admin
: ์ ์ฅ์๋ฅผ ๋ง๋ค๊ณ ๊ด๋ฆฌํ๋ ค๋ฉด ์ด ์ญํ ์ ํ ๋นํฉ๋๋ค.roles/artifactregistry.repoAdmin
๋๋roles/artifactregistry.writer
: ์ ์ฅ์ ๋ด์์ ํ ํ๋ฆฟ์ ๊ด๋ฆฌํ๋ ค๋ฉด ์ด๋ฌํ ์ญํ ์ ํ ๋นํฉ๋๋ค.roles/artifactregistry.reader
: ์ ์ฅ์์์ ํ ํ๋ฆฟ์ ๋ค์ด๋ก๋ํ๋ ค๋ฉด ์ด ์ญํ ์ ํ ๋นํฉ๋๋ค.roles/artifactregistry.reader
: ํ ํ๋ฆฟ์์ ํ์ดํ๋ผ์ธ ์คํ์ ๋ง๋ค๋ ค๋ฉด Vertex AI Pipelines์ ์ฐ๊ด๋ ์๋น์ค ๊ณ์ ์ ์ด ์ญํ ์ ํ ๋นํฉ๋๋ค.
Artifact Registry์ ์ฌ์ ์ ์๋ Identity and Access Management ์ญํ ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ฌ์ ์ ์๋ Artifact Registry ์ญํ ์ ์ฐธ์กฐํ์ธ์.
๋ค์ ์ํ์ ์ฌ์ฉํ์ฌ ์ญํ ์ ํ ๋นํฉ๋๋ค.
gcloud projects add-iam-policy-binding PROJECT_ID \ --member=PRINCIPAL \ --role=ROLE
๋ค์์ ๋ฐ๊ฟ๋๋ค.
- PROJECT_ID: ํ์ดํ๋ผ์ธ์ ๋ง๋ค ํ๋ก์ ํธ์ ๋๋ค.
- PRINCIPAL: ๊ถํ์ ์ถ๊ฐํ ์ฃผ ๊ตฌ์ฑ์์ ๋๋ค.
- ROLE: ์ฃผ ๊ตฌ์ฑ์์๊ฒ ๋ถ์ฌํ๋ ค๋ Identity and Access Management ์ญํ ์ ๋๋ค.
์์ธํ ๋ด์ฉ์ Artifact Registry ๋ฌธ์์์ ์ญํ ๋ฐ ๊ถํ์ ์ฐธ์กฐํ์ธ์.
- ํ๋ก์ ํธ ์ ์ฒด ๊ถํ ๋ถ์ฌ
- ์ ์ฅ์๋ณ ๊ถํ ๋ถ์ฌ
- ๊ฐ๋ณ ์ฌ์ฉ์์๊ฒ ๊ธฐ๋ณธ Identity and Access Management ์ญํ ๋ถ์ฌ
Artifact Registry์์ ์ ์ฅ์ ๋ง๋ค๊ธฐ
๋ค์์ผ๋ก Artifact Registry์ ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ์ํ ์ ์ฅ์๋ฅผ ๋ง๋ญ๋๋ค.
์ฝ์
Google Cloud ์ฝ์์์ Vertex AI Pipelines๋ฅผ ์ฝ๋๋ค.
๋ด ํ ํ๋ฆฟ ํญ์ ํด๋ฆญํฉ๋๋ค.
์ ์ฅ์ ์ ํ ์ฐฝ์ ์ด๋ ค๋ฉด ์ ์ฅ์ ์ ํ์ ํด๋ฆญํฉ๋๋ค.
์ ์ฅ์ ๋ง๋ค๊ธฐ๋ฅผ ํด๋ฆญํฉ๋๋ค.
quickstart-kfp-repo
๋ฅผ ์ ์ฅ์ ์ด๋ฆ์ผ๋ก ์ง์ ํฉ๋๋ค.ํ์์์
Kubeflow Pipelines
๋ฅผ ์ ํํฉ๋๋ค.์์น ์ ํ์์ ๋ฆฌ์ ์ ์ ํํฉ๋๋ค.
๋ฆฌ์ ๋๋กญ๋ค์ด ๋ชฉ๋ก์์
us-central1
์ ์ ํํฉ๋๋ค.๋ง๋ค๊ธฐ๋ฅผ ํด๋ฆญํฉ๋๋ค.
Google Cloud CLI
๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํ์ฌ ์ ์ฅ์๋ฅผ ๋ง๋ญ๋๋ค.
์๋์ ๋ช ๋ น์ด ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ๋ค์์ ๋ฐ๊ฟ๋๋ค.
- LOCATION: ์ ์ฅ์๋ฅผ ๋ง๋ค๋ ค๋ ์์น๋ ๋ฆฌ์ ์
๋๋ค(์:
us-central1
).
gcloud artifacts repositories create ๋ช ๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
Linux, macOS ๋๋ Cloud Shell
gcloud artifacts repositories create quickstart-kfp-repo --location=LOCATION_ID --repository-format=KFP
Windows(PowerShell)
gcloud artifacts repositories create quickstart-kfp-repo --location=LOCATION_ID --repository-format=KFP
Windows(cmd.exe)
gcloud artifacts repositories create quickstart-kfp-repo --location=LOCATION_ID --repository-format=KFP
ํ ํ๋ฆฟ ๋ง๋ค๊ธฐ
๋ค์ ์ฝ๋ ์ํ์ ์ฌ์ฉํ์ฌ ๋จ์ผ ๊ตฌ์ฑ์์๋ก ํ์ดํ๋ผ์ธ์ ์ ์ํฉ๋๋ค. KFP๋ฅผ ์ฌ์ฉํ์ฌ ํ์ดํ๋ผ์ธ์ ์ ์ํ๋ ๋ฐฉ๋ฒ์ ํ์ดํ๋ผ์ธ ๋น๋๋ฅผ ์ฐธ์กฐํ์ธ์.
from kfp import dsl
from kfp import compiler
@dsl.component()
def hello_world(text: str) -> str:
print(text)
return text
@dsl.pipeline(name='hello-world', description='A simple intro pipeline')
def pipeline_hello_world(text: str = 'hi there'):
"""Pipeline that passes small pipeline parameter string to consumer op."""
consume_task = hello_world(
text=text) # Passing pipeline parameter as argument to consumer op
compiler.Compiler().compile(
pipeline_func=pipeline_hello_world,
package_path='hello_world_pipeline.yaml')
์ํ์ ์คํํ๋ฉด compiler.Compiler().compile(...)
๋ฌธ์์ 'hello-world' ํ์ดํ๋ผ์ธ์ hello_world_pipeline.yaml
๋ก์ปฌ YAML ํ์ผ๋ก ์ปดํ์ผ์
๋๋ค.
ํ ํ๋ฆฟ ์ ๋ก๋
์ฝ์
Google Cloud ์ฝ์์์ Vertex AI Pipelines๋ฅผ ์ฝ๋๋ค.
์ ๋ก๋๋ฅผ ํด๋ฆญํ์ฌ ํ์ดํ๋ผ์ธ ๋๋ ๊ตฌ์ฑ์์ ์ ๋ก๋ ์ฐฝ์ ์ฝ๋๋ค.
์ ์ฅ์ ๋๋กญ๋ค์ด ๋ชฉ๋ก์์
quickstart-kfp-repo
์ ์ฅ์๋ฅผ ์ ํํฉ๋๋ค.ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ์ด๋ฆ์ ์ง์ ํฉ๋๋ค.
ํ์ผ ํ๋์์ ์ ํ์ ํด๋ฆญํ์ฌ ๋ก์ปฌ ํ์ผ ์์คํ ์์ ์ปดํ์ผ๋ ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ YAML์ ์ ํํ๊ณ ์ ๋ก๋ํฉ๋๋ค.
ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ์ ๋ก๋ํ๋ฉด ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ด ๋ด ํ ํ๋ฆฟ ํ์ด์ง์ ๋์ด๋ฉ๋๋ค.
Kubeflow Pipelines SDK ํด๋ผ์ด์ธํธ
Kubeflow Pipelines SDK ๋ ์ง์คํธ๋ฆฌ ํด๋ผ์ด์ธํธ๋ฅผ ๊ตฌ์ฑํ๋ ค๋ฉด ๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
from kfp.registry import RegistryClient client = RegistryClient(host=f"https://us-central1-kfp.pkg.dev/PROJECT_ID/quickstart-kfp-repo")
์ปดํ์ผ๋ YAML ํ์ผ์ Artifact Registry์ ์ ์ฅ์์ ์ ๋ก๋ํฉ๋๋ค.
templateName, versionName = client.upload_pipeline( file_name="hello_world_pipeline.yaml", tags=["v1", "latest"], extra_headers={"description":"This is an example pipeline template."})
ํ ํ๋ฆฟ์ด ์ ๋ก๋๋์๋์ง ํ์ธํ๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ๋ฐ๋ฅด์ธ์.
Google Cloud ์ฝ์์์ Vertex AI Pipelines๋ฅผ ์ฝ๋๋ค.
๋ด ํ ํ๋ฆฟ ํญ์ ํด๋ฆญํฉ๋๋ค.
์ ์ฅ์ ์ ํ์ ํด๋ฆญํฉ๋๋ค.
๋ชฉ๋ก์์
quickstart-kfp-repo
์ ์ฅ์๋ฅผ ์ ํํ ํ ์ ํ์ ํด๋ฆญํฉ๋๋ค.๋ชฉ๋ก์์ ์ ๋ก๋๋ ํ ํ๋ฆฟ ํจํค์ง
hello-world
๋ฅผ ์ฐพ์ต๋๋ค.ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ ๋ฒ์ ๋ชฉ๋ก์ ๋ณด๋ ค๋ฉด
hello-world
ํ ํ๋ฆฟ์ ํด๋ฆญํฉ๋๋ค.ํ์ดํ๋ผ์ธ ํ ํด๋ก์ง๋ฅผ ๋ณด๋ ค๋ฉด ๋ฒ์ ์ ํด๋ฆญํฉ๋๋ค.
Vertex AI์์ ํ ํ๋ฆฟ ์ฌ์ฉํ๊ธฐ
Artifact Registry์ ์ ์ฅ์์ ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ์ ๋ก๋ํ๋ฉด Vertex AI Pipelines์์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
ํ ํ๋ฆฟ์ ์คํ ์ด์ง ๋ฒํท ๋ง๋ค๊ธฐ
ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ์ฌ์ฉํ๋ ค๋ฉด ๋จผ์ ํ์ดํ๋ผ์ธ ์คํ์ ์คํ ์ด์งํ Cloud Storage ๋ฒํท์ ๋ง๋ค์ด์ผ ํฉ๋๋ค.
๋ฒํท์ ๋ง๋ค๋ ค๋ฉด ํ์ดํ๋ผ์ธ ์ํฐํฉํธ๋ฅผ ์ํ Cloud Storage ๋ฒํท ๊ตฌ์ฑ์ ์๋ด๋ฅผ ๋ฐ๋ฅธ ํ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
STAGING_BUCKET="gs://BUCKET_NAME"
BUCKET_NAME์ ๋ฐฉ๊ธ ๋ง๋ ๋ฒํท์ ์ด๋ฆ์ผ๋ก ๋ฐ๊ฟ๋๋ค.
ํ ํ๋ฆฟ์์ ํ์ดํ๋ผ์ธ ์คํ ๋ง๋ค๊ธฐ
Python์ฉ Vertex AI SDK ๋๋ Google Cloud ์ฝ์์ ์ฌ์ฉํ์ฌ Artifact Registry์ ํ ํ๋ฆฟ์์ ์คํ๋๋ ํ์ดํ๋ผ์ธ์ ๋ง๋ค ์ ์์ต๋๋ค.
์ฝ์
Google Cloud ์ฝ์์์ Vertex AI Pipelines๋ฅผ ์ฝ๋๋ค.
๋ด ํ ํ๋ฆฟ ํญ์ ํด๋ฆญํฉ๋๋ค.
์ ์ฅ์ ์ ํ ์ฐฝ์ ์ด๋ ค๋ฉด ์ ์ฅ์ ์ ํ์ ํด๋ฆญํฉ๋๋ค.
quickstart-kfp-repo
์ ์ฅ์๋ฅผ ์ ํํ ํ ์ ํ์ ํด๋ฆญํฉ๋๋ค.hello-world
ํจํค์ง๋ฅผ ํด๋ฆญํฉ๋๋ค.4f245e8f9605
๋ฒ์ ์์ ์คํ ๋ง๋ค๊ธฐ๋ฅผ ํด๋ฆญํฉ๋๋ค.๋ฐํ์ ๊ตฌ์ฑ์ ํด๋ฆญํฉ๋๋ค.
Cloud Storage ์์น์ ๋ค์์ ์ ๋ ฅํฉ๋๋ค.
gs://BUCKET_NAME
BUCKET_NAME์ ํ์ดํ๋ผ์ธ ์คํ ์คํ ์ด์ง์ ์ํด ๋ง๋ ๋ฒํท์ ์ด๋ฆ์ผ๋ก ๋ฐ๊ฟ๋๋ค.
์ ์ถ์ ํด๋ฆญํฉ๋๋ค.
Python์ฉ Vertex AI SDK
๋ค์ ์ํ์ ์ฌ์ฉํ์ฌ ํ ํ๋ฆฟ์์ ํ์ดํ๋ผ์ธ ์คํ์ ๋ง๋ญ๋๋ค.
from google.cloud import aiplatform
# Initialize the aiplatform package
aiplatform.init(
project="PROJECT_ID",
location='us-central1',
staging_bucket=STAGING_BUCKET)
# Create a pipeline job using a version ID.
job = aiplatform.PipelineJob(
display_name="hello-world-latest",
template_path="https://us-central1-kfp.pkg.dev/PROJECT_ID/quickstart-kfp-repo/hello-world@SHA256_TAG" + \
versionName)
# Alternatively, create a pipeline job using a tag.
job = aiplatform.PipelineJob(
display_name="hello-world-latest",
template_path="https://us-central1-kfp.pkg.dev/PROJECT_ID/quickstart-kfp-repo/hello-world/TAG")
job.submit()
๋ค์์ ๋ฐ๊ฟ๋๋ค.
PROJECT_ID: ์ด ํ์ดํ๋ผ์ธ์ด ์คํ๋๋ Google Cloud ํ๋ก์ ํธ์ ๋๋ค.
SHA256_TAG: ํ ํ๋ฆฟ ๋ฒ์ ์ sha256 ํด์ ๊ฐ์ ๋๋ค.
TAG: ํ ํ๋ฆฟ์ ๋ฒ์ ํ๊ทธ์ ๋๋ค.
์์ฑ๋ ํ์ดํ๋ผ์ธ ์คํ ๋ณด๊ธฐ
Python์ฉ Vertex AI SDK์์ ํน์ ํ์ดํ๋ผ์ธ ๋ฒ์ ์ผ๋ก ์์ฑ๋ ์คํ์ ๋ณผ ์ ์์ต๋๋ค.
์ฝ์
Google Cloud ์ฝ์์์ Vertex AI Pipelines๋ฅผ ์ฝ๋๋ค.
๋ด ํ ํ๋ฆฟ ํญ์ ํด๋ฆญํฉ๋๋ค.
์ ์ฅ์ ์ ํ์ ํด๋ฆญํฉ๋๋ค.
๋ชฉ๋ก์์
quickstart-kfp-repo
์ ์ฅ์๋ฅผ ์ ํํ ํ ์ ํ์ ํด๋ฆญํฉ๋๋ค.hello-world
ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ๋ฒ์ ๋ชฉ๋ก์ ๋ณด๋ ค๋ฉดhello world
ํ ํ๋ฆฟ์ ํด๋ฆญํฉ๋๋ค.ํ์ดํ๋ผ์ธ ์คํ์ ๋ณด๋ ค๋ ์ํ๋ ๋ฒ์ ์ ํด๋ฆญํฉ๋๋ค.
์ ํํ ๋ฒ์ ์ ํ์ดํ๋ผ์ธ ์คํ์ ๋ณด๋ ค๋ฉด ์คํ ๋ณด๊ธฐ๋ฅผ ํด๋ฆญํ ํ ์คํ ํญ์ ํด๋ฆญํฉ๋๋ค.
Python์ฉ Vertex AI SDK
ํ์ดํ๋ผ์ธ ์คํ์ ๋์ดํ๋ ค๋ฉด ๋ค์ ์์ ์ค ํ๋ ์ด์์ ํ์๋ pipelineJobs.list ๋ช ๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
from google.cloud import aiplatform
# To filter all runs created from a specific version
filter = 'template_uri:"https://us-central1-kfp.pkg.dev/PROJECT_ID/quickstart-kfp-repo/hello-world/*" AND ' + \
'template_metadata.version="%s"' % versionName
aiplatform.PipelineJob.list(filter=filter)
# To filter all runs created from a specific version tag
filter = 'template_uri="https://us-central1-kfp.pkg.dev/PROJECT_ID/quickstart-kfp-repo/hello-world/latest"'
aiplatform.PipelineJob.list(filter=filter)
# To filter all runs created from a package
filter = 'template_uri:"https://us-central1-kfp.pkg.dev/PROJECT_ID/quickstart-kfp-repo/hello-world/*"'
aiplatform.PipelineJob.list(filter=filter)
# To filter all runs created from a repo
filter = 'template_uri:"https://us-central1-kfp.pkg.dev/PROJECT_ID/quickstart-kfp-repo/*"'
aiplatform.PipelineJob.list(filter=filter)
Kubeflow Pipelines SDK ๋ ์ง์คํธ๋ฆฌ ํด๋ผ์ด์ธํธ์์ ํ ํ๋ฆฟ ์ฌ์ฉ
Kubeflow Pipelines SDK ๋ ์ง์คํธ๋ฆฌ ํด๋ผ์ด์ธํธ๋ฅผ Artifact Registry์ ํจ๊ป ์ฌ์ฉํ์ฌ ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ๋ค์ด๋ก๋ํ๊ณ ์ฌ์ฉํ ์ ์์ต๋๋ค.
์ ์ฅ์์ ๋ฆฌ์์ค๋ฅผ ๋์ดํ๋ ค๋ฉด ๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
templatePackages = client.list_packages() templatePackage = client.get_package(package_name = "hello-world") versions = client.list_versions(package_name="hello-world") version = client.get_version(package_name="hello-world", version=versionName) tags = client.list_tags(package_name = "hello-world") tag = client.get_tag(package_name = "hello-world", tag="latest")
์ฌ์ฉ ๊ฐ๋ฅํ ๋ฉ์๋ ๋ฐ ๋ฌธ์์ ์ ์ฒด ๋ชฉ๋ก์ Artifact Registry GitHub ์ ์ฅ์์
proto
ํ์ผ์ ์ฐธ์กฐํ์ธ์.ํ ํ๋ฆฟ์ ๋ก์ปฌ ํ์ผ ์์คํ ์ ๋ค์ด๋ก๋ํ๋ ค๋ฉด ๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
# Sample 1 filename = client.download_pipeline( package_name = "hello-world", version = versionName) # Sample 2 filename = client.download_pipeline( package_name = "hello-world", tag = "v1") # Sample 3 filename = client.download_pipeline( package_name = "hello-world", tag = "v1", file_name = "hello-world-template.yaml")
Artifact Registry REST API ์ฌ์ฉ
๋ค์ ์น์ ์์๋ Artifact Registry REST API๋ฅผ ์ฌ์ฉํ์ฌ Artifact Registry ์ ์ฅ์์์ ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ๊ด๋ฆฌํ๋ ๋ฐฉ๋ฒ์ ์์ฝํฉ๋๋ค.
Artifact Registry REST API๋ฅผ ์ฌ์ฉํ์ฌ ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ ์ ๋ก๋
์ด ์น์ ์ ์ค๋ช ๋ ๋งค๊ฐ๋ณ์ ๊ฐ์ ์ฌ์ฉํ์ฌ HTTP ์์ฒญ์ ๋ง๋ค๋ฉด ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ์ ๋ก๋ํ ์ ์์ต๋๋ค.
- PROJECT_ID: ์ด ํ์ดํ๋ผ์ธ์ด ์คํ๋๋ Google Cloud ํ๋ก์ ํธ
- REPO_ID: Artifact Registry ์ ์ฅ์์ ID
curl ์์ฒญ ์์
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-F tags=v1,latest \
-F content=@pipeline_spec.yaml \
https://us-central1-kfp.pkg.dev/PROJECT_ID/REPO_ID
์ ๋ก๋ ์์ฒญ ๊ตฌ์ฑ
์์ฒญ์ด HTTP ๋๋ HTTPS ๋ฉํฐํํธ ์์ฒญ์ ๋๋ค. ์์ฒญ ํค๋์ ์ธ์ฆ ํ ํฐ์ด ํฌํจ๋์ด ์์ด์ผ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ gcloud auth print-access-token์ ์ฐธ์กฐํ์ธ์.
์์ฒญ์ ํ์ด๋ก๋๋ pipeline_spec.yaml
ํ์ผ(๋๋ .zip ํจํค์ง)์ ์ฝํ
์ธ ์
๋๋ค. ๊ถ์ฅ ํฌ๊ธฐ ํ๋๋ 10MiB์
๋๋ค.
ํจํค์ง ์ด๋ฆ์ pipeline_spec.yaml
ํ์ผ์ pipeline_spec.pipeline_info.name
ํญ๋ชฉ์์ ๊ฐ์ ธ์ต๋๋ค. ํจํค์ง ์ด๋ฆ์ ํจํค์ง๋ฅผ ๊ณ ์ ํ๊ฒ ์๋ณํ๋ฉฐ ์ฌ๋ฌ ๋ฒ์ ์์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. ๊ธธ์ด๋ 4~128์ ์ฌ์ด์ฌ์ผ ํ๋ฉฐ ์ ๊ท ํํ์ ^[a-z0-9][a-z0-9-]{3,127}$
์ ์ผ์นํด์ผ ํฉ๋๋ค.
tags
ํจํค์ง๋ ์ต๋ ์ฌ๋ ๊ฐ์ ์ผํ๋ก ๊ตฌ๋ถ๋ ํ๊ทธ ๋ชฉ๋ก์
๋๋ค.
๊ฐ ํ๊ทธ๋ ^[a-zA-Z0-9\-._~:@+]{1,128}$
์ ๊ท ํํ์๊ณผ ์ผ์นํด์ผ ํฉ๋๋ค.
ํ๊ทธ๊ฐ ์กด์ฌํ๊ณ ์ด๋ฏธ ์
๋ก๋๋ ํ์ดํ๋ผ์ธ์ ๊ฐ๋ฆฌํค๋ ๊ฒฝ์ฐ ํ์ฌ ์
๋ก๋ ์ค์ธ ํ์ดํ๋ผ์ธ์ ๊ฐ๋ฆฌํค๋๋ก ํ๊ทธ๊ฐ ์
๋ฐ์ดํธ๋ฉ๋๋ค. ์๋ฅผ ๋ค์ด latest
ํ๊ทธ๊ฐ ์ด๋ฏธ ์
๋ก๋ํ ํ์ดํ๋ผ์ธ์ ๊ฐ๋ฆฌํค๊ณ --tag=latest
๋ก ์ ๋ฒ์ ์ ์
๋ก๋ํ๋ ๊ฒฝ์ฐ latest
ํ๊ทธ๊ฐ ์ด์ ์ ์
๋ก๋ํ ํ์ดํ๋ผ์ธ์์ ์ญ์ ๋๊ณ ์
๋ก๋ ์ค์ธ ์ ํ์ดํ๋ผ์ธ์ ํ ๋น๋ฉ๋๋ค.
์ ๋ก๋ํ๋ ํ์ดํ๋ผ์ธ์ด ์ด์ ์ ์ ๋ก๋ํ ํ์ดํ๋ผ์ธ๊ณผ ๋์ผํ ๊ฒฝ์ฐ ์ ๋ก๋๊ฐ ์ฑ๊ณตํฉ๋๋ค. ๋ฒ์ ํ๊ทธ๋ฅผ ํฌํจํ์ฌ ์ ๋ก๋๋ ํ์ดํ๋ผ์ธ์ ๋ฉํ๋ฐ์ดํฐ๋ ์ ๋ก๋ ์์ฒญ์ ๋งค๊ฐ๋ณ์ ๊ฐ๊ณผ ์ผ์นํ๋๋ก ์ ๋ฐ์ดํธ๋ฉ๋๋ค.
์๋ต ์ ๋ก๋
์
๋ก๋ ์์ฒญ์ด ์ฑ๊ณตํ๋ฉด HTTP OK
์ํ๊ฐ ๋ฐํ๋ฉ๋๋ค. ์๋ต ๋ณธ๋ฌธ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
{packageName}/{versionName=sha256:abcdef123456...}
์ฌ๊ธฐ์ versionName
์ 16์ง์ ๋ฌธ์์ด๋ก ํ์์ด ์ง์ ๋ pipeline_spec.yaml
์ sha256 ๋ค์ด์ ์คํธ์
๋๋ค.
Artifact Registry REST API๋ฅผ ์ฌ์ฉํ์ฌ ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ ๋ค์ด๋ก๋
์ด ์น์ ์ ์ค๋ช ๋ ๋งค๊ฐ๋ณ์ ๊ฐ์ ์ฌ์ฉํ์ฌ HTTP ์์ฒญ์ ๋ง๋ค๋ฉด ํ์ดํ๋ผ์ธ ํ ํ๋ฆฟ์ ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค.
- PROJECT_ID: ์ด ํ์ดํ๋ผ์ธ์ด ์คํ๋๋ Google Cloud ํ๋ก์ ํธ
- REPO_ID: Artifact Registry ์ ์ฅ์์ ID
- PACKAGE_ID: ์ ๋ก๋ํ ํ ํ๋ฆฟ์ ํจํค์ง ID
- TAG: ๋ฒ์ ํ๊ทธ์
- VERSION:
sha256:abcdef123456...
ํ์์ ํ ํ๋ฆฟ ๋ฒ์
ํ์ค Artifact Registry ๋ค์ด๋ก๋์ ๊ฒฝ์ฐ ๋ค์๊ณผ ๊ฐ์ด ๋ค์ด๋ก๋ ๋งํฌ๋ฅผ ์์ฑํด์ผ ํฉ๋๋ค.
url = https://us-central1-kfp.pkg.dev/PROJECT_ID/REPO_ID/PACKAGE_ID/VERSION
url = https://us-central1-kfp.pkg.dev/PROJECT_ID/REPO_ID/PACKAGE_ID/TAG
์ฌ๋ฌ curl ์์ฒญ ์์
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://us-central1-kfp.pkg.dev/PROJECT_ID/REPO_ID/PACKAGE_ID/VERSION
๋ค์ ์์์ ๊ฐ์ด VERSION์ TAG๋ก ๋ฐ๊พธ๊ณ ๋์ผํ ํ ํ๋ฆฟ์ ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค.
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://us-central1-kfp.pkg.dev/PROJECT_ID/REPO_ID/PACKAGE_ID/TAG
์๋ต ๋ค์ด๋ก๋
๋ค์ด๋ก๋ ์์ฒญ์ด ์ฑ๊ณตํ๋ฉด HTTP OK
์ํ๊ฐ ๋ฐํ๋ฉ๋๋ค. ์๋ต ๋ณธ๋ฌธ์ pipeline_spec.yaml
ํ์ผ์ ์ฝํ
์ธ ์
๋๋ค.
์ฐธ์กฐ ๋งํฌ
- ์ ์ฅ์ ๊ด๋ฆฌ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ Artifact Registry - ์ ์ฅ์ ๊ฐ์๋ฅผ ์ฐธ์กฐํ์ธ์.
- Repository API
- ํ์ ํค์๋๋ 'KFP'์ ๋๋ค.
- ํจํค์ง API
- ๋ฒ์ API
- ํ๊ทธ API
- GitHub์ Proto ์ ์