Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added deploy_model_with_dedicated_resources_sample, deploy_model_with_automatic_resources_sample, upload_model and get_model samples #337

Merged
merged 16 commits into from Apr 30, 2021

Conversation

ivanmkc
Copy link
Contributor

@ivanmkc ivanmkc commented Apr 17, 2021

Added deploy_model_with_dedicated_resources_sample, deploy_model_with_automatic_resources_sample, upload_model and get_model samples and tests.

@ivanmkc ivanmkc requested review from dizcology and a team as code owners April 17, 2021 03:40
@ivanmkc ivanmkc requested review from engelke and removed request for a team April 17, 2021 03:40
@snippet-bot
Copy link

snippet-bot bot commented Apr 17, 2021

Here is the summary of changes.

You are about to add 4 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label bot added api: aiplatform Issues related to the AI Platform API. samples Issues that are directly related to samples. labels Apr 17, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Apr 17, 2021
@ivanmkc ivanmkc changed the base branch from master to dev April 17, 2021 03:56
@ivanmkc ivanmkc force-pushed the imkc--mbsdk-samples-milestone1 branch from 32ef90b to 7a646b4 Compare April 17, 2021 04:00
@@ -16,6 +16,7 @@
from uuid import uuid4

from google.auth import credentials
from google.cloud import aiplatform
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed to import this for aiplatform.explain.ExplanationMetadata

@ivanmkc ivanmkc changed the title [WIP] Added deploy_model and upload_model samples and tests Added deploy_model and upload_model samples and tests Apr 19, 2021
@ivanmkc ivanmkc changed the title Added deploy_model and upload_model samples and tests feat: Added deploy_model and upload_model samples and tests Apr 19, 2021
yield mock

@pytest.fixture
def mock_batch_predict_model(mock_model):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated these fixtures to use the new mock_model

@ivanmkc ivanmkc changed the title feat: Added deploy_model and upload_model samples and tests feat: Added deploy_model, upload_model, get_model samples and tests Apr 19, 2021
@ivanmkc ivanmkc changed the title feat: Added deploy_model, upload_model, get_model samples and tests feat: Added deploy_model, upload_model, get_model samples and deploy_model_custom_trained_model_sample. Apr 19, 2021
@ivanmkc ivanmkc changed the title feat: Added deploy_model, upload_model, get_model samples and deploy_model_custom_trained_model_sample. feat: Added deploy_model, upload_model, get_model samples and deploy_model_custom_trained_model_sample Apr 19, 2021
@ivanmkc ivanmkc force-pushed the imkc--mbsdk-samples-milestone1 branch 2 times, most recently from e4be6f4 to 704ca9f Compare April 21, 2021 00:55
deployed_model_display_name: Optional[str] = None,
traffic_percentage: Optional[int] = 0,
traffic_split: Optional[Dict[str, int]] = None,
min_replica_count: Optional[int] = 1,
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the Optional type hint (just leave int) on min_replica_count and max_replica_count. After reviewing this, I realized Endpoint.deploy and Model.deploy have inconsistent types on those arguments. I opened a PR to fix the function type hints in the SDK here: #345

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

deployed_model_display_name: Optional[str] = None,
traffic_percentage: Optional[int] = 0,
traffic_split: Optional[Dict[str, int]] = None,
min_replica_count: Optional[int] = 1,
Copy link
Member

Choose a reason for hiding this comment

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

Same comment on min_replica_count and max_replica_count

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

from google.cloud.aiplatform import explain

# [START aiplatform_sdk_deploy_model_sample]
def deploy_model_sample(
Copy link
Member

Choose a reason for hiding this comment

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

I'm assuming this is for models with automatic resources as machine type is not exposed. If that's the case, I think the following arguments can be removed but please confirm:

accelerator_type
accelerator_count
explanation_metadata
explanation_parameters

Copy link
Contributor Author

@ivanmkc ivanmkc Apr 21, 2021

Choose a reason for hiding this comment

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

Yes it's for automatic resources.

I checked the internal deploy function and it looks like accelerator_type and accelerator_count are only used if machine-type is provided. However, even if it intuitively makes sense, I would argue that the docstrings should make their co-dependence clear.

I would also recommend a refactor to bundle machine_type, accelerator_type and accelerator_count together, since they can't be used independently. If you want to keep the user-facing API flat, that's fine but in private functions it will be cleaner bundled. This would also reduce duplication of logic (search for if machine_type:). Let me know if you agree, and I can do this in a new PR.

From looking at _deploy_call, I don't see explanation_metadata and explanation_parameters relying on machine_type being set. Is there some restriction from the service the requires `machine_type?

Copy link
Member

Choose a reason for hiding this comment

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

Agree on the refactor and updating the docstring. Only custom models take explanation_metadata and explanation_parameters as AutoMLs support it natively (if supported) and machine_type is required from custom models.

Copy link
Member

Choose a reason for hiding this comment

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

@vinnysenthil to confirm

Copy link
Contributor Author

@ivanmkc ivanmkc Apr 22, 2021

Choose a reason for hiding this comment

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


model = aiplatform.Model(model_name=model_name)

# AutoML models require a machine_type of None
Copy link
Member

Choose a reason for hiding this comment

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

@vinnysenthil do all AutoML Models require automatic resources?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, we talked about this and it's a little unclear what the truth of this is.

We're still trying to find out the answer from the predict team.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sasha-gitg I talked to prediction team and unfortunately, they do not have the answer. I will remove the comment for now and update this if I find out more.

@ivanmkc ivanmkc changed the title feat: Added deploy_model, upload_model, get_model samples and deploy_model_custom_trained_model_sample feat: Added deploy_model_with_dedicated_resources_sample, deploy_model_with_automatic_resources_sample, upload_model and get_model samples Apr 27, 2021
@ivanmkc ivanmkc added kokoro:force-run Add this label to force Kokoro to re-run the tests. and removed kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 27, 2021
@ivanmkc ivanmkc added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 29, 2021
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 29, 2021
@vinnysenthil vinnysenthil changed the base branch from dev to master April 30, 2021 17:09
@ivanmkc ivanmkc force-pushed the imkc--mbsdk-samples-milestone1 branch from 035197f to d8c3d8a Compare April 30, 2021 17:47
@ivanmkc ivanmkc requested a review from a team as a code owner April 30, 2021 17:47
@ivanmkc ivanmkc force-pushed the imkc--mbsdk-samples-milestone1 branch from d8c3d8a to 8d474d6 Compare April 30, 2021 18:31
@ivanmkc ivanmkc force-pushed the imkc--mbsdk-samples-milestone1 branch from 8d474d6 to 4131edf Compare April 30, 2021 18:39
@ivanmkc ivanmkc merged commit ef4f6f8 into googleapis:master Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: aiplatform Issues related to the AI Platform API. cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants