StochSS / GillesPy2

Modeling toolkit for biochemical simulation
http://gillespy2.readthedocs.io/
GNU General Public License v3.0
72 stars 32 forks source link

Dimerization example #774

Closed GFP-akers closed 2 years ago

GFP-akers commented 2 years ago

If the code for the Dimerization() example is ran (direct copy and paste), the program throws an error "Circular reference detected". raise SimulationError( SimulationError: argument 'solver=<class 'gillespy2.solvers.numpy.ssa_solver.NumPySSASolver'>' to run() failed. Reason Given: Circular reference detected

Re-produced on main using the SSACSolver and is present in all solvers. Full trace below:

2022-04-13 09:39:25,855 - root - WARNING - Please install/configure 'g++' and 'make' on your system, to ensure that GillesPy2 C solvers will run properly.
2022-04-13 09:39:25,855 - root - WARNING - Please install/configure 'g++' and 'make' on your system, to ensure that GillesPy2 C solvers will run properly.
Traceback (most recent call last):
  File "/Users/bryanrumsey/Documents/GillesPy2/gillespy2/core/model.py", line 1011, in run
    return solver.run(model=self, t=t, increment=increment, timeout=timeout, **solver_args)
  File "/Users/bryanrumsey/Documents/GillesPy2/gillespy2/solvers/cpp/ssa_c_solver.py", line 49, in run
    if model is not None and model.get_json_hash() != self.model.get_json_hash():
  File "/Users/bryanrumsey/Documents/GillesPy2/gillespy2/core/jsonify.py", line 158, in get_json_hash
    model_json = self.to_json(encode_private=hash_private_vals)
  File "/Users/bryanrumsey/Documents/GillesPy2/gillespy2/core/jsonify.py", line 49, in to_json
    return json.dumps(copy.deepcopy(self), indent=4, sort_keys=True, default=encoder.default)
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 234, in dumps
    return cls(
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 201, in encode
    chunks = list(chunks)
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 439, in _iterencode
    yield from _iterencode(o, _current_indent_level)
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/encoder.py", line 436, in _iterencode
    raise ValueError("Circular reference detected")
ValueError: Circular reference detected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 188, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/homebrew/Cellar/python@3.9/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 111, in _get_module_details
    __import__(pkg_name)
  File "/Users/bryanrumsey/Documents/GillesPy2/examples/ExtraModels/dimer_example.py", line 119, in <module>
    output = model.run(number_of_trajectories=10)
  File "/Users/bryanrumsey/Documents/GillesPy2/gillespy2/core/model.py", line 1022, in run
    raise SimulationError(
gillespy2.core.gillespyError.SimulationError: argument 'solver=<class 'gillespy2.solvers.cpp.ssa_c_solver.SSACSolver'>' to run() failed.  Reason Given: Circular reference detected

This error doesn't occur in the Jupyter Notebook environment

BryanRumsey commented 2 years ago

Thank you for you feedback, this issue will be resolved with the release of v1.6.9.

We have confirmed that this will run correctly in a Jupyter Notebook environment, see #775.