Skip to content

Commit

Permalink
Solving the Sacred 0.75 issue where config is read-only
Browse files Browse the repository at this point in the history
  • Loading branch information
samvelyan committed Oct 16, 2019
1 parent afbc6ff commit 9be8cb0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/config/envs/sc2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ env_args:
state_last_action: True
state_timestep_number: False
step_mul: 8
seed: null
heuristic_ai: False
debug: False

Expand Down
20 changes: 15 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@


@ex.main
def my_main(_run, _config, _log, env_args):
def my_main(_run, _config, _log):
# Setting the random seed throughout the modules
np.random.seed(_config["seed"])
th.manual_seed(_config["seed"])
env_args['seed'] = _config["seed"]
config = config_copy(_config)
np.random.seed(config["seed"])
th.manual_seed(config["seed"])
config['env_args']['seed'] = config["seed"]

# run the framework
run(_run, _config, _log)
run(_run, config, _log)


def _get_config(params, arg_name, subfolder):
Expand Down Expand Up @@ -60,6 +61,15 @@ def recursive_dict_update(d, u):
return d


def config_copy(config):
if isinstance(config, dict):
return {k: config_copy(v) for k, v in config.items()}
elif isinstance(config, list):
return [config_copy(v) for v in config]
else:
return deepcopy(config)


if __name__ == '__main__':
params = deepcopy(sys.argv)

Expand Down

0 comments on commit 9be8cb0

Please sign in to comment.