Skip to content
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

Add warning for removal of default in annotated Parameter args #1102

Merged
merged 3 commits into from
Jun 18, 2024

Conversation

elliotgunton
Copy link
Collaborator

Pull Request Checklist

Description of PR
To complete #812 it would be preferable to give a version's warning of the backwards incompatible change, although I'm happy to make the change in one go.

This PR also fixes a serialization problem when setting the default via a Python function arg.

@elliotgunton elliotgunton added semver:minor A change requiring a minor version bump type:informational Provides information or notice to the community labels Jun 17, 2024
@elliotgunton elliotgunton force-pushed the 812-annotated-defaults branch from 03ff013 to b57d32a Compare June 17, 2024 09:21
sambhav added a commit that referenced this pull request Jun 17, 2024
The `type:informational` label is not one of the set of "minimal
required labels", resulting in failing CI in #1102

Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
Co-authored-by: Sambhav Kothari <skothari44@bloomberg.net>
@elliotgunton elliotgunton force-pushed the 812-annotated-defaults branch from b57d32a to 1543036 Compare June 18, 2024 02:04
@elliotgunton
Copy link
Collaborator Author

@samj1912 / @flaviuvadan any preference on this change having a notice or just make the change directly? It's an experimental feature after all 👀

@sambhav
Copy link
Collaborator

sambhav commented Jun 18, 2024

I would prefer to give a bit more notice. Let's also provide a couple of minor versions of bandwidth. The way I would prefer to go about removing things is as follows -

  • Give warning
  • Raise exception which can be turned off by a flag
  • Removed feature

Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
We will follow a slower deprecation process to give more room to migrate:
* Deprecation message (likely in 5.16)
* Raise error unless override flag turned on (likely in 5.17)
* Raise error, remove ability to set Parameter's default, users must use Python (likely in 5.18)

Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
@elliotgunton elliotgunton force-pushed the 812-annotated-defaults branch from 5e4bb68 to 5908486 Compare June 18, 2024 06:36
if new_object.default is not None:
raise ValueError(
"default cannot be set via both the function parameter default and the Parameter's default"
)
new_object.default = str(func_param.default)
new_object.default = serialize(func_param.default)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This change is technically a bug fix

@sambhav sambhav merged commit 0d51104 into main Jun 18, 2024
20 checks passed
@sambhav sambhav deleted the 812-annotated-defaults branch June 18, 2024 13:33
elliotgunton added a commit that referenced this pull request Sep 18, 2024
**Pull Request Checklist**
- [x] Fixes #812
- [x] Tests added
- [x] Documentation/examples added
- [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR
title

**Description of PR**
Currently, using the `default` kwarg for a `Parameter` in an input
Annotation or Hera's Pydantic `Input` class logs a warning message,
added in #1102. This PR makes
the code path raise an error, which can be supressed using the
`suppress_parameter_default_error` experimental feature flag for 1 minor
version until it is removed.

---------

Signed-off-by: Elliot Gunton <elliotgunton@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:minor A change requiring a minor version bump type:informational Provides information or notice to the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants