From 25bda6d848e7cbde23688e2b5a3c8a4502e6f080 Mon Sep 17 00:00:00 2001 From: AlexanderLavelle <73360008+AlexanderLavelle@users.noreply.github.com> Date: Fri, 13 Sep 2024 15:12:15 -0400 Subject: [PATCH 1/3] Add project and location Signed-off-by: AlexanderLavelle <73360008+AlexanderLavelle@users.noreply.github.com> --- .../google_cloud_pipeline_components/v1/custom_job/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py b/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py index 9002939e298..6dee185bd36 100644 --- a/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py +++ b/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py @@ -71,6 +71,8 @@ def create_custom_training_job_from_component( labels: Optional[Dict[str, str]] = None, persistent_resource_id: str = _placeholders.PERSISTENT_RESOURCE_ID_PLACEHOLDER, env: Optional[List[Dict[str, str]]] = None, + project: Optional[str] = None, + location: Optional[str] = None, ) -> Callable: # fmt: off """Convert a KFP component into Vertex AI [custom training job](https://cloud.google.com/vertex-ai/docs/training/create-custom-job) using the [CustomJob](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.customJobs) API. @@ -203,6 +205,8 @@ def create_custom_training_job_from_component( 'labels': labels or {}, 'encryption_spec_key_name': encryption_spec_key_name, 'persistent_resource_id': persistent_resource_id, + 'project': project, + 'location': location } for param_name, default_value in custom_job_param_defaults.items(): From d77686e9c0aca46b6564d099257a55ed389be633 Mon Sep 17 00:00:00 2001 From: Alexander Lavelle Date: Fri, 13 Sep 2024 15:29:45 -0400 Subject: [PATCH 2/3] edit comma to align with list item formatting Signed-off-by: Alexander Lavelle --- .../google_cloud_pipeline_components/v1/custom_job/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py b/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py index 6dee185bd36..e0ee7e32247 100644 --- a/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py +++ b/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py @@ -206,7 +206,7 @@ def create_custom_training_job_from_component( 'encryption_spec_key_name': encryption_spec_key_name, 'persistent_resource_id': persistent_resource_id, 'project': project, - 'location': location + 'location': location, } for param_name, default_value in custom_job_param_defaults.items(): From dd6cfb57bd469bfa70d93d2d9d76caa81fc4422a Mon Sep 17 00:00:00 2001 From: Alexander Lavelle Date: Thu, 19 Sep 2024 18:53:08 -0400 Subject: [PATCH 3/3] remember to add docstring and copy docstring hints from other files Signed-off-by: Alexander Lavelle --- .../google_cloud_pipeline_components/v1/custom_job/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py b/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py index e0ee7e32247..8f6face0343 100644 --- a/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py +++ b/components/google-cloud/google_cloud_pipeline_components/v1/custom_job/utils.py @@ -71,8 +71,8 @@ def create_custom_training_job_from_component( labels: Optional[Dict[str, str]] = None, persistent_resource_id: str = _placeholders.PERSISTENT_RESOURCE_ID_PLACEHOLDER, env: Optional[List[Dict[str, str]]] = None, - project: Optional[str] = None, - location: Optional[str] = None, + project: Optional[str] = _placeholders.PROJECT_ID_PLACEHOLDER, + location: Optional[str] = "us-central1", ) -> Callable: # fmt: off """Convert a KFP component into Vertex AI [custom training job](https://cloud.google.com/vertex-ai/docs/training/create-custom-job) using the [CustomJob](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.customJobs) API. @@ -101,6 +101,8 @@ def create_custom_training_job_from_component( labels: The labels with user-defined metadata to organize the CustomJob. See [more information](https://goo.gl/xmQnxf). persistent_resource_id: The ID of the PersistentResource in the same Project and Location which to run. The default value is a placeholder that will be resolved to the PipelineJob [RuntimeConfig](https://cloud.google.com/vertex-ai/docs/reference/rest/v1/projects.locations.pipelineJobs#PipelineJob.RuntimeConfig)'s persistent resource id at runtime. However, if the PipelineJob doesn't set Persistent Resource as the job level runtime, the placedholder will be resolved to an empty string and the custom job will be run on demand. If the value is set explicitly, the custom job will runs in the specified persistent resource, in this case, please note the network and CMEK configs on the job should be consistent with those on the PersistentResource, otherwise, the job will be rejected. env: Environment variables to be passed to the container. Takes the form `[{'name': '...', 'value': '...'}]`. Maximum limit is 100. + project: Project to run the CustomJob. Defaults to the project in which the PipelineJob is run, but may need specified depending on VPC. + location: Location to run the HyperparameterTuningJob in, defaults to `'us-central1'`. Returns: A KFP component with CustomJob specification applied.