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

118 Add test_lru_cache_problem.py. #119

Merged
merged 5 commits into from
Mar 5, 2025
Merged

Conversation

chenkins
Copy link
Contributor

@chenkins chenkins commented Feb 15, 2025

Changes

Related issues

Fixes #118.
First steps for #104

Checklist

  • Tests are included for relevant behavior changes.
  • Documentation is added in the flatland-book repo for relevant behavior changes.
  • If you made important user-facing changes, describe them under the [Unreleased] tag in CHANGELOG.md.
  • New package dependencies are declared in the pyproject.toml file.
    Requirement files have been updated by running tox -e requirements.
  • Code works with all supported Python versions (3.10, 3.11 and 3.12). Checks run with all three version and are
    required to run successfully.
  • Code is formatted according to PEP 8 (an IDE like PyCharm can do this for you).
  • Technical guidelines listed in CONTRIBUTING.md are followed.

@chenkins chenkins added this to the 4.0.5 milestone Feb 15, 2025
@chenkins chenkins changed the title Add test_lru_cache_problem.py. 118 Add test_lru_cache_problem.py. Feb 16, 2025
@chenkins chenkins force-pushed the 118-fix-lru-cache-in-env-loading branch 2 times, most recently from 65f5e0b to 16e32c3 Compare February 19, 2025 17:58
@chenkins chenkins marked this pull request as ready for review February 19, 2025 17:58
@chenkins chenkins requested a review from a team as a code owner February 19, 2025 17:58
@chenkins chenkins assigned manuschn and unassigned manuschn Feb 21, 2025
@aiAdrian
Copy link
Contributor

This solution looks good - unfortunately, I haven't been able to test it at runtime yet. However, I understand the fix.

@chenkins
Copy link
Contributor Author

@aiAdrian thx for your comment. Rest coming with #104

@aiAdrian
Copy link
Contributor

aiAdrian commented Mar 4, 2025

I checked out this branch. I am not sure whether we will encounter future issues. See the below log – of course, this is not yet adapted to the latest version (in this branch), but I am just wondering if the problem can be fixed when we inherit the RailEnv.

(flatland-rl-test) u216993@K57156:~/flatland/test/flatland_solver_policy$ python example/flatland_dynamics/example_flatland_dynamics.py
Traceback (most recent call last):
File "example/flatland_dynamics/example_flatland_dynamics.py", line 4, in
from environment.flatland_railway_extension.flatland_dynamics import FlatlandDynamicsEnvironment
File "/home/u216993/flatland/test/flatland_solver_policy/environment/flatland_railway_extension/flatland_dynamics.py", line 3, in
from flatland_railway_extension.FlatlandEnvironmentHelper import FlatlandEnvironmentHelper
File "/home/u216993/flatland/test/flatland_railway_extension/flatland_railway_extension/FlatlandEnvironmentHelper.py", line 6, in
from flatland.envs.malfunction_generators import MalfunctionParameters, ParamMalfunctionGen
File "/home/u216993/flatland/test/flatland-rl/flatland/envs/malfunction_generators.py", line 10, in
from flatland.envs import persistence
File "/home/u216993/flatland/test/flatland-rl/flatland/envs/persistence.py", line 10, in
from flatland.envs import rail_env
File "/home/u216993/flatland/test/flatland-rl/flatland/envs/rail_env.py", line 34, in
class RailEnv(Environment):
File "/home/u216993/flatland/test/flatland-rl/flatland/envs/rail_env.py", line 244, in RailEnv
def action_required(agent_state, is_cell_entry):
File "/etc/pyenv/.pyenv/versions/3.8.6/lib/python3.8/functools.py", line 526, in decorating_function
wrapper = _lru_cache_wrapper(user_function, maxsize, typed, _CacheInfo)
TypeError: the first argument must be callable

@chenkins
Copy link
Contributor Author

chenkins commented Mar 4, 2025

@aiAdrian you're using 3.8. There were changes to lru_cache in 3.9, see https://docs.python.org/3.13/library/functools.html#functools.lru_cache. Please use one of the supported Python versions 3.10, 3.11, 3.12, see https://github.com/flatland-association/flatland-rl/blob/main/CONTRIBUTING.md#get-started. Does it go away?

@chenkins chenkins force-pushed the 118-fix-lru-cache-in-env-loading branch from 3254dbd to 6026a74 Compare March 5, 2025 15:24
@chenkins chenkins requested a review from aiAdrian March 5, 2025 15:24
@chenkins chenkins enabled auto-merge (squash) March 5, 2025 15:34
@chenkins chenkins merged commit de36600 into main Mar 5, 2025
11 checks passed
@chenkins chenkins deleted the 118-fix-lru-cache-in-env-loading branch March 5, 2025 15:38
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

Successfully merging this pull request may close these issues.

Reset lru cache in all env loading cases.
3 participants