Skip to content

Handle class instances in stub generator #2408

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

Merged
merged 6 commits into from
May 15, 2025
Merged

Conversation

npow
Copy link
Contributor

@npow npow commented May 14, 2025

Stub generator fails to handle something like the following where there's a class instance as a default argument:

def identity(data: MDF, parameters: FunctionParameters = FunctionParameters()) -> MDF:
    return data

Traceback:

STDERR:
Traceback (most recent call last):
File "/root/metaflow/metaflow_extensions/nflx/plugins/functions/function_parameters.py", line 65, in getattr
return self[name]
File "/root/metaflow/metaflow_extensions/nflx/plugins/functions/function_parameters.py", line 61, in getitem
return self._data[name]
File "/root/metaflow/metaflow_extensions/nflx/plugins/functions/function_parameters.py", line 24, in getitem
raise KeyError(f"Artifact '{key}' not found in FunctionParameters.")
KeyError: "Artifact 'name' not found in FunctionParameters."

@npow npow requested a review from romain-intel May 14, 2025 21:28
@talsperre
Copy link
Collaborator

How did you go about testing it?

@npow
Copy link
Contributor Author

npow commented May 15, 2025

How did you go about testing it?

python -m metaflow.cmd.main_cli develop stubs install --force

opened up the metaflow-stubs/mf_extensions/nflx/plugins/dataframe_function.pyi file and looked at it

Copy link
Contributor

@romain-intel romain-intel left a comment

Choose a reason for hiding this comment

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

LGTM

@talsperre talsperre self-requested a review May 15, 2025 16:35
@talsperre talsperre merged commit 153d0a7 into master May 15, 2025
29 checks passed
@talsperre talsperre deleted the npow/fix-stub-generator branch May 15, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants