Gurobi / modeling-examples

Gurobi modeling examples
https://gurobi.github.io/modeling-examples/
Apache License 2.0
615 stars 272 forks source link

Testing for notebooks #25

Closed venaturum closed 4 months ago

venaturum commented 4 months ago

Setup for tox and github actions.

Currently tests will fail due to errors in notebooks, which will be addressed in separate pull request

venaturum commented 4 months ago

@Marika-K this PR doesn't change any notebooks, it just sets up the framework to test them, so currently tests will not pass.

Further down the line we might want to separate each notebook into it's own test.

mattmilten commented 4 months ago

Looks good - thanks! Is there a reason for defining specific versions for all packages in the requirements file? I would just remove all of those, so we always pick the latest.

venaturum commented 4 months ago

Looks good - thanks! Is there a reason for defining specific versions for all packages in the requirements file? I would just remove all of those, so we always pick the latest.

Yeh it was a very deliberate action. This requirements file is supposed to act as a lockfile. If we were managing this project with Poetry or Pipenv - which would be a good idea considering the amount of easily breakable code - then we would be using a lockfile by default under the hood. This is pretty standard in modern package managers, Python and non-Python.

When someone submits a change to code we really want the tests to test only the code changes. Without a lockfile you are almost certainly testing a change in environment too, and this should be kept separate. We want to avoid the scenario where something runs on one computer, but the same code on another computer does not. The only way around this is a lockfile. You and I could create fresh virtual environments and ask for the latest package versions at the same precise instant and end up with different environments. Maybe mine works with a particular notebook and yours does not.

This is different from mandating that users of these notebooks have to use certain package versions. It will be a case of "use whatever environment you like, it may work, but we only guarantee it works for the environment defined here: ....". We make statements similar to this in the notebooks: "tested with Python 3.12 and gurobipy 11", but this is only a small part of the story.

mattmilten commented 4 months ago

OK, excellent! Then, we just have to update this requirements file every now and then to get the latest Gurobi version.