-
Notifications
You must be signed in to change notification settings - Fork 37
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
Support pathlib.Path
values for dvcyaml
argument in Live()
.
#842
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,7 +82,7 @@ def __init__( | |
resume: bool = False, | ||
report: Literal["md", "notebook", "html", None] = None, | ||
save_dvc_exp: bool = True, | ||
dvcyaml: Optional[str] = "dvc.yaml", | ||
dvcyaml: Union[str, os.PathLike, bool, None] = "dvc.yaml", | ||
cache_images: bool = False, | ||
exp_name: Optional[str] = None, | ||
exp_message: Optional[str] = None, | ||
|
@@ -104,11 +104,11 @@ def __init__( | |
part of `Live.end()`. Defaults to `True`. If you are using DVCLive | ||
inside a DVC Pipeline and running with `dvc exp run`, the option will be | ||
ignored. | ||
dvcyaml (str | None): where to write dvc.yaml file, which adds DVC | ||
dvcyaml (str | Path | None): where to write dvc.yaml file, which adds DVC | ||
configuration for metrics, plots, and parameters as part of | ||
`Live.next_step()` and `Live.end()`. If `None`, no dvc.yaml file is | ||
written. Defaults to `"dvc.yaml"`. See `Live.make_dvcyaml()`. | ||
If a string like `"subdir/dvc.yaml"`, DVCLive will write the | ||
If a string or Path like `"subdir/dvc.yaml"`, DVCLive will write the | ||
configuration to that path (file must be named "dvc.yaml"). | ||
If `False`, DVCLive will not write to "dvc.yaml" (useful if you are | ||
tracking DVCLive metrics, plots, and parameters independently and | ||
|
@@ -265,11 +265,19 @@ def _init_dvc(self): # noqa: C901 | |
self._include_untracked.append(self.dir) | ||
|
||
def _init_dvc_file(self) -> str: | ||
if isinstance(self._dvcyaml, str): | ||
if os.path.basename(self._dvcyaml) == "dvc.yaml": | ||
return self._dvcyaml | ||
raise InvalidDvcyamlError | ||
return "dvc.yaml" | ||
if self._dvcyaml is None: | ||
return "dvc.yaml" | ||
if isinstance(self._dvcyaml, bool): | ||
return "dvc.yaml" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we okay with returning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this is unrelated to this PR. We were already doing that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @skshetry, as pointed out by @dberenbaum, "the slight justification for still setting it to dvc.yaml is that if someone has set Live(dvcyaml=False) but then manually calls make_dvcyaml(), it will still write to dvc.yaml. "dvc.yaml" is being returned ". |
||
|
||
self._dvcyaml = os.fspath(self._dvcyaml) | ||
if ( | ||
isinstance(self._dvcyaml, str) | ||
and os.path.basename(self._dvcyaml) == "dvc.yaml" | ||
): | ||
return self._dvcyaml | ||
|
||
raise InvalidDvcyamlError | ||
|
||
def _init_dvc_pipeline(self): | ||
if os.getenv(env.DVC_EXP_BASELINE_REV, None): | ||
|
@@ -334,6 +342,7 @@ def _init_test(self): | |
""" | ||
with tempfile.TemporaryDirectory() as dirpath: | ||
self._dir = os.path.join(dirpath, self._dir) | ||
self._dvcyaml = os.fspath(self._dvcyaml) | ||
if isinstance(self._dvcyaml, str): | ||
self._dvc_file = os.path.join(dirpath, self._dvcyaml) | ||
self._save_dvc_exp = False | ||
|
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.
hmm, so is it something new? do we want to support bool as well?
we need to update docs then?
what happens if it's False (sounds like
dvc.yaml
should not be produced at all then?)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.
On True/False/None, it defaults to "dvc.yaml".
I had to make this change to pass an already written test case, which tests
True
,False
values todvcyaml
argument.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.
@AbdullahMakhdoom could you please point me to that test?
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.
@shcheklein, you can read the docstring for
dvcyaml
.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.
okay, so:
it means we can't default to
dvc.yaml
- we should probably not running this function at all then if it's False.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.
@shcheklein The code is maybe a bit of a mess here, but this sets
self._dvcfile
, which shouldn't matter for whether thedvc.yaml
file is written. The code still checksself._dvcyaml
to decide whether to writedvc.yaml
here. This is tested here:dvclive/tests/test_make_dvcyaml.py
Lines 461 to 463 in 6888462
It shouldn't matter much if
self._dvcfile
is set in this scenario, but the slight justification for still setting it todvc.yaml
is that if someone has setLive(dvcyaml=False)
but then manually callsmake_dvcyaml()
, it will still write todvc.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.
It's unclear why using
False
is necessary here, as settingdvcyaml
toNone
appears to produce the same outcome. Both tests ensure that thedvc.yaml
file is not created whendvcyaml
is either False or None, indicating that these options are functionally equivalent in this context.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.
Also, apologize for the delayed responses, I've been quite busy with my day job. Please let me know the best way to move forward, and I'll make sure to do my best.
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.
No problem @AbdullahMakhdoom, thanks for keeping on top of this!
dvcyaml
used to be a bool argument and support for bools was left to avoid making a breaking change. We should probably have dropped this during the last major release but missed it.