fix: Execution.create() 503 from credentials annotation typo and missing metadata store init#6611
Open
javabrett wants to merge 1 commit intogoogleapis:mainfrom
Open
Conversation
…ing metadata store init Fixes googleapis#6610. Two bugs in `metadata/execution.py` caused `Execution.create()` to fail with "503 Getting metadata from plugin failed with error: before_request": 1. The `credentials` parameter on both `create()` and `_create()` used `=` instead of `:` for the type annotation: `credentials=Optional[auth_credentials.Credentials]` instead of `credentials: Optional[auth_credentials.Credentials] = None`. This made the default value the `typing.Optional` type object itself (not `None`), which the gRPC auth stack tried to call `.before_request()` on. 2. `create()` skipped the `ensure_default_metadata_store_exists()` call that `Artifact.create()` makes, so standalone `Execution.create()` would also fail if no prior operation had initialized the metadata store. Both issues have been present since PR googleapis#1410 (June 2022). `artifact.py` and `context.py` both have the correct annotation.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #6610.
Two bugs in
metadata/execution.pycausedExecution.create()to fail with503 Getting metadata from plugin failed with error: before_request:Credentials annotation typo (
create()line 103,_create()line 181): Usedcredentials=Optional[auth_credentials.Credentials](assignment,=) instead ofcredentials: Optional[auth_credentials.Credentials] = None(annotation with default,:). The=form makes the default value thetyping.Optionaltype object itself (a_UnionGenericAlias), notNone. This non-None object is passed to the gRPC auth stack, which calls.before_request()on it, producing the 503. Present since PR feat: Vertex AI Experiments GA #1410 (June 2022).artifact.pyandcontext.pyboth have the correct: ... = Nonesyntax.Missing
ensure_default_metadata_store_exists()call:Artifact.create()callsmetadata_store._MetadataStore.ensure_default_metadata_store_exists()before delegating to_create(), butExecution.create()skipped this. StandaloneExecution.create()(without a priorArtifact.create()oraiplatform.init(experiment=...)warming the store) would fail.Changes
google/cloud/aiplatform/metadata/execution.py: Fixcredentialsannotation on bothcreate()and_create(). Addensure_default_metadata_store_exists()call increate()matchingArtifact.create().tests/unit/aiplatform/test_metadata_resources.py: 3 regression tests:test_create_credentials_default_is_none-- verifies bothcreate()and_create()default toNonetest_create_calls_ensure_default_metadata_store_exists-- verifies the store init is called for default storetest_create_skips_ensure_for_non_default_metadata_store-- verifies it's skipped for non-default storesTest plan
TestExecutiontests pass (zero regressions)