Skip to content

Conversation

@ClementWalter
Copy link
Contributor

@ClementWalter ClementWalter commented Nov 21, 2020

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™

Fix #4373
Doc PR: treeverse/dvc.org#1980

@efiop
Copy link
Contributor

efiop commented Nov 21, 2020

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 . πŸ™‚

@efiop
Copy link
Contributor

efiop commented Nov 22, 2020

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 πŸ™‚

@ClementWalter
Copy link
Contributor Author

ClementWalter commented Nov 25, 2020

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

@ClementWalter ClementWalter force-pushed the support_list_of_commands_in_yaml branch from ace930f to 6f3b432 Compare November 25, 2020 17:54
@ClementWalter
Copy link
Contributor Author

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

Copy link
Contributor

@efiop efiop left a 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.

Copy link
Contributor

@efiop efiop left a 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).

Copy link
Collaborator

@skshetry skshetry left a 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
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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 world

But 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
world

Copy link
Contributor Author

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 ;)

@ClementWalter
Copy link
Contributor Author

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).

Just added two tests @efiop tell me what do you think about them

dvc/stage/run.py Outdated
Comment on lines +92 to +93
Copy link
Contributor

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?

Copy link
Contributor

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

@efiop efiop force-pushed the support_list_of_commands_in_yaml branch from d947329 to a62f7cc Compare December 3, 2020 10:25
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(
Copy link
Contributor Author

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.

Copy link
Contributor Author

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 ?

Copy link
Contributor

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.

Comment on lines +526 to +527
- echo foo>foo
- echo bar>bar
Copy link
Contributor Author

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

@efiop efiop merged commit 94f2a1d into treeverse:master Dec 3, 2020
@efiop
Copy link
Contributor

efiop commented Dec 3, 2020

Thank you @ClementWalter ! πŸš€

@ClementWalter
Copy link
Contributor Author

thanks you too! how is it that not all tests passes?

@efiop
Copy link
Contributor

efiop commented Dec 3, 2020

@ClementWalter Temporary issues with windows tests related to gitpython, please don't mind it, your tests have passed. πŸ‘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiline command?

6 participants