Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

add support for boolean params #108

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rlpytorch/model_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def load_model(self, params):

return model

def str2bool(v):
return v.lower() in ("yes", "true", "t", "1")

def load_env(envs, num_models=None, overrides=dict(), defaults=dict(), **kwargs):
''' Load envs. envs will be specified as environment variables, more specifically, ``game``, ``model_file`` and ``model`` are required.

Expand Down Expand Up @@ -132,5 +135,6 @@ def load_env(envs, num_models=None, overrides=dict(), defaults=dict(), **kwargs)
env.update(kwargs)

parser = argparse.ArgumentParser()
parser.register('type', 'bool', str2bool)
all_args = ArgsProvider.Load(parser, env, global_defaults=defaults, global_overrides=overrides)
return env, all_args