def artifact_objs(sagemaker_session): artifact_objs = [] for artifact_name in names(): artifact_objs.append( artifact.Artifact.create( artifact_name=artifact_name, artifact_type="SDKIntegrationTest", source_uri=name(), properties={"k1": "v1"}, sagemaker_session=sagemaker_session, )) time.sleep(SLEEP_TIME_SECONDS) artifact_objs.append( artifact.Artifact.create( artifact_name=name(), artifact_type="SDKIntegrationTestType2", source_uri=name(), properties={"k1": "v1"}, sagemaker_session=sagemaker_session, )) yield artifact_objs for artifact_obj in artifact_objs: artifact_obj.delete()
def dataset_artifact_associated_models(sagemaker_session, trial_component_obj, model_artifact_obj1): dataset_artifact_obj = artifact.DatasetArtifact.create( artifact_name="dataset-artifact-name", artifact_type="Context", source_uri=name(), source_types=None, sagemaker_session=sagemaker_session, ) association.Association.create( source_arn=dataset_artifact_obj.artifact_arn, destination_arn=trial_component_obj.trial_component_arn, sagemaker_session=sagemaker_session, ) association_obj = association.Association.create( source_arn=trial_component_obj.trial_component_arn, destination_arn=model_artifact_obj1.artifact_arn, sagemaker_session=sagemaker_session, ) yield dataset_artifact_obj time.sleep(SLEEP_TIME_SECONDS) dataset_artifact_obj.delete(disassociate=True) association_obj.delete
def endpoint_context_associate_with_model(sagemaker_session, endpoint_action_obj, model_obj): context_name = name() obj = context.EndpointContext.create( source_uri="endpontContextWithModel" + context_name, context_name=context_name, source_type="test-source-type", context_type="test-context-type", description="test-description", properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) association.Association.create( source_arn=obj.context_arn, destination_arn=endpoint_action_obj.action_arn, sagemaker_session=sagemaker_session, ) association.Association.create( source_arn=endpoint_action_obj.action_arn, destination_arn=model_obj.context_arn, sagemaker_session=sagemaker_session, ) yield obj time.sleep(SLEEP_TIME_SECONDS) obj.delete(disassociate=True)
def model_artifact_associated_endpoints(sagemaker_session, endpoint_deployment_action_obj, endpoint_context_obj): model_artifact_obj = artifact.ModelArtifact.create( artifact_name="model-artifact-name", artifact_type="model-artifact-type", source_uri=name(), source_types=None, sagemaker_session=sagemaker_session, ) association.Association.create( source_arn=model_artifact_obj.artifact_arn, destination_arn=endpoint_deployment_action_obj.action_arn, sagemaker_session=sagemaker_session, ) association.Association.create( source_arn=endpoint_deployment_action_obj.action_arn, destination_arn=endpoint_context_obj.context_arn, sagemaker_session=sagemaker_session, ) yield model_artifact_obj time.sleep(SLEEP_TIME_SECONDS) model_artifact_obj.delete(disassociate=True)
def trial_component_obj(sagemaker_session): trial_component_obj = trial_component.TrialComponent.create( trial_component_name=name(), sagemaker_boto_client=sagemaker_session.sagemaker_client) yield trial_component_obj time.sleep(0.5) trial_component_obj.delete()
def trial_obj(sagemaker_session, experiment_obj): trial_obj = trial.Trial.create( trial_name=name(), experiment_name=experiment_obj.experiment_name, sagemaker_boto_client=sagemaker_session.sagemaker_client, ) yield trial_obj time.sleep(0.5) trial_obj.delete()
def model_artifact_obj1(sagemaker_session): obj = artifact.Artifact.create( artifact_name="foo", artifact_type="Context", source_uri=name(), properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) yield obj time.sleep(SLEEP_TIME_SECONDS) obj.delete(disassociate=True)
def artifact_obj(sagemaker_session): obj = artifact.Artifact.create( artifact_name="SDKIntegrationTest", artifact_type="SDKIntegrationTest", source_uri=name(), properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) yield obj time.sleep(SLEEP_TIME_SECONDS) obj.delete()
def endpoint_action_obj(sagemaker_session): obj = action.Action.create( action_name=name(), action_type="ModelDeployment", source_uri="bazz", status="InProgress", properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) yield obj time.sleep(SLEEP_TIME_SECONDS) obj.delete(disassociate=True)
def action_obj(sagemaker_session): obj = action.Action.create( action_name=name(), action_type="bar", source_uri="bazz", status="InProgress", properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) yield obj time.sleep(SLEEP_TIME_SECONDS) obj.delete()
def model_obj(sagemaker_session): model = artifact.Artifact.create( artifact_name=name(), artifact_type="Model", source_uri="bar1", properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) yield model time.sleep(SLEEP_TIME_SECONDS) retry(lambda: model.delete(disassociate=True), num_attempts=4)
def experiment_obj(sagemaker_session): description = "{}-{}".format("description", str(uuid.uuid4())) boto3.set_stream_logger("", logging.INFO) experiment_name = name() experiment_obj = experiment.Experiment.create( experiment_name=experiment_name, description=description, sagemaker_boto_client=sagemaker_session.sagemaker_client, ) yield experiment_obj time.sleep(0.5) experiment_obj.delete()
def endpoint_context_obj(sagemaker_session): obj = context.Context.create( context_name=name(), source_uri="bar", source_type="Context", context_type="test-context-type", description="test-description", properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) yield obj time.sleep(SLEEP_TIME_SECONDS) obj.delete(disassociate=True)
def model_obj(sagemaker_session): model = context.Context.create( context_name=name(), source_uri="bar1", source_type="test-source-type1", context_type="Model", description="test-description", properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) yield model time.sleep(SLEEP_TIME_SECONDS) model.delete(disassociate=True)
def artifact_obj_with_association(sagemaker_session, artifact_obj): obj = artifact.Artifact.create( artifact_name="foo", artifact_type="SDKIntegrationTest", source_uri=name(), properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) association.Association.create( source_arn=obj.artifact_arn, destination_arn=artifact_obj.artifact_arn, sagemaker_session=sagemaker_session, ) yield obj time.sleep(SLEEP_TIME_SECONDS) obj.delete(disassociate=True)
def action_obj_with_association(sagemaker_session, artifact_obj): obj = action.Action.create( action_name=name(), action_type="bar", source_uri="bazz", status="InProgress", properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) association.Association.create( source_arn=obj.action_arn, destination_arn=artifact_obj.artifact_arn, sagemaker_session=sagemaker_session, ) yield obj time.sleep(SLEEP_TIME_SECONDS) obj.delete(disassociate=True)
def context_obj_with_association(sagemaker_session, action_obj): obj = context.Context.create( context_name=name(), source_uri="bar", source_type="test-source-type", context_type="test-context-type", description="test-description", properties={"k1": "v1"}, sagemaker_session=sagemaker_session, ) association.Association.create( source_arn=obj.context_arn, destination_arn=action_obj.action_arn, sagemaker_session=sagemaker_session, ) yield obj time.sleep(SLEEP_TIME_SECONDS) obj.delete(disassociate=True)