-
Notifications
You must be signed in to change notification settings - Fork 299
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
Cookie cutter initial template #738
Conversation
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Unit test is failing. Fix in #739. |
# as described in https://cookiecutter.readthedocs.io/en/1.7.2/advanced/directories.html. | ||
# The idea is to extend the number of templates, each in their own subdirectory, for example | ||
# a tensorflow-based example. | ||
directory="simple-example", |
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.
This is what I mean. This is hard coded. Or are you thinking of parameterizing this? I was suggesting that you could create
pyflyte init tensorflow
pyflyte init xyz
Or otherwise we should call it
pyflyte init <project-name> --template=tensorflow
and then --template can be defaulted to simple-example
?
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.
I was thinking of parametrizing this going forward, but I really liked the suggestion of making project-name
part of the invocation. I'll go ahead and implement both suggestions.
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.
I also updated the PR description.
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
This reverts commit bf7f22d.
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #738 +/- ##
==========================================
- Coverage 85.61% 85.60% -0.01%
==========================================
Files 341 342 +1
Lines 28915 28926 +11
Branches 2381 2381
==========================================
+ Hits 24755 24763 +8
- Misses 3527 3530 +3
Partials 633 633
Continue to review full report at Codecov.
|
) | ||
app = read_user_variable("app", "myapp") | ||
click.echo("What should be the name of your example workflow?") | ||
workflow_name = read_user_variable("workflow", "workflow_example") |
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.
Should we just use click for consistency http://pallets-click.readthedocs.io/en/stable/prompts.html
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.
using cookiecutter just for the templating feels less cluttered. Thanks for the suggestion!
Signed-off-by: Eduardo Apolinario <[email protected]>
d606b40
to
3f91dca
Compare
…late Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Only the code coverage tasks are failing. |
|
||
|
||
@click.command("init") | ||
@click.option("--template", default="simple-example", help="cookiecutter template to be used") |
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.
@click.option("--template", default="simple-example", help="cookiecutter template to be used") | |
@click.option("--template", default="simple-example", help="cookiecutter template folder name to be used in the repo - https://github.com/flyteorg/flytekit-python-template.git") |
Also eventually I think the repo itself should be parameterizable
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.
this idea of exposing the repo is interesting. So your expectation is that people will have their own private (or public forks) of the repo? In any case, if the need arises we can definitely go that way, but not in this PR, ok?
Small comment then +1 |
Signed-off-by: Eduardo Apolinario <[email protected]>
…late Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
Signed-off-by: Eduardo Apolinario <[email protected]>
* Add cookiecutter to requirements and pyflyte init Signed-off-by: Eduardo Apolinario <[email protected]> * Invoke cookiecutter with the overridden configuration. Signed-off-by: Eduardo Apolinario <[email protected]> * Comment the use of directory in the call to cookiecutter. Signed-off-by: Eduardo Apolinario <[email protected]> * Use the original repo and do not clobber existing files+directories Signed-off-by: Eduardo Apolinario <[email protected]> * Add example sub-command Signed-off-by: Eduardo Apolinario <[email protected]> * make requirements Signed-off-by: Eduardo Apolinario <[email protected]> * Fix test_dataclass_transformer test Signed-off-by: Eduardo Apolinario <[email protected]> * Constrain mashmallow-jsonschema temporarily Signed-off-by: Eduardo Apolinario <[email protected]> * Add --template flag and project-name argument to command Signed-off-by: Eduardo Apolinario <[email protected]> * Revert changes to dataclass transformer tests Signed-off-by: Eduardo Apolinario <[email protected]> * Constrain marshmallow-jsonschema in dev-requirements Signed-off-by: Eduardo Apolinario <[email protected]> * Revert "Constrain marshmallow-jsonschema in dev-requirements" This reverts commit bf7f22d. * Fix typo in Makefile Signed-off-by: Eduardo Apolinario <[email protected]> * Fix regeneration of spark2 requirements file Signed-off-by: Eduardo Apolinario <[email protected]> * Use click for prompts Signed-off-by: Eduardo Apolinario <[email protected]> * Changes default workflow name to `my_wf` Signed-off-by: Eduardo Apolinario <[email protected]> * Remove the two inputs from simple-example Signed-off-by: Eduardo Apolinario <[email protected]> * Add more descriptive help for the template flag Signed-off-by: Eduardo Apolinario <[email protected]> * Set cookiecutter in setup.py Signed-off-by: Eduardo Apolinario <[email protected]> * Default top level directory to flyte (as opposed to myapp) Signed-off-by: Eduardo Apolinario <[email protected]> Co-authored-by: Eduardo Apolinario <[email protected]> Signed-off-by: Robert Everson <[email protected]>
TL;DR
Add a command to generate the boilerplate for flyte-ready repos.
Type
Are all requirements met?
Complete description
This PR defines a new
pyflyte
command calledinit
that takes a template and a project name as arguments. These are used to call the template engine provided by cookiecutter.In terms of where templates are stored, we defined a cookiecutter template in flyteorg/flytekit-python-template#16. Note how we have the ability to keep multiple templates in the same repo, the idea being that we're going to expose them using different templates under the
pyflyte init
command.The
pyflyte init
command defaults to "simple-example" cookiecutter template and this template prompts the user for 2 additional inputs:project-name
that will store the actual workflowAll inputs have default values.
Also worth noting that the command does not clobber existing user code, i.e. the command fails if the user attempts to overwrite a directory by re-running the command.
Here's how the help provided by
click
looks like:Tracking Issue
flyteorg/flyte#1799
Follow-up issue
NA