-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Use an enum for configurable_alternatives to make the generated json schema nicer #11350
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
| arbitrary_types_allowed = True | ||
|
|
||
| include = include or [] | ||
| include = [i for i in include if i != "configurable"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we make it possible to generate schema that does not include "configurable" schema?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is that useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opt in to expose configuration params twice seems overkill no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- either we do that or that key is treated differently from other top level keys of the RunnableConfig (which is ifne)
- Any situations where a server picks up an existing configurable runnable without knowing that it's configurable and not wanting to expose configurability by default?
| which_enum = enum.StrEnum( # type: ignore[misc] | ||
| self.which.name, list(self.alternatives.keys()) + ["default"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's fine, we only check these values in this component
| alt_keys = self.alternatives.keys() | ||
| which_keys = tuple(Literal[k] for k in alt_keys) + ( # type: ignore | ||
| Literal["default"], | ||
| which_enum = enum.StrEnum( # type: ignore[misc] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our of curiosity, what is the error this is suppressing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pylance/mypy doesn't like a non-constant value being passed in as the name of the enum, but from checking the code this doesnt raise an issue
| arbitrary_types_allowed = True | ||
|
|
||
| include = include or [] | ||
| include = [i for i in include if i != "configurable"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- either we do that or that key is treated differently from other top level keys of the RunnableConfig (which is ifne)
- Any situations where a server picks up an existing configurable runnable without knowing that it's configurable and not wanting to expose configurability by default?

No description provided.