Skip to content

Commit

Permalink
[core] Fix DataclassConfig.from_path() when argument is a URI
Browse files Browse the repository at this point in the history
  • Loading branch information
aschuh-hf committed Aug 16, 2023
1 parent 2064f3d commit e0cfe1f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/deepali/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# (cf. https://github.com/iterative/dvc/issues/8466#issuecomment-1290757564)
from ruamel.yaml import YAML

from .pathlib import Path, PathUri, abspath_template
from .pathlib import Path, PathUri, abspath_template, is_uri
from .storage import StorageObject
from .typing import is_path_str_field

Expand Down Expand Up @@ -51,7 +51,14 @@ def from_path(cls: Type[T], path: PathUri, section: Optional[str] = None) -> T:
if section:
for key in section.split("."):
config = config.get(key, {})
return cls.from_dict(config, parent=path.parent)
if is_uri(path):
if path.startswith("file:///"):
parent = Path(path[7:]).parent
else:
parent = None
else:
parent = Path(path).absolute().parent
return cls.from_dict(config, parent=parent)

@classmethod
def read(cls: Type[T], path: PathUri, section: Optional[str] = None) -> T:
Expand Down

0 comments on commit e0cfe1f

Please sign in to comment.