-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Allow user to pass a list of commands for one single stage #4934
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
Allow user to pass a list of commands for one single stage #4934
Conversation
|
Hi @ClementWalter ! Thanks for the PR! π Note that your commit is not recognised by github as coming from your github profile. You need to add the email used in the commit to https://github.com/settings/emails . π |
|
Also, please don't forget to add the issue number or even "fixes #issuenumber" to the PR desc(or commit), so github tracks it automatically. #4373 π |
|
thanks for the feedback. Actually I was guessing it was hacky but, so easy to write down that I gave it a try. I'll work on this tonight |
ace930f to
6f3b432
Compare
|
This might be better but I am not sure about the loop and eventually I am not sure where to add tests for this change |
efiop
left a comment
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.
Looks great! Just a few more comments.
efiop
left a comment
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.
Looks good! We are lacking a simple func or unit test to make sure that we are actually able to run list of commands though. Could you add one, please? Ir could be a unit test for run_cmd or it could be a simple func test (adding a simple repo.repro test to tests/func/test_repro_multistage.py would be enough).
skshetry
left a comment
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.
Looks good overall. I have 2 questions regarding UI and multiline support.
dvc/stage/run.py
Outdated
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.
The issue you linked to is also about multiline string.
Right now, it's not officially supported, but works depending on the shell.
What do you think of it? Should we support it?
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 am not sure about your question: the issue mentions:
- piping: this shout stay as is as stated by @efiop
&&: the purpose of this pr: officially allowing the user to define sequential commands in a single stage from its yaml definition.
I don't see much space to think about something else
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.
@ClementWalter, as you are proposing to close the issue related to multiline/multiple commands, I just wanted to know what your opinion is on that, and if we should support it, as this list and the multiline string seems to be allowing the user the same thing.
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 think I don't understand what you are trying to ask me
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.
ok you mean @skshetry if all this work is worth doing because eventually it is only syntactic sugar for yaml?
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.
ok I think I got it, just re-reading from the beginning. You mean: should we also support the parallel case, ie multi line string where every line should a command that runs in parallel?
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.
@ClementwWalter I believe @skshetry was wondering about your opinion on whether or not we should treat multiline string as a list of commands when running it. #4373 (comment) I've mentioned that it should probably stay as it is, but there is an idea that maybe we should handle that better, similar as gha yaml does it. Let's keep that issue opened for that last question.
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.
@efiop yes! actually re-reading this morning and re-reading yaml parsing rules it became 100% clear to me what was @skshetry's point, sorry about that yesterday. My guess is that we should not try to parse user input. Maybe we could add a flag in the stage definition about the desired behavior with a list of command: stop on fail or keep going?
dvc/stage/run.py
Outdated
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.
Let's not add running on each command of the list as there's already a line for the whole stage.
Let's either print them all as a list before running or one-by-one:
Running stage "build":
- echo hello
- echo worldBut I can see that the output gets messy if the script output gets mixed.
We could think of removing indent and add a ">" before the script:
Running stage "build":
> echo hello
hello
> echo world
worldThere 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 like the suggestion with >, accepted ;)
Just added two tests @efiop tell me what do you think about them |
dvc/stage/run.py
Outdated
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.
@pmrowla Could you please confirm that this will work as expected with checkpoints?
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 should work as expected
d947329 to
a62f7cc
Compare
| dump_yaml(PIPELINE_FILE, dvcfile_content) | ||
| dvc.reproduce(target="multi_commands") | ||
| assert (tmp_dir / "foo").read_text() == "First command\nSecond command\n" | ||
| (tmp_dir / "dvc.yaml").write_text( |
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.
cool, I was not sure if it was better to write yaml directly or to use the dump_yaml func indeed.
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 the PIPELINE_FILE variable be used instead of direct dvc.yaml ?
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.
Doesn't really matter in the test.
| - echo foo>foo | ||
| - echo bar>bar |
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.
much better because actually my version crashed on windows, thanks
|
Thank you @ClementWalter ! π |
|
thanks you too! how is it that not all tests passes? |
|
@ClementWalter Temporary issues with windows tests related to gitpython, please don't mind it, your tests have passed. π |
β I have followed the Contributing to DVC checklist.
π If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.
Thank you for the contribution - we'll try to review it as soon as possible. π
Fix #4373
Doc PR: treeverse/dvc.org#1980