Description
In agents.py
I stumbled onto the following import statements:
Lines 577 to 582 in e9033cf
These import statements are used to render graphics by the GraphicEnvironment
class defined just below it. However, since these packages are not mentioned in requirements.txt
, neither binder nor any developer installs them before running the notebooks. This results in the following stacktrace when agents.ipynb
tries to create an instance of GraphicEnvironment
:
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-18-0a21d3807079> in <module>
----> 1 park = GraphicPark(5,5, color={'EnergeticBlindDog': (200,0,0), 'Water': (0, 200, 200), 'Food': (230, 115, 40)})
2 dog = EnergeticBlindDog(program)
3 dogfood = Food()
4 water = Water()
5 park.add_thing(dog, [0,0])
/spare/aimacode/agents.py in __init__(self, width, height, boundary, color, display)
588 but initialise a BlockGrid for GUI too."""
589 super().__init__(width, height)
--> 590 self.grid = BlockGrid(width, height, fill=(200, 200, 200))
591 if display:
592 self.grid.show()
NameError: name 'BlockGrid' is not defined
There are two ways to resolve this issue:
- Remove the statements from the try except block and include these packages in
requirements.txt
- Put the entire class
GraphicEnvironment
in try-except so that it is only defined if those packages are installed.
I prefer the first approach since it requires minimal changes and because the second one will lead to the class not working on binder at all. However since the contribution guide states that no new packages should be added to requirements.txt
, I'm at an impasse.
Steps to reproduce the issue:
- Open Binder > agents.ipynb
- Rerun all cells by restarting the kernel (This is required because the initial output is a cached version by the notebook)