@@ -82,7 +82,7 @@ def __init__(
82
82
resume : bool = False ,
83
83
report : Literal ["md" , "notebook" , "html" , None ] = None ,
84
84
save_dvc_exp : bool = True ,
85
- dvcyaml : Optional [str ] = "dvc.yaml" ,
85
+ dvcyaml : Optional [str , Path ] = "dvc.yaml" ,
86
86
cache_images : bool = False ,
87
87
exp_name : Optional [str ] = None ,
88
88
exp_message : Optional [str ] = None ,
@@ -104,11 +104,11 @@ def __init__(
104
104
part of `Live.end()`. Defaults to `True`. If you are using DVCLive
105
105
inside a DVC Pipeline and running with `dvc exp run`, the option will be
106
106
ignored.
107
- dvcyaml (str | None): where to write dvc.yaml file, which adds DVC
107
+ dvcyaml (str | Path | None): where to write dvc.yaml file, which adds DVC
108
108
configuration for metrics, plots, and parameters as part of
109
109
`Live.next_step()` and `Live.end()`. If `None`, no dvc.yaml file is
110
110
written. Defaults to `"dvc.yaml"`. See `Live.make_dvcyaml()`.
111
- If a string like `"subdir/dvc.yaml"`, DVCLive will write the
111
+ If a string or Path like `"subdir/dvc.yaml"`, DVCLive will write the
112
112
configuration to that path (file must be named "dvc.yaml").
113
113
If `False`, DVCLive will not write to "dvc.yaml" (useful if you are
114
114
tracking DVCLive metrics, plots, and parameters independently and
@@ -265,11 +265,16 @@ def _init_dvc(self): # noqa: C901
265
265
self ._include_untracked .append (self .dir )
266
266
267
267
def _init_dvc_file (self ) -> str :
268
- if isinstance (self ._dvcyaml , str ):
269
- if os .path .basename (self ._dvcyaml ) == "dvc.yaml" :
270
- return self ._dvcyaml
271
- raise InvalidDvcyamlError
272
- return "dvc.yaml"
268
+ if self ._dvcyaml is None or isinstance (self ._dvcyaml , bool ):
269
+ return "dvc.yaml"
270
+ if isinstance (self ._dvcyaml , Path ):
271
+ self ._dvcyaml = str (self ._dvcyaml )
272
+ if (
273
+ isinstance (self ._dvcyaml , str )
274
+ and os .path .basename (self ._dvcyaml ) == "dvc.yaml"
275
+ ):
276
+ return self ._dvcyaml
277
+ raise InvalidDvcyamlError
273
278
274
279
def _init_dvc_pipeline (self ):
275
280
if os .getenv (env .DVC_EXP_BASELINE_REV , None ):
@@ -334,6 +339,8 @@ def _init_test(self):
334
339
"""
335
340
with tempfile .TemporaryDirectory () as dirpath :
336
341
self ._dir = os .path .join (dirpath , self ._dir )
342
+ if isinstance (self ._dvcyaml , Path ):
343
+ self ._dvcyaml = str (self ._dvcyaml )
337
344
if isinstance (self ._dvcyaml , str ):
338
345
self ._dvc_file = os .path .join (dirpath , self ._dvcyaml )
339
346
self ._save_dvc_exp = False
0 commit comments