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

cleanup dvcyaml #615

Merged
merged 1 commit into from
Jul 4, 2023
Merged

cleanup dvcyaml #615

merged 1 commit into from
Jul 4, 2023

Conversation

dberenbaum
Copy link
Collaborator

Fixes #611

@dberenbaum dberenbaum requested a review from daavoo July 3, 2023 20:48
@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01 🎉

Comparison is base (cae5129) 89.70% compared to head (ab189a1) 89.72%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #615      +/-   ##
==========================================
+ Coverage   89.70%   89.72%   +0.01%     
==========================================
  Files          43       43              
  Lines        2983     2987       +4     
  Branches      247      248       +1     
==========================================
+ Hits         2676     2680       +4     
  Misses        268      268              
  Partials       39       39              
Impacted Files Coverage Δ
src/dvclive/live.py 94.81% <100.00%> (+0.03%) ⬆️
tests/test_main.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -121,6 +121,9 @@ def _init_cleanup(self):
if f and os.path.exists(f):
os.remove(f)

if self.dvc_file and os.path.exists(self.dvc_file):
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember we had a discussion the first time we added the make_dvcyaml about not wanting to remove it on cleanup #366 (comment)

Do you think the concerns no longer apply (the config for sklearn is now auto-generated) and we can consider the dvclive/dvc.yaml not modifiable?

Copy link
Contributor

@daavoo daavoo Jul 4, 2023

Choose a reason for hiding this comment

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

Nevermind, it looks like we are already overwriting in the code, so we never preserved the existing dvcyaml 😅

Copy link
Contributor

@daavoo daavoo left a comment

Choose a reason for hiding this comment

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

The code changes look good to me, and it is consistent with the behavior we already applying *#615 (comment).

My only worry is that I am not understanding the issue behind #611 and when this is a fix. I assume that this is a fix only if Live gets instantiated before params_show is called?

@daavoo daavoo merged commit a0de508 into main Jul 4, 2023
@daavoo daavoo deleted the cleanup-dvcyaml branch July 4, 2023 11:54
@dberenbaum
Copy link
Collaborator Author

@daavoo Where are we overwriting in the code? Is this PR doing anything then? 😅

dberenbaum pushed a commit that referenced this pull request Jul 4, 2023
@daavoo
Copy link
Contributor

daavoo commented Jul 4, 2023

@daavoo Where are we overwriting in the code?

dvclive/src/dvclive/dvc.py

Lines 86 to 116 in d261760

def make_dvcyaml(live):
dvcyaml = {}
if live._params:
dvcyaml["params"] = [os.path.relpath(live.params_file, live.dir)]
if live._metrics or live.summary:
dvcyaml["metrics"] = [os.path.relpath(live.metrics_file, live.dir)]
plots = []
plots_path = Path(live.plots_dir)
if live._metrics:
metrics_path = (plots_path / Metric.subfolder).relative_to(live.dir).as_posix()
metrics_config = {metrics_path: {"x": "step"}}
plots.append(metrics_config)
if live._images:
images_path = (plots_path / Image.subfolder).relative_to(live.dir)
plots.append(images_path.as_posix())
if live._plots:
for plot in live._plots.values():
plot_path = plot.output_path.relative_to(live.dir)
plots.append({plot_path.as_posix(): plot.plot_config})
if plots:
dvcyaml["plots"] = plots
if live._artifacts:
dvcyaml["artifacts"] = copy.deepcopy(live._artifacts)
for artifact in dvcyaml["artifacts"].values():
abs_path = os.path.abspath(artifact["path"])
abs_dir = os.path.realpath(live.dir)
relative_path = os.path.relpath(abs_path, abs_dir)
artifact["path"] = Path(relative_path).as_posix()
dump_yaml(dvcyaml, live.dvc_file)

This only happens when make_dvcyaml is called.

Is this PR doing anything then? 😅

Yes, it makes the behavior consistent with the rest of the DVCLive-generated files, where we clean up at Live instantiation

@dberenbaum
Copy link
Collaborator Author

I wonder if we need to be so particular anymore about which files to drop inside the dvclive dir or if we should just drop the whole dir. Seems just as likely that someone will end up with stale files than deleting something someone wanted to keep. AFAIR we used to drop more aggressively before #102, but maybe we are more clear now that the dvclive dir should be a separate dir managed only by dvclive.

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.

params_show compatibility
3 participants