fix(sdk): load v1 component I/O names that YAML 1.1 resolves as booleans. Fixes #13756 - #13990
fix(sdk): load v1 component I/O names that YAML 1.1 resolves as booleans. Fixes #13756#13990Yigtwxx wants to merge 1 commit into
Conversation
Signed-off-by: Yigtwxx <yigiterdogan023@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @Yigtwxx. Thanks for your PR. I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Description of your changes:
load_component_from_textandload_component_from_filefailed on v1 component YAML whose input or output name is one of the YAML 1.1 boolean wordson,off,yesorno, in both flow style and block style:PyYAML implements YAML 1.1, so
yaml.safe_loadresolved those unquoted scalars to Python booleans beforev1_structures.ComponentSpec.from_dictran, producing a nestedTypeError:The same coercion also affects placeholders:
{inputValue: off}became{'inputValue': False}, which then fails inutils.sanitize_input_namewithAttributeError: 'bool' object has no attribute 'lower'. Repairing only thenamefields would therefore not be enough, andbool -> strcannot recover the original spelling (on,On,ON, ...).Changes, all scoped to
_load_component_spec_from_component_text, the single entry point for v1 component text:_V1ComponentYamlLoaderis ayaml.SafeLoadersubclass whose implicit resolvers keep the boolean tag only for scalars starting witht/T/f/F. This matches the YAML 1.2 core schema:true/falsestill resolve to booleans,null/~still resolve to null, andon/off/yes/nostay strings._normalize_v1_io_specsrestores the boolean meaning of theoptionalfield when it is written asyes/no/on/off, so component YAML that loads today keeps loading.optionalis the only strictly boolean-typed field inv1_structures.ValueErrornaming the offending input or output when a name is not a string, replacing the nestedTypeErrorfromInputSpec.from_dict.Boolean-typed defaults are unaffected:
default: yesnow reachestype_utils.deserialize_v1_component_yaml_defaultas the string'yes', andbool_cast_fn/strtoboolalready mapyes/no/on/offto booleans, so the resulting default is stillTrue. AString-typed input withdefault: yeschanges from'True'to'yes', which is the value the YAML actually spells.load_documents_from_yamland the v2 IR path are deliberately unchanged. Compiled IR YAML is emitted by PyYAML, whose emitter quotes scalars that would otherwise resolve to a non-string type, so IR round-trips correctly today.Fixes #13756
Checklist: