Skip to content

Commit ec3e83d

Browse files
author
dberenbaum
committed
limit windows path handling to studio
1 parent 33288cd commit ec3e83d

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

dvc.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
metrics:
22
- ../../../../private/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/pytest-of-dave/pytest-255/test_dvclive_log_metrics_10_0/metrics.json
33
- ../../../../private/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/pytest-of-dave/pytest-255/test_dvclive_log_metrics_None_0/metrics.json
4+
- ../../../../private/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/pytest-of-dave/pytest-256/test_dvclive_log_metrics_10_0/metrics.json
5+
- ../../../../private/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/pytest-of-dave/pytest-256/test_dvclive_log_metrics_None_0/metrics.json
46
plots:
57
- ? ../../../../private/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/pytest-of-dave/pytest-255/test_dvclive_log_metrics_10_0/plots/metrics
68
: x: step
79
- ? ../../../../private/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/pytest-of-dave/pytest-255/test_dvclive_log_metrics_None_0/plots/metrics
810
: x: step
11+
- ? ../../../../private/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/pytest-of-dave/pytest-256/test_dvclive_log_metrics_10_0/plots/metrics
12+
: x: step
13+
- ? ../../../../private/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/pytest-of-dave/pytest-256/test_dvclive_log_metrics_None_0/plots/metrics
14+
: x: step

src/dvclive/studio.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import math
66
import os
7+
from pathlib import PureWindowsPath
78
from typing import TYPE_CHECKING
89

910
from dvc_studio_client.config import get_studio_config
@@ -38,8 +39,11 @@ def _cast_to_numbers(datapoints: dict):
3839

3940

4041
def _adapt_path(live: Live, name: StrPath):
41-
dvc_root_path = live._dvc_repo.root_dir if live._dvc_repo else None
42-
return rel_path(name, dvc_root_path)
42+
if live._dvc_repo is not None:
43+
name = rel_path(name, live._dvc_repo.root_dir)
44+
if os.name == "nt":
45+
name = str(PureWindowsPath(name).as_posix())
46+
return name
4347

4448

4549
def _adapt_plot_datapoints(live: Live, plot: dict):

src/dvclive/utils.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55
import re
66
import shutil
7-
from pathlib import Path, PureWindowsPath
7+
from pathlib import Path
88
from platform import uname
99
from typing import Union, List, Dict, TYPE_CHECKING
1010
import webbrowser
@@ -192,12 +192,8 @@ def wrapper(*args, **kwargs):
192192

193193

194194
def rel_path(path, dvc_root_path):
195-
if dvc_root_path:
196-
absolute_path = Path(path).absolute()
197-
path = os.path.relpath(absolute_path, dvc_root_path)
198-
if os.name == "nt":
199-
return str(PureWindowsPath(path).as_posix())
200-
return str(Path(path).as_posix())
195+
absolute_path = Path(path).absolute()
196+
return str(Path(os.path.relpath(absolute_path, dvc_root_path)).as_posix())
201197

202198

203199
def read_history(live, metric):

0 commit comments

Comments
 (0)