Skip to content

Commit

Permalink
Fix issue that str2bool not being applied in certain cases (#2023)
Browse files Browse the repository at this point in the history
* Add workaround solution

* Fix minor

* Remove str int
  • Loading branch information
harimkang authored Apr 18, 2023
1 parent e22e52a commit 4000c7d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions otx/cli/utils/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ def _get_leaf_node(curr_dict: Dict[str, dict], curr_key: str):
value_type = None
if type_hint is not None:
value_type = type_hint.get(origin_key, {}).get("type", None)
# FIXME[HARIM]: There's no template in args, and it's not inside the workspace, but with --workspace,
# the template is not found in args, so params, which are all bools, go into str.
# This is a temporary solution.
if isinstance(value, str) and value.lower() in ("true", "false"):
value_type = str2bool

leaf_node_dict, node_key = _get_leaf_node(params_dict, origin_key)
leaf_node_dict[node_key] = {"value": value_type(value) if value_type else value}
Expand Down Expand Up @@ -249,6 +254,8 @@ def get_parser_and_hprams_data():
template_config = parse_model_template("./template.yaml")
hyper_parameters = template_config.hyper_parameters.data
parser.add_argument("template", nargs="?", default="./template.yaml", help=template_help_str)
# TODO: Need fix for how to get hyper_parameters when no template is given and ./template.yaml doesn't exist
# Ex. When using --workspace outside of a workspace, but cannot access --workspace from this function.
else:
parser.add_argument("template", nargs="?", default=None, help=template_help_str)

Expand Down

0 comments on commit 4000c7d

Please sign in to comment.