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

Lightsim2grid backend is not properly copied by env's copy method #360

Closed
Farid-Najar opened this issue Jul 12, 2022 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@Farid-Najar
Copy link
Contributor

Environment

  • Grid2op version: dev_multiagent
  • System: ubuntu20.04.3 LTS

Bug description

When we copy the env with env.copy(), the backend loses, at least, _my_kwargs attribute. Here, I used the lightsim2grid backend.

How to reproduce

Try the following code on a notebook or python terminal

Code snippet

from grid2op import make
try:
    from lightsim2grid import LightSimBackend
    bk_cls = LightSimBackend
    print("Using lightsim2grid!")
except ImportError as exc:
    print(f"Error: {exc} when importing faster LightSimBackend")
    from grid2op.Backend import PandaPowerBackend
    bk_cls = PandaPowerBackend

print(bk_cls()._my_kwargs)
env = make("l2rpn_case14_sandbox", test = True, backend = bk_cls()).copy()
print(env.backend._my_kwargs)

Current output

{'detailed_infos_for_cascading_failures': False, 'can_be_copied': True, 'solver_type': None, 'max_iter': 10, 'tol': 1e-08}
~/Grid2Op/grid2op/MakeEnv/Make.py:394: UserWarning: You are using a development environment. This environment is not intended for training agents. It might not be up to date and its primary use if for tests (hence the "test=True" you passed as argument). Use at your own risk.
  warnings.warn(_MAKE_DEV_ENV_WARN)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/Grid2Op/grid2op/multi_agent/test.ipynb Cell 29' in <cell line: 3>()
      [1](~/Grid2Op/grid2op/multi_agent/test.ipynb#ch0000049?line=0) print(bk_cls()._my_kwargs)
      [2](~/Grid2Op/grid2op/multi_agent/test.ipynb#ch0000049?line=1) env = make("l2rpn_case14_sandbox", test = True, backend = bk_cls()).copy()
----> [3](~/Grid2Op/grid2op/multi_agent/test.ipynb#ch0000049?line=2) print(env.backend._my_kwargs)

AttributeError: 'LightSimBackend_l2rpn_case14_sandbox' object has no attribute '_my_kwargs'

Expected output

{'detailed_infos_for_cascading_failures': False, 'can_be_copied': True, 'solver_type': None, 'max_iter': 10, 'tol': 1e-08}
~/Grid2Op/grid2op/MakeEnv/Make.py:394: UserWarning: You are using a development environment. This environment is not intended for training agents. It might not be up to date and its primary use if for tests (hence the "test=True" you passed as argument). Use at your own risk.
  warnings.warn(_MAKE_DEV_ENV_WARN)
{'detailed_infos_for_cascading_failures': False, 'can_be_copied': True, 'solver_type': None, 'max_iter': 10, 'tol': 1e-08}
@Farid-Najar Farid-Najar added the bug Something isn't working label Jul 12, 2022
BDonnot added a commit to Grid2op/lightsim2grid that referenced this issue Jul 12, 2022
@BDonnot BDonnot changed the title The backend is not properly copied by env's copy method Lightsim2grid backend is not properly copied by env's copy method Jul 13, 2022
@BDonnot BDonnot closed this as completed Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants