-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Improved recipe initialization UX #9158
Conversation
✅ Deploy Preview for prefect-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
@@ -230,6 +233,7 @@ def initialize_project(name: str = None, recipe: str = None) -> List[str]: | |||
elif recipe is None: | |||
recipe = "local" | |||
|
|||
formatting_kwargs.update(inputs or {}) |
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.
probably a dumb python q - why not set inputs: dict = {}
as a default arg?
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.
@parkedwards not a dumb question at all, it's a common python gotcha actually; because function definitions are run only once per-import, all default values are set and bound once and only once. This means that if a default is a mutable object, it can begin to leak state between calls of the function. Easy to inspect example:
def f(item, x: list = []):
x.append(item)
return x
f(1) # returns [1]
f(2) # returns [1, 2]
So to get around that, the best practice is to use None
as the default for mutable inputs, and initialize an empty version of the object once per-call (you'll often see things like inputs = inputs or {}
at the top of functions for this reason).
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.
iiiinteresting, good to know. thanks chris
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.
nice one
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.
Awesome! Again, minor nits.
Co-authored-by: Bill Palombi <bill@prefect.io>
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.
LGTM!
Co-authored-by: Bill Palombi <bill@prefect.io>
This PR introduces a new interactive experience for recipes - all recipes now ship with
required_inputs
that, if not provided, are prompted for whenever initializing that recipe. These interactive prompts can be avoided by passing the required fields with the new--field
flag onproject init
. Documentation has also been updated to reflect this.Example

produces:Checklist
<link to issue>
"fix
,feature
,enhancement
,docs
.