Skip to content

Commit 25a071c

Browse files
Fix marshmallow 4.x Schema constructor compatibility issues
Co-authored-by: kshitij-microsoft <[email protected]>
1 parent b25a9f1 commit 25a071c

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/_schema/core/schema.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ def __init__(self, *args, **kwargs):
3232
# set old base path, note it's an Path object and point to the same object with
3333
# self.context.get(BASE_PATH_CONTEXT_KEY)
3434
self.old_base_path = self.context.get(BASE_PATH_CONTEXT_KEY)
35-
super().__init__(*args, **kwargs)
35+
36+
# In marshmallow 4.x, filter out unsupported constructor parameters
37+
# Valid parameters for Schema constructor: only, exclude, many, context, load_only, dump_only, partial
38+
valid_schema_params = {'only', 'exclude', 'many', 'context', 'load_only', 'dump_only', 'partial'}
39+
filtered_kwargs = {k: v for k, v in kwargs.items() if k in valid_schema_params}
40+
41+
super().__init__(*args, **filtered_kwargs)
3642

3743
@pre_load
3844
def add_param_overrides(self, data, **kwargs):

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_component/flow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,9 +495,9 @@ def _load_with_schema(
495495

496496
# unlike other component, we should ignore unknown fields in flow to keep init_params clean and avoid
497497
# too much understanding of flow.dag.yaml & run.yaml
498-
kwargs["unknown"] = EXCLUDE
498+
# In marshmallow 4.x, use unknown parameter during schema.load() call
499499
try:
500-
loaded_dict = schema.load(data, **kwargs)
500+
loaded_dict = schema.load(data, unknown=EXCLUDE, **kwargs)
501501
except ValidationError as e:
502502
if raise_original_exception:
503503
raise e

0 commit comments

Comments
 (0)