aws / sagemaker-python-sdk

A library for training and deploying machine learning models on Amazon SageMaker
https://sagemaker.readthedocs.io/
Apache License 2.0
2.1k stars 1.14k forks source link

Sagemaker PipelineModel Doesn't Support tags when create model #2272

Open wangajing opened 3 years ago

wangajing commented 3 years ago

Describe the bug When create sagemaker PipelineModel and deploy it(https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/pipeline.py#L175-L181), sagemaker PipelineModel doesn't allow passing tags when call create_model.

To reproduce

See the source code here https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/pipeline.py#L175-L181 And tags are not passed when call session.create_model()

Expected behavior when create sageamaker PipelineModel object, tags should be allowed to be passed, and then propagate it to necessary resources.

Screenshots or logs If applicable, add screenshots or logs to help explain your problem.

System information A description of your system. Please provide:

Additional context Add any other context about the problem here.

inverts commented 1 year ago

This is still an issue, here is a permalink to the code where we would likely need tags to be passed through (original description link is out of date) https://github.com/aws/sagemaker-python-sdk/blob/19115a216cffc81d77f88621a27553817ee4fc96/src/sagemaker/pipeline.py#L282-L313

Perhaps something as simple as accepting **kwargs on PipelineModel's create function, and just passing them along through _create_sagemaker_pipeline_model and on to the create_model call would be adequate without adding much complexity.

Similar issues: https://github.com/aws/sagemaker-python-sdk/issues/3447 https://github.com/aws/sagemaker-python-sdk/issues/3733

For now, we can workaround by basically just copying what the source code does and adding in tags. It would just be nice to be able to use the convenient create method. eg.

pipeline_model = PipelineModel(**model_args, models=models, sagemaker_session=sagemaker_session)
containers = pipeline_model.pipeline_container_def(instance_type)
sagemaker_session.create_model(**model_args, container_defs=containers, tags=my_tags)

Note that the above doesn't do some default value resolution that would otherwise happen for the model_args params.

qidewenwhen commented 1 year ago

FYI PipelineModel is not owned or managed by SageMaker Pipeline service, though the name is confusing. Thus removing the component: pipelines tag and leave it in the more proper queue of component: hosting