Skip to content

Add initial helper util functions and tests#25

Merged
vinnysenthil merged 3 commits into
googleapis:devfrom
vinnysenthil:dev
Oct 7, 2020
Merged

Add initial helper util functions and tests#25
vinnysenthil merged 3 commits into
googleapis:devfrom
vinnysenthil:dev

Conversation

@vinnysenthil
Copy link
Copy Markdown
Contributor

Creates a utils.py module containing two helper functions:

  1. get_client_options — Returns a client_options dict based on location set by intializer or override and whether the client is for prediction .
from google.cloud import aiplatform as aip
from google.cloud.aiplatform.utils import get_client_options

aip.init(location="europe-west4")
get_client_options()  # { "api_endpoint": "europe-west4-aiplatform.googleapis.com" }
  1. validate_name — Validates an fully-qualified AI Platform resource name and returns the contained values as properties of a tuple subclass.
from google.cloud.aiplatform.utils import validate_name

dataset_name = "projects/acme-co/locations/us-central1/datasets/123456"
fields = validate_name(dataset_name)
fields.project  # "acme-co"
fields.location  # "us-central1"
fields.resource  # "datasets"
fields.id  # "123456"

Please take a look at the tests for more usage.

@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 7, 2020
Copy link
Copy Markdown
Member

@sasha-gitg sasha-gitg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Couple of high level comments:

  1. I don't think all services only accept integer strings as the resource ids. Capture this in a ticket and add a comment "TODO(b/...) ... "

  2. There may be nested resource names as well, not just one level. Capture that as a ticket and comment.

Thanks!

Comment thread google/cloud/aiplatform/utils.py Outdated
Comment thread google/cloud/aiplatform/utils.py Outdated
Comment thread google/cloud/aiplatform/utils.py Outdated
Comment thread google/cloud/aiplatform/utils.py Outdated
Comment thread google/cloud/aiplatform/utils.py Outdated
Comment thread google/cloud/aiplatform/utils.py
@vinnysenthil vinnysenthil merged commit bdd92ec into googleapis:dev Oct 7, 2020
dizcology pushed a commit to dizcology/python-aiplatform that referenced this pull request Nov 30, 2020
* Add initial helper util functions and tests

* Make requested changes, add TODOs to utils.py

* Fix indent and lint
dizcology pushed a commit to dizcology/python-aiplatform that referenced this pull request Nov 30, 2020
* Add initial helper util functions and tests

* Make requested changes, add TODOs to utils.py

* Fix indent and lint
dizcology pushed a commit to dizcology/python-aiplatform that referenced this pull request Nov 30, 2020
* Add initial helper util functions and tests

* Make requested changes, add TODOs to utils.py

* Fix indent and lint
dizcology pushed a commit to dizcology/python-aiplatform that referenced this pull request Nov 30, 2020
* Add initial helper util functions and tests

* Make requested changes, add TODOs to utils.py

* Fix indent and lint
dizcology pushed a commit to dizcology/python-aiplatform that referenced this pull request Nov 30, 2020
* Add initial helper util functions and tests

* Make requested changes, add TODOs to utils.py

* Fix indent and lint
dizcology pushed a commit to dizcology/python-aiplatform that referenced this pull request Dec 22, 2020
* Add initial helper util functions and tests

* Make requested changes, add TODOs to utils.py

* Fix indent and lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants