Skip to content

command: Should not consume 'print' to output default remote info - #6650

Merged
skshetry merged 1 commit into
treeverse:masterfrom
eggqq007:dev-fix-print-in-remote-command
Oct 6, 2021
Merged

command: Should not consume 'print' to output default remote info#6650
skshetry merged 1 commit into
treeverse:masterfrom
eggqq007:dev-fix-print-in-remote-command

Conversation

@eggqq007

@eggqq007 eggqq007 commented Sep 20, 2021

Copy link
Copy Markdown
Contributor
  1. should not consume 'print' to output default remote info,
    otherwise the --quiet would not work.

Thank you for the contribution - we'll try to review it as soon as possible. 🙏

1. should not consume 'print' to output default remote info,
   otherwise the --quiet would not work.
@eggqq007
eggqq007 requested a review from a team as a code owner September 20, 2021 03:17
@eggqq007
eggqq007 requested a review from skshetry September 20, 2021 03:17
Comment thread dvc/command/remote.py
conf = self.config.read(self.args.level)
try:
print(conf["core"]["remote"])
ui.write(conf["core"]["remote"])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eggqq007, could you please describe your use case? Do you want to check if the default is set or not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I want to check the whether the project has set default-remote or not. And I think it should not output any regular string once --quiet was add.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't treat --quiet as a no output mode. We still output the data that the user asked for, but silence all the other outputs that DVC usually throws (so that dvc metrics diff --show-md still works with --quiet, etc).

This is a bit of an edge-case here as you may want to either check what the default is or test if the default remote has been set.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply. emm, I think updating the dvc document in https://dvc.org/doc/command-reference/remote/add is a candidate. It says "-q, --quiet - do not write anything to standard output. Exit with 0 if no problems arise, otherwise 1."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current behavior seems consistent with the guideline in #5891. I think it even gives the behavior you are looking for @eggqq007, but it's inverted (there is output printed only if the default remote has been set). The command reference definitely needs an update, though, and probably for other commands also.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, okay. I was mostly sticking to the first point of the guideline:

If the command's (or, the option) that sole purpose is to display the information, let show it in any case.

I guess we need to clarify if this belongs to the second one or not:

If the information is very important to the user, print warnings and error messages to the stderr even in --quiet mode wherever appropriate.

I have mostly chosen to err on the side of caution, and support --quiet only if the command's/flag's sole purpose is to show that information, if --quiet has other uses too, I have kept that so far (as we have discussed, --quiet on the dvc metrics diff probably is an error on the user's side).

dvc status does the same thing when used with --quiet, in fact it's what we have been recommending for use in the scripts.

To resolve this, I guess we need to either suggest alternatives here, or clarify the guideline then.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not following. Isn't the sole purpose of dvc remote default (without any args/options) and dvc status to display information? What do you think dvc remote default --quiet should show according to the guideline?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the sole purpose of dvc remote default (without any args/options) and dvc status to display information?

Actually no, dvc status -q without output is used to indicate whether there are any changes, same as git status -q. dvc remote default can be used similarly in scripts - to tell user if it has default remote or not. So I think that making -q suppress it is justifiable beacuse dvc remote default has two purposes: with and without printing.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@efiop Do you mean git status -s (I don't think git status -q is an option)? Both git status -s and dvc status -q show output if there are changes and suppress output if there are no changes. dvc remote default -q shows output if there is a default remote and suppresses output if there is no default remote.

How is this different from what you are suggesting? I'm still not following what behavior changes you or @skshetry are suggesting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed this as a group. I was wrong about dvc status -q, which never prints anything. In that case, it seems fine to do the same here and merge this PR. I don't think it can cause much harm, and it aligns with the current documentation. Sorry for the oversight and all the noise here.

@jorgeorpinel

jorgeorpinel commented Oct 4, 2021

Copy link
Copy Markdown
Contributor

Will someone be able to contribute treeverse/dvc.org#2840 too? 🙂

Comment thread dvc/command/remote.py
conf = self.config.read(self.args.level)
try:
print(conf["core"]["remote"])
ui.write(conf["core"]["remote"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed this as a group. I was wrong about dvc status -q, which never prints anything. In that case, it seems fine to do the same here and merge this PR. I don't think it can cause much harm, and it aligns with the current documentation. Sorry for the oversight and all the noise here.

@skshetry
skshetry merged commit 1eb89a2 into treeverse:master Oct 6, 2021
@skshetry

skshetry commented Oct 6, 2021

Copy link
Copy Markdown
Collaborator

Thanks @eggqq007 🙂

@eggqq007
eggqq007 deleted the dev-fix-print-in-remote-command branch October 7, 2021 00:09
skshetry added a commit to endremborza/dvc that referenced this pull request Oct 8, 2021
* master: (47 commits)
  make dependabot updates work (treeverse#6760)
  move defaults to the class level (treeverse#6762)
  build(deps): Bump dvclive from 0.3.0 to 0.4.0 (treeverse#6753)
  move requirements to setup.cfg (treeverse#6758)
  gha: cancel previous workflows (treeverse#6756)
  pyinstaller: hooks: remove webhdfs
  webhdfs: migrate to fsspec (treeverse#6662)
  gha: benchmarks: fix pytest flags (treeverse#6749)
  hdfs: migrate to fsspec (treeverse#6604)
  Pin dvclive to 0.3.0
  command: Should not consume 'print' to output default remote info (treeverse#6650)
  command: output prettify json in tty (treeverse#6743)
  gha: run benchmarks on PRs (treeverse#6733)
  Run on Python3.10 (treeverse#6745)
  Fix dvclive running subdir (treeverse#6740)
  exp init: only ask for that are not provided in an interactive mode (treeverse#6739)
  move exp init logic to dvc.repo.experiments.init (treeverse#6738)
  build(deps): Bump jaraco-windows from 5.6.0 to 5.7.0 (treeverse#6735)
  build(deps): Bump pytest-cov from 2.12.1 to 3.0.0 (treeverse#6736)
  Bump typing_extensions to >=3.7.4 (treeverse#6731) (treeverse#6732)
  ...
@efiop efiop added the enhancement Enhances DVC label Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhances DVC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants