Skip to content

Commit

Permalink
comply with ruff linter
Browse files Browse the repository at this point in the history
  • Loading branch information
kmario23 committed Oct 20, 2024
1 parent a60ec47 commit 663dadb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pdebench/data_gen/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import glob
import os
from pathlib import Path
from pprint import pprint

from omegaconf import DictConfig, OmegaConf
Expand All @@ -11,14 +12,14 @@ def expand_path(path, unique=True):
"""
Resolve a path that may contain variables and user home directory references.
"""
return os.path.expandvars(os.path.expanduser(path))
return os.path.expandvars(Path(path).expanduser())


def matching_paths(glob_exp):
"""
return a list of paths matching a glob expression
"""
path = os.path.expandvars(os.path.expanduser(glob_exp))
path = os.path.expandvars(Path(glob_exp).expanduser())
return glob.glob(path)


Expand All @@ -35,12 +36,13 @@ def resolve_path(path, idx=None, unique=True):
matches = sorted(matches)

if unique and len(matches) > 1:
raise ValueError(f"Too many matches for glob: {path}")
else:
try:
return matches[idx]
except IndexError:
raise FileNotFoundError(f"No matches for glob: {path}")
valerrmsg = f"Too many matches for glob: {path}"
raise ValueError(valerrmsg)
try:
return matches[idx]
except IndexError:
idxerrmsg = f"No matches for glob: {path}"
raise FileNotFoundError(idxerrmsg)


def print_config(
Expand Down

0 comments on commit 663dadb

Please sign in to comment.