Skip to content

Commit

Permalink
docs(samples): improve docstring of Vertex AI Python SDK Model Regist…
Browse files Browse the repository at this point in the history
…ry samples (#1705)

* improve doc string

* nox tests passed

* rename location

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
  • Loading branch information
inardini and andrewferlitsch authored Oct 4, 2022
1 parent fc5791b commit f97e90f
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def assign_aliases_model_version_sample(
model_id: The ID of the model.
version_aliases: The version aliases to assign.
version_id: The version ID of the model to assign the aliases to.
project: The project name.
location: The location name.
project: The project ID.
location: The region name.
Returns
None.
"""
# Initialize the client.
aiplatform.init(project=project, location=location)

# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of create method can be also
# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of the Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model_registry = aiplatform.models.ModelRegistry(model=model_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def create_aliased_model_sample(
Args:
model_id: The ID of the model to initialize. Parent resource name of the model is also accepted.
version_id: The version ID or version alias of the model to initialize.
project: The project.
location: The location.
project: The project ID.
location: The region name.
Returns:
Model resource.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def create_default_model_sample(model_id: str, project: str, location: str):
Initialize a Model resource to represent an existing model version with alias 'default'.
Args:
model_id: The ID of the model to initialize. Parent resource name of the model is also accepted.
project: The project.
location: The location.
project: The project ID.
location: The region name.
Returns:
Model resource.
"""
# Initialize the client.
aiplatform.init(project=project, location=location)

# Initialize the Model resource with the ID 'model_id'. The parent_name of create method can be also
# Initialize the Model resource with the ID 'model_id'. The parent_name of the Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
default_model = aiplatform.Model(model_name=model_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ def create_model_registry_sample(model_id: str, project: str, location: str):
Create a ModelRegistry resource associated to model_id
Args:
model_id: The ID of the model.
project: The project name.
location: The location name.
project: The project ID.
location: The region name.
Returns:
ModelRegistry resource.
"""

# Initialize the client.
aiplatform.init(project=project, location=location)

# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of create method can be also
# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model_registry = aiplatform.models.ModelRegistry(model=model_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def delete_aliases_model_version_sample(
model_id: The ID of the model.
version_aliases: The version aliases to assign.
version_id: The version ID of the model to assign the aliases to.
project: The project name.
location: The location name.
project: The project ID.
location: The region name.
Returns
None.
"""
# Initialize the client.
aiplatform.init(project=project, location=location)

# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of create method can be also
# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model_registry = aiplatform.models.ModelRegistry(model=model_id)

Expand Down
4 changes: 2 additions & 2 deletions samples/model-builder/model_registry/delete_model_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ def delete_model_sample(model_id: str, project: str, location: str):
Args:
model_id: The ID of the model to delete. Parent resource name of the model is also accepted.
project: The project.
location: The location.
location: The region name.
Returns
None.
"""
# Initialize the client.
aiplatform.init(project=project, location=location)

# Get the model with the ID 'model_id'. The parent_name of delete method can be also
# Get the model with the ID 'model_id'. The parent_name of Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model = aiplatform.Model(model_name=model_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def delete_model_version_sample(
Args:
model_id: The ID of the model to delete. Parent resource name of the model is also accepted.
version_id: The version ID or version alias of the model to delete.
project: The project.
location: The location.
project: The project ID.
location: The region name.
Returns
None.
"""
# Initialize the client.
aiplatform.init(project=project, location=location)

# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of create method can be also
# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model_registry = aiplatform.models.ModelRegistry(model=model_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ def get_model_version_info_sample(
Args:
model_id: The ID of the model.
version_id: The version ID of the model version.
project: The project name.
location: The location name.
project: The project ID.
location: The region name.
Returns:
VersionInfo resource.
"""

# Initialize the client.
aiplatform.init(project=project, location=location)

# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of create method can be also
# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model_registry = aiplatform.models.ModelRegistry(model=model_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ def get_registered_model_version_sample(
Get a registered model version.
Args:
model_id: The ID of the model. Parent resource name of the model is also accepted.
project: The project.
location: The location.
project: The project ID.
location: The region name.
version_id: The version ID of the model.
Returns:
Model resource.
"""
# Initialize the client.
aiplatform.init(project=project, location=location)

# Initialize the Model Registry resource with the ID 'model_id'. The parent_name of get method can be also
# Initialize the Model Registry resource with the ID 'model_id'. The parent_name of Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model_registry = aiplatform.models.ModelRegistry(model=model_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def list_model_versions_sample(model_id: str, project: str, location: str):
List all model versions of a model.
Args:
model_id: The ID of the model to list. Parent resource name of the model is also accepted.
project: The project.
location: The location.
project: The project ID.
location: The region name.
Returns:
versions: List of model versions.
"""
# Initialize the client.
aiplatform.init(project=project, location=location)

# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of create method can be also
# Initialize the Model Registry resource with the ID 'model_id'.The parent_name of Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model_registry = aiplatform.models.ModelRegistry(model=model_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ def upload_new_aliased_model_version_sample(
is_default_version: Whether this version is the default version of the model.
version_aliases: The aliases of the model version.
version_description: The description of the model version.
project: The project.
location: The location.
project: The project ID.
location: The region name.
Returns:
The new version of the model.
"""
# Initialize the client.
aiplatform.init(project=project, location=location)

# Upload a new aliased version of the Model resource with the ID 'model_id'. The parent_name of upload method can
# be also 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
# Upload a new aliased version of the Model resource with the ID 'model_id'. The parent_name of Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model = aiplatform.Model.upload(
artifact_uri=artifact_uri,
serving_container_image=serving_container_image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


import upload_new_aliased_model_version_sample

import test_constants as constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ def upload_new_default_model_version_sample(
parent_name: The parent resource name of the existing model.
artifact_uri: The URI of the model artifact to upload.
serving_container_image: The name of the serving container image to use.
project: The project.
location: The location.
project: The project ID.
location: The region name.
Returns:
The new version of the model.
"""
# Initialize the client.
aiplatform.init(project=project, location=location)

# Upload a new default version of the Model resource with the ID 'model_id'.
# The parent_name of upload method can be also
# Upload a new default version of the Model resource with the ID 'model_id'. The parent_name of Model resource can be also
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
model = aiplatform.Model.upload(
artifact_uri=artifact_uri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


import upload_new_default_model_version_sample

import test_constants as constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def upload_new_model_version_using_custom_training_pipeline(
model_version_aliases: The aliases of the model version to create.
model_version_description: The description of the model version.
is_default_version: Whether the model version is the default version.
project: The project.
location: The location.
project: The project ID.
location: The region name.
Returns:
The new version of the model.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.


import upload_new_model_version_using_custom_training_pipeline_sample

import test_constants as constants


def test_upload_new_model_version_using_custom_training_pipeline_sample(
mock_sdk_init,
mock_tabular_dataset,
mock_get_tabular_dataset,
mock_get_custom_training_job,
mock_run_custom_training_job,
mock_upload_model,
mock_sdk_init,
mock_tabular_dataset,
mock_get_tabular_dataset,
mock_get_custom_training_job,
mock_run_custom_training_job,
mock_upload_model,
):

upload_new_model_version_using_custom_training_pipeline_sample.upload_new_model_version_using_custom_training_pipeline(
display_name=constants.DISPLAY_NAME,
script_path=constants.SCRIPT_PATH,
Expand Down

0 comments on commit f97e90f

Please sign in to comment.