CityBrainChallenge / KDDCup2021-CityBrainChallenge-starter-kit

77 stars 40 forks source link

unexpected keyword argument 'metric_period' #16

Closed boostf closed 3 years ago

boostf commented 3 years ago

An error called unexpected keyword argument 'metric_period' occurred while running the evaluate.py

INFO:evaluate.py:root_path=[agent, log, evaluate.py, run.sh, ui, train_dqn_example.py, demo.py, readme.md, data, .gitignore, cfg, out, eval.sh]
INFO:evaluate.py:input_dir=[agent_DQN.py, dqn_agent_99.h5, agent.py, __pycache__, gym_cfg.py]
INFO:evaluate.py:output_dir=[scores.json, .gitignore]
INFO:evaluate.py:submission_dir=[agent_DQN.py, dqn_agent_99.h5, agent.py, __pycache__, gym_cfg.py]
INFO:evaluate.py:scores_dir=[scores.json, .gitignore]
INFO:evaluate.py:files under submission dir:[agent_DQN.py, dqn_agent_99.h5, agent.py, __pycache__, gym_cfg.py]
INFO:evaluate.py:Loaded user agent instance={'test': <agent.TestAgent object at 0x7fe0dedd9790>}
INFO:evaluate.py:

INFO:evaluate.py:****************************************
Traceback (most recent call last):
  File "evaluate.py", line 502, in <module>
    scores = run_simulation(agent_spec, simulator_cfg_file, gym_cfg,metric_period,scores_dir,threshold)
  File "evaluate.py", line 291, in run_simulation
    metric_period = metric_period
  File "/usr/local/lib/python3.7/dist-packages/gym/envs/registration.py", line 145, in make
    return registry.make(id, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/gym/envs/registration.py", line 90, in make
    env = spec.make(**kwargs)
  File "/usr/local/lib/python3.7/dist-packages/gym/envs/registration.py", line 60, in make
    env = cls(**_kwargs)
TypeError: __init__() got an unexpected keyword argument 'metric_period'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "evaluate.py", line 507, in <module>
    raise AssertionError()
AssertionError

When I modified the code as follow, the evaluate.py can run correctly

def run_simulation(agent_spec, simulator_cfg_file, gym_cfg,metric_period,scores_dir,threshold):
    logger.info("\n")
    logger.info("*" * 40)

    # get gym instance
    gym_configs = gym_cfg.cfg
    simulator_configs = read_config(simulator_cfg_file)
    env = gym.make(
        'CBEngine-v0',
        simulator_cfg_file=simulator_cfg_file,
        thread_num=1,
        gym_dict = gym_configs,
        # metric_period = metric_period
    )
IcarusWizard commented 3 years ago

metric_period parameter is introduced in cbengine:0.1.2, you need to update your docker image.