Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Gym.__init__() missing 1 required positional argument: 'name' #8

Open
davidenitti opened this issue Aug 1, 2023 · 1 comment

Comments

@davidenitti
Copy link

I have this error

Traceback (most recent call last):
  File "/home/davide/code/ML/RL/bench.py", line 37, in <module>
    exp.run(
  File "/home/davide/code/mushroom-rl-benchmark/mushroom_rl_benchmark/core/experiment.py", line 63, in run
    run_fn(**executor_params, **run_params)
  File "/home/davide/code/mushroom-rl-benchmark/mushroom_rl_benchmark/core/experiment.py", line 157, in run_parallel
    runs = parallel(
  File "/home/davide/code/mushroom-rl-benchmark/mushroom_rl_benchmark/utils/tqdm_parallel.py", line 9, in __call__
    return joblib.Parallel.__call__(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/joblib/parallel.py", line 1098, in __call__
    self.retrieve()
  File "/usr/local/lib/python3.10/dist-packages/joblib/parallel.py", line 975, in retrieve
    self._output.extend(job.get(timeout=self.timeout))
  File "/usr/local/lib/python3.10/dist-packages/joblib/_parallel_backends.py", line 567, in wrap_future_result
    return future.result(timeout=timeout)
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
TypeError: Gym.__init__() missing 1 required positional argument: 'name'

With this code:

import time
from mushroom_rl_benchmark.core import BenchmarkExperiment, BenchmarkLogger
from mushroom_rl_benchmark.builders import EnvironmentBuilder, PPOBuilder

if __name__ == '__main__':

    logger = BenchmarkLogger(
        log_dir='./logs',
        log_id='ppo_pendulum'
    )

    agent_builder = PPOBuilder.default(
        actor_lr=3e-4,
        critic_lr=3e-4,
        n_features=32
    )

    env_name = 'Gym'
    env_params = dict(
        env_id='Pendulum-v0',
        horizon=200,
        gamma=.99
    )

    parallel = dict(
            max_concurrent_runs=10
    )

    env_builder = EnvironmentBuilder(env_name, env_params)
    logger.info('Environment is imported')

    exp = BenchmarkExperiment(agent_builder, env_builder, logger)
    logger.info('BenchmarkExperiment was built successfully')

    start_time = time.time()
    exp.run(
        exec_type='parallel',
        n_runs=10,
        n_epochs=100,
        n_steps=30000,
        n_episodes_test=5,
        parallel=parallel
    )
    end_time = time.time()
    logger.info('Execution time: {} SEC'.format(end_time-start_time))

    exp.save_plot()
@boris-il-forte
Copy link
Contributor

boris-il-forte commented Aug 7, 2023

Dear @davidenitti

This code uses the old version of the benchmark (master branch) that is not supported anymore.
The new version is almost ready, you can find it in the new_benchmark branch. Unfortunately, it has not been tested yet. Indeed, our experiment-launcher package, upon which we base our new benchmark, has some issues with wandb, causing some random seeds to crash. We are solving the issue right now.

to fix the current issue in your code, you could just change the lines specifying the environment:

env_name = 'Gym.Pendulum-v1'
    env_params = dict(
        horizon=200,
        gamma=.99
    )

Unfortunately, the code is still crashing with the newest version of mushroom, as we performed some minor changes in the interface.

nb: I set v1 in the code as the version of gym I'm using does not have Pendulum-v0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants