Skip to content

Commit

Permalink
stash
Browse files Browse the repository at this point in the history
  • Loading branch information
jjshoots committed Sep 11, 2024
1 parent 3a5f96b commit d409201
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "jj_wingman"
version = "0.20.0"
version = "0.21.0"
authors = [
{ name="Jet", email="[email protected]" },
]
Expand Down
42 changes: 26 additions & 16 deletions wingman/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,35 @@ def __setattr__(self, name, value):
)
super().__setattr__(name, value)

def to_dict(self) -> dict[str, Any]:
"""to_dict.
def dict_to_locked_ns(nested_dict: dict[str, Any]) -> LockedNamespace:
"""dict_to_ns.
Args:
Args:
----
nested_dict (dict[str, Any]): nested_dict
Returns:
dict[str, Any]:
"""
return {
k: (v.to_dict() if isinstance(v, LockedNamespace) else v)
for k, v in vars(self).items()
}

Returns:
-------
types.SimpleNamespace:
@staticmethod
def from_dict(nested_dict: dict[str, Any]) -> "LockedNamespace":
"""from_dict.
"""
return LockedNamespace(
**{
k: (dict_to_locked_ns(v) if isinstance(v, dict) else v)
for k, v in nested_dict.items()
}
)
Args:
nested_dict (dict[str, Any]): nested_dict
Returns:
"LockedNamespace":
"""
return LockedNamespace(
**{
k: (LockedNamespace.from_dict(v) if isinstance(v, dict) else v)
for k, v in nested_dict.items()
}
)


def check_dict_superset(base: dict[str, Any], target: dict[str, Any]) -> bool:
Expand Down Expand Up @@ -206,4 +216,4 @@ def generate_wingman_config(config_yaml: Path | str) -> LockedNamespace:
raise NotImplementedError("Save code is not yet implemented.")
wandb.run.log_code(".", exclude_fn=lambda path: "venv" in path)

return dict_to_locked_ns(config_dict)
return LockedNamespace.from_dict(config_dict)

0 comments on commit d409201

Please sign in to comment.