-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[components][rfc] @component_loader
decorator
#27182
[components][rfc] @component_loader
decorator
#27182
Conversation
80276e1
to
7d764bb
Compare
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.
We could go all the way and do this?
@component_decl
def load(context: ComponentLoadContext) -> PipesSubprocessScriptCollectionParams:
return PipesSubprocessScriptCollectionParams(
scripts=[
PipesSubprocessScriptParams(
path="cool_script.py",
assets=[
AssetAttributesModel(
key="cool_script",
automation_condition="{{ automation_condition.eager() }}",
),
],
),
]
)
3c6e30f
to
8e92e27
Compare
7d764bb
to
3326d2f
Compare
8e92e27
to
82497f2
Compare
3326d2f
to
a602eb7
Compare
82497f2
to
5ee4d47
Compare
a602eb7
to
202ebb1
Compare
5ee4d47
to
fcca097
Compare
202ebb1
to
9ea40e6
Compare
I think I prefer leaving the init method accessible to the user here. This gives the user more control over what actually happens, and means that if we do come up with a good theory about how to craft a nice set of init args for a given component then users are able to access that with the same interface |
9ea40e6
to
f3750af
Compare
fcca097
to
bc45aea
Compare
f3750af
to
6e8f617
Compare
6e8f617
to
abab2a4
Compare
abab2a4
to
4483a34
Compare
Summary & Motivation
Adds an
@component_loader
decorator and the corresponding infrastructure to allow users to write arbitrary python code to load their Components.Note that the convention I've gone with here has the user manually call
XComponent.load()
, rather than going through the__init__
. My thought here was basically just that this feels like better practice as it provides a common shared format between the python and yaml interfaces.In short, the way to use this is to have a
component.py
file instead of acomponent.yaml
file, which will look something like:And again, there's nothing stopping you from using the regular constructor, I just think that might be harder to use.
How I Tested These Changes
Changelog
NOCHANGELOG