Skip to content
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

dvcyaml: write to cwd instead of git root #729

Merged
merged 3 commits into from
Oct 31, 2023
Merged

dvcyaml: write to cwd instead of git root #729

merged 3 commits into from
Oct 31, 2023

Conversation

dberenbaum
Copy link
Collaborator

Instead of defaulting to the git root for dvc.yaml, use the current path. This is technically a breaking change, but it simplifies the dvc.yaml logic and should have the same behavior for most users.

Rationale for this change:

  • Avoids unnecessary git logic that can cause unexpected behavior
  • More consistent with dvc commands (for example, dvc stage add writes dvc.yaml in the current directory, not the git root)
  • Simpler code

@@ -63,7 +63,7 @@ def __init__(
resume: bool = False,
report: Optional[str] = None,
save_dvc_exp: bool = True,
dvcyaml: Union[str, bool] = True,
dvcyaml: Union[str, bool] = "dvc.yaml",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now that there is a constant value, it seems more transparent to make the default value a string. Keeping a boolean option for now to not break existing behavior.

@dberenbaum dberenbaum marked this pull request as ready for review October 30, 2023 14:27
@codecov-commenter
Copy link

codecov-commenter commented Oct 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Files Coverage Δ
src/dvclive/live.py 95.45% <100.00%> (-0.06%) ⬇️
tests/test_dvc.py 100.00% <ø> (ø)
tests/test_log_artifact.py 100.00% <ø> (ø)
tests/test_make_dvcyaml.py 100.00% <100.00%> (ø)

📢 Thoughts on this report? Let us know!.

@shcheklein
Copy link
Member

does it meant that depending on where I run the command (e.g. yolo train ...) I might end up with a few dvc.yaml files? Also, how do we determine the path for the dvclive directory now? It is also usually in the root, how do we do that?

@dberenbaum
Copy link
Collaborator Author

dberenbaum commented Oct 30, 2023

does it meant that depending on where I run the command (e.g. yolo train ...) I might end up with a few dvc.yaml files?

Yes, it's possible if you run it from different places. I can think of cases where each behavior is "better." For example, if I have multiple pipelines, always writing to the root could be worse.

Also, how do we determine the path for the dvclive directory now? It is also usually in the root, how do we do that?

It is based on the current path, not the root (same as this PR).

Comment on lines -194 to -200
if self._dvc_repo is not None:
return os.path.join(self._dvc_repo.root_dir, "dvc.yaml")
logger.warning(
"Can't infer dvcyaml path without a DVC repo. "
"`dvc.yaml` file will not be written."
)
return ""
Copy link
Member

Choose a reason for hiding this comment

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

dvcyaml: write to cwd instead of git root

Looking at the diff, it seems it was dvc's root, not git root, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you are right

@skshetry
Copy link
Member

dvc stage add is a CLI command, which comes with the expectation that it respects your current working directory (and it's a one-off command). I don't understand changes here yet, but in the scripts, you might invoke it from any location, not just your cwd. Shouldn't dvclive be consistent/predictable in that regard? No strong opinion though.

@dberenbaum
Copy link
Collaborator Author

dvc stage add is a CLI command, which comes with the expectation that it respects your current working directory (and it's a one-off command). I don't understand changes here yet, but in the scripts, you might invoke it from any location, not just your cwd. Shouldn't dvclive be consistent/predictable in that regard? No strong opinion though.

Yes, sorry, the description is a bit sloppy. This does not guarantee it uses your cwd. As discussed above with @shcheklein, this PR matches the behavior for creating the dvclive directory, so it seems most consistent with existing dvclive behavior (the dvc.yaml and dvclive directory should be in the same place).

@dberenbaum dberenbaum merged commit 3403046 into main Oct 31, 2023
10 checks passed
@dberenbaum dberenbaum deleted the dvcyaml-cwd branch October 31, 2023 14:59
@BastiQ
Copy link

BastiQ commented Dec 18, 2023

My solution and online course are built on top of DVC and DVC Live. I really appreciate your work and understand that you have to continue developing the tool, but breaking changes like this result in a lot of overhead on my end. Maybe there is a way to reduce those in the future. Thanks a lot!

@dberenbaum
Copy link
Collaborator Author

Sorry for the incovenience @BastiQ. Obviously, this isn't best practice and we do our best to avoid breaking changes in minor releases. If this or other changes are causing specific issues for you, feel free to follow up with more details.

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.

5 participants