추적 엔터티 수동 생성 - 아마존 SageMaker

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

추적 엔터티 수동 생성

모든 속성에 대해 추적 엔터티를 수동으로 만들 수 있습니다. Amazon이 SageMaker 자동으로 생성하는 추적 개체에 대한 자세한 내용은 을 참조하십시오Amazon SageMaker — 생성된 추적 엔티티.

연결을 제외한 모든 엔터티에 태그를 추가할 수 있습니다. 태그는 사용자 지정 정보를 제공하는 임의의 키-값 쌍입니다. 목록 또는 검색 쿼리를 태그별로 필터링하거나 정렬할 수 있습니다. 자세한 내용은 의 AWS 리소스 태깅을 AWS 일반 참조참조하십시오.

계보 엔티티를 생성하는 방법을 보여주는 샘플 노트북은 Amazon 예제 리포지토리의 Amazon SageMaker Lineage 노트북을 참조하십시오. SageMaker GitHub

엔터티 수동 생성

다음 절차는 SageMaker 교육 작업과 엔드포인트 간에 아티팩트를 생성하고 연결하는 방법을 보여줍니다. 다음 절차를 수행합니다.

추적 엔터티 및 연결 가져오기
  1. 계보 추적 엔터티를 가져옵니다.

    import sys !{sys.executable} -m pip install -q sagemaker from sagemaker import get_execution_role from sagemaker.session import Session from sagemaker.lineage import context, artifact, association, action import boto3 boto_session = boto3.Session(region_name=region) sagemaker_client = boto_session.client("sagemaker")
  2. 입력 및 출력 아티팩트 생성

    code_location_arn = artifact.Artifact.create( artifact_name='source-code-location', source_uri='s3://...', artifact_type='code-location' ).artifact_arn # Similar constructs for train_data_location_arn and test_data_location_arn model_location_arn = artifact.Artifact.create( artifact_name='model-location', source_uri='s3://...', artifact_type='model-location' ).artifact_arn
  3. 모델을 훈련시키고 훈련 작업을 나타내는 trial_component_arn을 가져옵니다.

  4. 입력 아티팩트와 출력 아티팩트를 훈련 작업(시험 구성 요소)에 연결합니다.

    input_artifacts = [code_location_arn, train_data_location_arn, test_data_location_arn] for artifact_arn in input_artifacts: try: association.Association.create( source_arn=artifact_arn, destination_arn=trial_component_arn, association_type='ContributedTo' ) except: logging.info('association between {} and {} already exists', artifact_arn, trial_component_arn) output_artifacts = [model_location_arn] for artifact_arn in output_artifacts: try: association.Association.create( source_arn=trial_component_arn, destination_arn=artifact_arn, association_type='Produced' ) except: logging.info('association between {} and {} already exists', artifact_arn, trial_component_arn)
  5. 추론 엔드포인트를 생성합니다.

    predictor = mnist_estimator.deploy(initial_instance_count=1, instance_type='ml.m4.xlarge')
  6. 엔드포인트 컨텍스트를 생성합니다.

    from sagemaker.lineage import context endpoint = sagemaker_client.describe_endpoint(EndpointName=predictor.endpoint_name) endpoint_arn = endpoint['EndpointArn'] endpoint_context_arn = context.Context.create( context_name=predictor.endpoint_name, context_type='Endpoint', source_uri=endpoint_arn ).context_arn
  7. 훈련 작업(시험 구성 요소)과 엔드포인트 컨텍스트를 연결합니다.

    association.Association.create( source_arn=trial_component_arn, destination_arn=endpoint_context_arn )

워크플로 수동 추적

이전 섹션에서 생성한 워크플로를 수동으로 추적할 수 있습니다.

이전 예시의 엔드포인트 Amazon 리소스 이름(ARN)을 고려하여 다음 절차는 엔드포인트에 배포된 모델을 훈련시키는 데 사용된 데이터 세트로 워크플로를 추적하는 방법을 보여줍니다. 다음 절차를 수행합니다.

엔드포인트에서 훈련 데이터 원본까지의 워크플로를 추적하려면
  1. 추적 엔터티를 가져옵니다.

    import sys !{sys.executable} -m pip install -q sagemaker from sagemaker import get_execution_role from sagemaker.session import Session from sagemaker.lineage import context, artifact, association, action import boto3 boto_session = boto3.Session(region_name=region) sagemaker_client = boto_session.client("sagemaker")
  2. 엔드포인트 ARN에서 엔드포인트 컨텍스트를 가져옵니다.

    endpoint_context_arn = sagemaker_client.list_contexts( SourceUri=endpoint_arn)['ContextSummaries'][0]['ContextArn']
  3. 시험 구성 요소와 엔드포인트 컨텍스트 간의 연결을 통해 시험 구성 요소를 가져옵니다.

    trial_component_arn = sagemaker_client.list_associations( DestinationArn=endpoint_context_arn)['AssociationSummaries'][0]['SourceArn']
  4. 시험 구성 요소와 엔드포인트 컨텍스트 간의 연결에서 훈련 데이터 위치 아티팩트를 가져옵니다.

    train_data_location_artifact_arn = sagemaker_client.list_associations( DestinationArn=trial_component_arn, SourceType='Model')['AssociationSummaries'][0]['SourceArn']
  5. 훈련 데이터 위치 아티팩트에서 훈련 데이터 위치를 가져옵니다.

    train_data_location = sagemaker_client.describe_artifact( ArtifactArn=train_data_location_artifact_arn)['Source']['SourceUri'] print(train_data_location)

    응답:

    s3://sagemaker-sample-data-us-east-2/mxnet/mnist/train

Limits

다음을 제외한 모든 엔터티, 실험 및 계보 간에 연결을 만들 수 있습니다.

  • 두 실험 엔터티 간에는 연결을 만들 수 없습니다. 실험 엔터티는 실험, 시험 및 시험 구성 요소로 구성됩니다.

  • 다른 연결을 사용하여 연결을 만들 수 있습니다.

이미 존재하는 엔터티를 생성하려고 하면 오류가 발생합니다.

수동으로 생성된 계보 엔터티의 최대 수
  • 작업: 3000

  • 아티팩트: 6000

  • 연결: 6000

  • 컨텍스트: 500

SageMakerAmazon에서 자동으로 생성하는 계보 개체의 수에는 제한이 없습니다.