Skip to content

Commit

Permalink
Google Cloud - Vertex_AI - Models - Upload_Scikit-learn_pickle_model …
Browse files Browse the repository at this point in the history
…- Simplified the component after my Vertex SDK fixes were merged

Some of my Vertex SDK fixes:
googleapis/python-aiplatform#779
googleapis/python-aiplatform#882
googleapis/python-aiplatform#943
googleapis/python-aiplatform#997
  • Loading branch information
Ark-kun committed Aug 1, 2022
1 parent 4677245 commit 32a849a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
Expand Up @@ -18,15 +18,14 @@ def upload_Scikit_learn_pickle_model_to_Google_Cloud_Vertex_AI(
# explanation_parameters: "google.cloud.aiplatform_v1.types.explanation.ExplanationParameters" = None,

project: str = None,
location: str = "us-central1",
location: str = None,
labels: dict = None,
# encryption_spec_key_name: str = None,
staging_bucket: str = None,
) -> NamedTuple("Outputs", [
("model_name", "GoogleCloudVertexAiModelName"),
("model_dict", dict),
]):
import datetime
import json
import os
import shutil
Expand All @@ -45,8 +44,6 @@ def upload_Scikit_learn_pickle_model_to_Google_Cloud_Vertex_AI(
_, renamed_model_path = tempfile.mkstemp(suffix=".pkl")
shutil.copyfile(src=model_path, dst=renamed_model_path)

display_name = display_name or "Scikit-learn model " + datetime.datetime.now().isoformat(sep=" ")

model = aiplatform.Model.upload_scikit_learn_model_file(
model_file_path=renamed_model_path,
sklearn_version=sklearn_version,
Expand Down Expand Up @@ -82,8 +79,7 @@ def upload_Scikit_learn_pickle_model_to_Google_Cloud_Vertex_AI(
func=upload_Scikit_learn_pickle_model_to_Google_Cloud_Vertex_AI,
base_image="python:3.9",
packages_to_install=[
# "google-cloud-aiplatform==1.10.0",
"git+https://github.com/Ark-kun/python-aiplatform@9b50f62b9d1409644656fb3202edc7be19c722f4#egg=google-cloud-aiplatform&subdirectory=." # branch: fix--Fixed-getitng-project-ID-when-running-on-Vertex-AI
"google-cloud-aiplatform==1.16.0",
],
annotations={
"author": "Alexey Volkov <alexey.volkov@ark-kun.com>",
Expand Down
Expand Up @@ -7,7 +7,7 @@ inputs:
- {name: display_name, type: String, optional: true}
- {name: description, type: String, optional: true}
- {name: project, type: String, optional: true}
- {name: location, type: String, default: us-central1, optional: true}
- {name: location, type: String, optional: true}
- {name: labels, type: JsonObject, optional: true}
- {name: staging_bucket, type: String, optional: true}
outputs:
Expand All @@ -20,9 +20,8 @@ implementation:
- sh
- -c
- (PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location
'git+https://github.com/Ark-kun/python-aiplatform@9b50f62b9d1409644656fb3202edc7be19c722f4#egg=google-cloud-aiplatform&subdirectory=.'
|| PIP_DISABLE_PIP_VERSION_CHECK=1 python3 -m pip install --quiet --no-warn-script-location
'git+https://github.com/Ark-kun/python-aiplatform@9b50f62b9d1409644656fb3202edc7be19c722f4#egg=google-cloud-aiplatform&subdirectory=.'
'google-cloud-aiplatform==1.16.0' || PIP_DISABLE_PIP_VERSION_CHECK=1 python3
-m pip install --quiet --no-warn-script-location 'google-cloud-aiplatform==1.16.0'
--user) && "$0" "$@"
- sh
- -ec
Expand All @@ -46,12 +45,11 @@ implementation:
# explanation_parameters: "google.cloud.aiplatform_v1.types.explanation.ExplanationParameters" = None,
project = None,
location = "us-central1",
location = None,
labels = None,
# encryption_spec_key_name: str = None,
staging_bucket = None,
):
import datetime
import json
import os
import shutil
Expand All @@ -70,8 +68,6 @@ implementation:
_, renamed_model_path = tempfile.mkstemp(suffix=".pkl")
shutil.copyfile(src=model_path, dst=renamed_model_path)
display_name = display_name or "Scikit-learn model " + datetime.datetime.now().isoformat(sep=" ")
model = aiplatform.Model.upload_scikit_learn_model_file(
model_file_path=renamed_model_path,
sklearn_version=sklearn_version,
Expand Down

0 comments on commit 32a849a

Please sign in to comment.