fix(types): Resolve 'tfx.' prefixed KFP v2/Vertex AI artifact types to native Python classes#7869
Open
vkarampudi wants to merge 1 commit into
Open
Conversation
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.
Description
This PR resolves a major type resolution bug (Issue #7849) where standard TFX artifacts produced under Kubeflow Pipelines (KFP) v2 or Google Cloud Vertex AI Pipelines fail to resolve to their native Python classes.
The Problem
Under KFP v2 / Vertex AI (which uses IR-based pipeline execution), TFX artifacts are registered in MLMD using their YAML schema title which is prefixed with
tfx.(e.g.tfx.Examples,tfx.Model).When a downstream Python step queries MLMD, TFX's
get_artifact_type_class()utility attempts to match the MLMD type name against native Python classes. Because native classes haveTYPE_NAMEattributes without the prefix (e.g.TYPE_NAME = "Examples"), the exact match check fails:Consequently, TFX prints a warning ("Could not find matching artifact class for type...") and generates an ephemeral generic
Artifactsubclass. This is highly brittle and breaks any downstream code performing class checks (e.g.isinstance(artifact, standard_artifacts.Examples)) or using subclass-specific properties/methods.The Solution
We normalize
artifact_type.nameby stripping thetfx.prefix before checking for a match with native TFX classes:Testing
artifact_utils_test.py(testArtifactTypeRoundTrip) that constructs a mock KFP-prefixedtfx.Examplesartifact type and asserts that it is correctly resolved tostandard_artifacts.Examples.artifact_utils_testtests pass successfully in thetfx-py310environment.