Skip to content

Commit f97e90f

Browse files
docs(samples): improve docstring of Vertex AI Python SDK Model Registry samples (#1705)
* improve doc string * nox tests passed * rename location Co-authored-by: Andrew Ferlitsch <[email protected]>
1 parent fc5791b commit f97e90f

16 files changed

+43
-48
lines changed

samples/model-builder/model_registry/assign_aliases_model_version_sample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def assign_aliases_model_version_sample(
3232
model_id: The ID of the model.
3333
version_aliases: The version aliases to assign.
3434
version_id: The version ID of the model to assign the aliases to.
35-
project: The project name.
36-
location: The location name.
35+
project: The project ID.
36+
location: The region name.
3737
Returns
3838
None.
3939
"""
4040
# Initialize the client.
4141
aiplatform.init(project=project, location=location)
4242

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

samples/model-builder/model_registry/create_aliased_model_sample.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def create_aliased_model_sample(
2525
Args:
2626
model_id: The ID of the model to initialize. Parent resource name of the model is also accepted.
2727
version_id: The version ID or version alias of the model to initialize.
28-
project: The project.
29-
location: The location.
28+
project: The project ID.
29+
location: The region name.
3030
Returns:
3131
Model resource.
3232
"""

samples/model-builder/model_registry/create_default_model_sample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ def create_default_model_sample(model_id: str, project: str, location: str):
2222
Initialize a Model resource to represent an existing model version with alias 'default'.
2323
Args:
2424
model_id: The ID of the model to initialize. Parent resource name of the model is also accepted.
25-
project: The project.
26-
location: The location.
25+
project: The project ID.
26+
location: The region name.
2727
Returns:
2828
Model resource.
2929
"""
3030
# Initialize the client.
3131
aiplatform.init(project=project, location=location)
3232

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

samples/model-builder/model_registry/create_model_registry_sample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ def create_model_registry_sample(model_id: str, project: str, location: str):
2222
Create a ModelRegistry resource associated to model_id
2323
Args:
2424
model_id: The ID of the model.
25-
project: The project name.
26-
location: The location name.
25+
project: The project ID.
26+
location: The region name.
2727
Returns:
2828
ModelRegistry resource.
2929
"""
3030

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

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

samples/model-builder/model_registry/delete_aliases_model_version_sample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def delete_aliases_model_version_sample(
3232
model_id: The ID of the model.
3333
version_aliases: The version aliases to assign.
3434
version_id: The version ID of the model to assign the aliases to.
35-
project: The project name.
36-
location: The location name.
35+
project: The project ID.
36+
location: The region name.
3737
Returns
3838
None.
3939
"""
4040
# Initialize the client.
4141
aiplatform.init(project=project, location=location)
4242

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

samples/model-builder/model_registry/delete_model_sample.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ def delete_model_sample(model_id: str, project: str, location: str):
2323
Args:
2424
model_id: The ID of the model to delete. Parent resource name of the model is also accepted.
2525
project: The project.
26-
location: The location.
26+
location: The region name.
2727
Returns
2828
None.
2929
"""
3030
# Initialize the client.
3131
aiplatform.init(project=project, location=location)
3232

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

samples/model-builder/model_registry/delete_model_version_sample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ def delete_model_version_sample(
2525
Args:
2626
model_id: The ID of the model to delete. Parent resource name of the model is also accepted.
2727
version_id: The version ID or version alias of the model to delete.
28-
project: The project.
29-
location: The location.
28+
project: The project ID.
29+
location: The region name.
3030
Returns
3131
None.
3232
"""
3333
# Initialize the client.
3434
aiplatform.init(project=project, location=location)
3535

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

samples/model-builder/model_registry/get_model_version_info_sample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ def get_model_version_info_sample(
2525
Args:
2626
model_id: The ID of the model.
2727
version_id: The version ID of the model version.
28-
project: The project name.
29-
location: The location name.
28+
project: The project ID.
29+
location: The region name.
3030
Returns:
3131
VersionInfo resource.
3232
"""
3333

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

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

samples/model-builder/model_registry/get_registered_model_version_sample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ def get_registered_model_version_sample(
2626
Get a registered model version.
2727
Args:
2828
model_id: The ID of the model. Parent resource name of the model is also accepted.
29-
project: The project.
30-
location: The location.
29+
project: The project ID.
30+
location: The region name.
3131
version_id: The version ID of the model.
3232
Returns:
3333
Model resource.
3434
"""
3535
# Initialize the client.
3636
aiplatform.init(project=project, location=location)
3737

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

samples/model-builder/model_registry/list_model_versions_with_model_registry_sample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ def list_model_versions_sample(model_id: str, project: str, location: str):
2222
List all model versions of a model.
2323
Args:
2424
model_id: The ID of the model to list. Parent resource name of the model is also accepted.
25-
project: The project.
26-
location: The location.
25+
project: The project ID.
26+
location: The region name.
2727
Returns:
2828
versions: List of model versions.
2929
"""
3030
# Initialize the client.
3131
aiplatform.init(project=project, location=location)
3232

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

samples/model-builder/model_registry/upload_new_aliased_model_version_sample.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ def upload_new_aliased_model_version_sample(
3838
is_default_version: Whether this version is the default version of the model.
3939
version_aliases: The aliases of the model version.
4040
version_description: The description of the model version.
41-
project: The project.
42-
location: The location.
41+
project: The project ID.
42+
location: The region name.
4343
Returns:
4444
The new version of the model.
4545
"""
4646
# Initialize the client.
4747
aiplatform.init(project=project, location=location)
4848

49-
# Upload a new aliased version of the Model resource with the ID 'model_id'. The parent_name of upload method can
50-
# be also 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
49+
# Upload a new aliased version of the Model resource with the ID 'model_id'. The parent_name of Model resource can be also
50+
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
5151
model = aiplatform.Model.upload(
5252
artifact_uri=artifact_uri,
5353
serving_container_image=serving_container_image,

samples/model-builder/model_registry/upload_new_aliased_model_version_sample_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
1615
import upload_new_aliased_model_version_sample
1716

1817
import test_constants as constants

samples/model-builder/model_registry/upload_new_default_model_version_sample.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,16 @@ def upload_new_default_model_version_sample(
3030
parent_name: The parent resource name of the existing model.
3131
artifact_uri: The URI of the model artifact to upload.
3232
serving_container_image: The name of the serving container image to use.
33-
project: The project.
34-
location: The location.
33+
project: The project ID.
34+
location: The region name.
3535
3636
Returns:
3737
The new version of the model.
3838
"""
3939
# Initialize the client.
4040
aiplatform.init(project=project, location=location)
4141

42-
# Upload a new default version of the Model resource with the ID 'model_id'.
43-
# The parent_name of upload method can be also
42+
# Upload a new default version of the Model resource with the ID 'model_id'. The parent_name of Model resource can be also
4443
# 'projects/<your-project-id>/locations/<your-region>/models/<your-model-id>'
4544
model = aiplatform.Model.upload(
4645
artifact_uri=artifact_uri,

samples/model-builder/model_registry/upload_new_default_model_version_sample_test.py

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
1615
import upload_new_default_model_version_sample
1716

1817
import test_constants as constants

samples/model-builder/model_registry/upload_new_model_version_using_custom_training_pipeline_sample.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def upload_new_model_version_using_custom_training_pipeline(
5454
model_version_aliases: The aliases of the model version to create.
5555
model_version_description: The description of the model version.
5656
is_default_version: Whether the model version is the default version.
57-
project: The project.
58-
location: The location.
57+
project: The project ID.
58+
location: The region name.
5959
Returns:
6060
The new version of the model.
6161
"""

samples/model-builder/model_registry/upload_new_model_version_using_custom_training_pipeline_test.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
1615
import upload_new_model_version_using_custom_training_pipeline_sample
1716

1817
import test_constants as constants
1918

2019

2120
def test_upload_new_model_version_using_custom_training_pipeline_sample(
22-
mock_sdk_init,
23-
mock_tabular_dataset,
24-
mock_get_tabular_dataset,
25-
mock_get_custom_training_job,
26-
mock_run_custom_training_job,
27-
mock_upload_model,
21+
mock_sdk_init,
22+
mock_tabular_dataset,
23+
mock_get_tabular_dataset,
24+
mock_get_custom_training_job,
25+
mock_run_custom_training_job,
26+
mock_upload_model,
2827
):
29-
3028
upload_new_model_version_using_custom_training_pipeline_sample.upload_new_model_version_using_custom_training_pipeline(
3129
display_name=constants.DISPLAY_NAME,
3230
script_path=constants.SCRIPT_PATH,

0 commit comments

Comments
 (0)