From 461d99f39d839b0f741544f657b216be091253b0 Mon Sep 17 00:00:00 2001 From: Taji Harris Date: Thu, 5 Jan 2023 14:26:32 -0800 Subject: [PATCH 1/5] p1 component deployment exisitng job definition --- .../batch/job_definition_schema.py | 4 ++-- .../_batch_deployment_operations.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_deployment/batch/job_definition_schema.py b/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_deployment/batch/job_definition_schema.py index b44815c37929..df85a9dea97b 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_deployment/batch/job_definition_schema.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_deployment/batch/job_definition_schema.py @@ -9,7 +9,7 @@ from marshmallow import fields, post_load -from azure.ai.ml._schema import ArmVersionedStr, PatchedSchemaMeta, RegistryStr, StringTransformedEnum, UnionField +from azure.ai.ml._schema import ArmVersionedStr, PatchedSchemaMeta, RegistryStr, StringTransformedEnum, UnionField, ArmStr from azure.ai.ml._schema.pipeline.pipeline_component import PipelineComponentFileRefField from azure.ai.ml.constants._common import AzureMLResourceType from azure.ai.ml.constants._job.job import JobType @@ -21,7 +21,7 @@ class JobDefinitionSchema(metaclass=PatchedSchemaMeta): component_id = fields.Str() job = UnionField( [ - RegistryStr(azureml_type=AzureMLResourceType.JOB), + ArmStr(azureml_type=AzureMLResourceType.JOB), PipelineComponentFileRefField(), ] ) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py index 1b8e1f8d3d5e..09e4392c1e25 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py @@ -280,3 +280,22 @@ def _validate_component(self, deployment: Deployment, orchestrators: OperationOr name, _ = parse_prefixed_name_version(deployment.job_definition.component) deployment.job_definition.name = name deployment.job_definition.component_id = component_id + elif(deployment.job_definition.job): + if isinstance(deployment.job_definition.job, str): + component = PipelineComponent(source_job_id= deployment.job_definition.job) + rest_component = self._component_operations.create_or_update( + name = component.name, + resource_group_name=self._resource_group_name, + workspace_name=self._workspace_name, + body = component._to_rest_object(), + version= component.version, + **self._init_kwargs + ) + deployment.job_definition.job = None + deployment.job_definition.component_id = rest_component.id + if not deployment.job_definition.name and rest_component.name: + deployment.job_definition.name = rest_component.name + if not deployment.job_definition.description and rest_component.properties.description: + deployment.job_definition.description = rest_component.properties.description + if not deployment.job_definition.tags and rest_component.properties.tags: + deployment.job_definition.tags = rest_component.properties.tags From ad63f44e07304a02a276aa35e99fd7c3f98b0e74 Mon Sep 17 00:00:00 2001 From: Taji Harris Date: Thu, 5 Jan 2023 16:27:37 -0800 Subject: [PATCH 2/5] removed unused import in job schema --- .../ai/ml/_schema/_deployment/batch/job_definition_schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_deployment/batch/job_definition_schema.py b/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_deployment/batch/job_definition_schema.py index df85a9dea97b..0e2a467bdac5 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_deployment/batch/job_definition_schema.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/_deployment/batch/job_definition_schema.py @@ -9,7 +9,7 @@ from marshmallow import fields, post_load -from azure.ai.ml._schema import ArmVersionedStr, PatchedSchemaMeta, RegistryStr, StringTransformedEnum, UnionField, ArmStr +from azure.ai.ml._schema import ArmVersionedStr, PatchedSchemaMeta, StringTransformedEnum, UnionField, ArmStr from azure.ai.ml._schema.pipeline.pipeline_component import PipelineComponentFileRefField from azure.ai.ml.constants._common import AzureMLResourceType from azure.ai.ml.constants._job.job import JobType From 49f215024e0406fc1517ee8fb077dcec4121c18b Mon Sep 17 00:00:00 2001 From: Taji Harris Date: Thu, 5 Jan 2023 17:04:52 -0800 Subject: [PATCH 3/5] resolve pylint errors --- .../_batch_deployment_operations.py | 37 +++++++++---------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py index 09e4392c1e25..7e636c8b1dc2 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py @@ -280,22 +280,21 @@ def _validate_component(self, deployment: Deployment, orchestrators: OperationOr name, _ = parse_prefixed_name_version(deployment.job_definition.component) deployment.job_definition.name = name deployment.job_definition.component_id = component_id - elif(deployment.job_definition.job): - if isinstance(deployment.job_definition.job, str): - component = PipelineComponent(source_job_id= deployment.job_definition.job) - rest_component = self._component_operations.create_or_update( - name = component.name, - resource_group_name=self._resource_group_name, - workspace_name=self._workspace_name, - body = component._to_rest_object(), - version= component.version, - **self._init_kwargs - ) - deployment.job_definition.job = None - deployment.job_definition.component_id = rest_component.id - if not deployment.job_definition.name and rest_component.name: - deployment.job_definition.name = rest_component.name - if not deployment.job_definition.description and rest_component.properties.description: - deployment.job_definition.description = rest_component.properties.description - if not deployment.job_definition.tags and rest_component.properties.tags: - deployment.job_definition.tags = rest_component.properties.tags + elif isinstance(deployment.job_definition.job, str): + component = PipelineComponent(source_job_id= deployment.job_definition.job) + rest_component = self._component_operations.create_or_update( + name = component.name, + resource_group_name=self._resource_group_name, + workspace_name=self._workspace_name, + body = component._to_rest_object(), + version= component.version, + **self._init_kwargs + ) + deployment.job_definition.job = None + deployment.job_definition.component_id = rest_component.id + if not deployment.job_definition.name and rest_component.name: + deployment.job_definition.name = rest_component.name + if not deployment.job_definition.description and rest_component.properties.description: + deployment.job_definition.description = rest_component.properties.description + if not deployment.job_definition.tags and rest_component.properties.tags: + deployment.job_definition.tags = rest_component.properties.tags From f0e9c74b86b92910a9755523b0c821072261d6d5 Mon Sep 17 00:00:00 2001 From: Taji Harris Date: Thu, 5 Jan 2023 18:16:25 -0800 Subject: [PATCH 4/5] fixing repetative code --- .../_batch_deployment_operations.py | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py index 7e636c8b1dc2..5ae215850769 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py @@ -264,10 +264,6 @@ def _validate_component(self, deployment: Deployment, orchestrators: OperationOr version=deployment.job_definition.component.version, **self._init_kwargs, ) - deployment.job_definition.component = None - deployment.job_definition.component_id = component.id - if not deployment.job_definition.name and component.name: - deployment.job_definition.name = component.name if not deployment.job_definition.description and component.description: deployment.job_definition.description = component.description if not deployment.job_definition.tags and component.tags: @@ -281,20 +277,22 @@ def _validate_component(self, deployment: Deployment, orchestrators: OperationOr deployment.job_definition.name = name deployment.job_definition.component_id = component_id elif isinstance(deployment.job_definition.job, str): - component = PipelineComponent(source_job_id= deployment.job_definition.job) - rest_component = self._component_operations.create_or_update( - name = component.name, + job_component = PipelineComponent(source_job_id= deployment.job_definition.job) + component = self._component_operations.create_or_update( + name = job_component.name, resource_group_name=self._resource_group_name, workspace_name=self._workspace_name, - body = component._to_rest_object(), - version= component.version, + body = job_component._to_rest_object(), + version= job_component.version, **self._init_kwargs ) + if not deployment.job_definition.description and component.properties.description: + deployment.job_definition.description = component.properties.description + if not deployment.job_definition.tags and component.properties.tags: + deployment.job_definition.tags = component.properties.tags + if isinstance(deployment.job_definition.job, str) or isinstance(deployment.job_definition.component, PipelineComponent): + deployment.job_definition.component = None deployment.job_definition.job = None - deployment.job_definition.component_id = rest_component.id - if not deployment.job_definition.name and rest_component.name: - deployment.job_definition.name = rest_component.name - if not deployment.job_definition.description and rest_component.properties.description: - deployment.job_definition.description = rest_component.properties.description - if not deployment.job_definition.tags and rest_component.properties.tags: - deployment.job_definition.tags = rest_component.properties.tags + deployment.job_definition.component_id = component.id + if not deployment.job_definition.name and component.name: + deployment.job_definition.name = component.name \ No newline at end of file From f374aa85d58021259a5eb59116d7479c18dd615f Mon Sep 17 00:00:00 2001 From: Taji Harris Date: Thu, 5 Jan 2023 21:20:27 -0800 Subject: [PATCH 5/5] resolve pylint error --- .../azure/ai/ml/operations/_batch_deployment_operations.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py index 5ae215850769..777b5f856e7d 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_batch_deployment_operations.py @@ -290,9 +290,10 @@ def _validate_component(self, deployment: Deployment, orchestrators: OperationOr deployment.job_definition.description = component.properties.description if not deployment.job_definition.tags and component.properties.tags: deployment.job_definition.tags = component.properties.tags + # pylint: disable=line-too-long if isinstance(deployment.job_definition.job, str) or isinstance(deployment.job_definition.component, PipelineComponent): deployment.job_definition.component = None deployment.job_definition.job = None deployment.job_definition.component_id = component.id if not deployment.job_definition.name and component.name: - deployment.job_definition.name = component.name \ No newline at end of file + deployment.job_definition.name = component.name