Skip to content

Commit

Permalink
Test layers (#147)
Browse files Browse the repository at this point in the history
* fix time bug

* linting

* fixed default fileconfig bug for empty files

* linting
  • Loading branch information
simplymathematics authored Nov 29, 2023
1 parent 40ce154 commit 75172d3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
5 changes: 1 addition & 4 deletions deckard/base/files/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ def __init__(
:param kwargs: Additional keyword arguments to be added to the files dictionary.
:return: A FileConfig object.
"""
# self._target_ = "deckard.base.files.FileConfig"
needs = [reports, data_dir, model_dir, attack_dir]
for need in needs:
assert need is not None, f"Need to specify {need}"
self._target_ = "deckard.base.files.FileConfig"
files.update(kwargs)
self.reports = str(Path(reports).as_posix()) if reports is not None else None
self.data_dir = str(Path(data_dir).as_posix()) if data_dir is not None else None
Expand Down
33 changes: 23 additions & 10 deletions deckard/layers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@


def find_conf_files(
config_name,
config_subdir,
config_dir,
config_name=None,
config_regex=None,
default_file=None,
):
Expand All @@ -50,10 +50,11 @@ def find_conf_files(
config_dir = Path(Path(), config_dir).resolve().as_posix()
sub_dir = Path(config_dir, config_subdir)
files = [default_file]
else:
else: # pragma: no cover
raise ValueError(
"Must specify either config_name or config_regex or default_file",
)
files = [file.as_posix() for file in files]
return files


Expand All @@ -67,14 +68,26 @@ def get_overrides(file: str, key: str = None, overrides=None):
overrides = {
entry.split("=")[0]: entry.split("=")[1] for entry in overrides
}
assert isinstance(overrides, dict), f"Expected list, got {type(overrides)}"
if key is not None and len(overrides) > 0:
overrides.pop(f"{key}.name", None)
overrides.pop(f"files.{key}_file", None)
overrides[f"++{key}.name"] = Path(file).stem
overrides[f"++files.{key}_file"] = Path(file).stem
overrides[f"{key}"] = Path(file).stem
overrides["++stage"] = key
if isinstance(overrides, dict):
new_dict = deepcopy(overrides)
for k, v in new_dict.items():
if k.startswith("++"):
overrides[k] = v
elif k.startswith("+"):
overrides[f"++{k[1:]}"] = v
elif k.startswith("~~"):
overrides[f"~~{k[2:]}"] = v
else:
overrides[f"++{k}"] = v

# assert isinstance(overrides, dict), f"Expected list, got {type(overrides)}"
# if key is not None and len(overrides) > 0:
# overrides.pop(f"{key}.name", None)
# overrides.pop(f"files.{key}_file", None)
# overrides[f"++{key}.name"] = Path(file).stem
# overrides[f"++files.{key}_file"] = Path(file).stem
# overrides[f"{key}"] = Path(file).stem
# overrides["++stage"] = key
return overrides


Expand Down

0 comments on commit 75172d3

Please sign in to comment.