gsi-upm / soil

Apache License 2.0
28 stars 8 forks source link

Error when running example.yml from tutorial (soil 0.14.6) #4

Closed arodmor closed 4 years ago

arodmor commented 4 years ago

Hi,

Successfully updated soil to 0.14.6, which fixed this issue, -so environment is as in that one, except for networkx downgraded to 2.3 as part of the soil update-

I try to run example.yml from the soil tutorial, and I encounter the following error:

(testsim) arodmor@ganymede:~/testsoil$ soil example.yml 
INFO:root:Running SOIL version: 0.14.6
INFO:root:Loading config file: example.yml
INFO:soil:Using config(s): MyExampleSimulation
INFO:soil:Using exporters: ['default']
INFO:soil:Output directory: soil_output
INFO:soil:Starting simulation MyExampleSimulation at 15:15:29.
INFO:soil:Dumping results to soil_output/MyExampleSimulation
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/simulation.py", line 217, in run_trial_exceptions
    return self.run_trial(*args, **kwargs)
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/simulation.py", line 206, in run_trial
    env = self.get_env(trial_id = trial_id, **opts)
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/simulation.py", line 194, in get_env
    env = self.environment_class(**opts)
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/environment.py", line 61, in __init__
    self.network_agents = network_agents or []
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/environment.py", line 98, in network_agents
    self.init_agent(ix, agent_distribution=network_agents)
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/environment.py", line 120, in init_agent
    return self.set_agent(agent_id, agent_type, state)
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/environment.py", line 134, in set_agent
    state=state)
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/agents/SISaModel.py", line 35, in __init__
    self.neutral_discontent_spon_prob = np.random.normal(self.env['neutral_discontent_spon_prob'],
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/environment.py", line 186, in __getitem__
    return self.environment_params[key]
KeyError: 'neutral_discontent_spon_prob'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/simulation.py", line 220, in run_trial_exceptions
    c.message = ''.join(traceback.format_exception(type(c), c, c.__traceback__)[:])
AttributeError: 'NoneType' object has no attribute '__traceback__'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/arodmor/anaconda3/envs/testsim/bin/soil", line 8, in <module>
    sys.exit(main())
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/__init__.py", line 73, in main
    exporter_params=exp_params)
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/simulation.py", line 306, in run_from_config
    sim.run_simulation(**kwargs)
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/simulation.py", line 132, in run_simulation
    return self.run(*args, **kwargs)
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/simulation.py", line 136, in run
    return list(self._run_simulation_gen(*args, **kwargs))
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/simulation.py", line 170, in _run_simulation_gen
    **kwargs):
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/site-packages/soil/simulation.py", line 144, in _run_sync_or_async
    for i in p.imap_unordered(func, range(self.num_trials)):
  File "/home/arodmor/anaconda3/envs/testsim/lib/python3.7/multiprocessing/pool.py", line 748, in next
    raise value
AttributeError: 'NoneType' object has no attribute '__traceback__'

This one seems different from the other issue mentioned above.

Thanks!

balkian commented 4 years ago

The example was incomplete, some environment variables were missing. Take a look at the new file: https://github.com/gsi-upm/soil/blob/6adc8d36ba705da322435b231e2b923a2c574bd1/docs/example.yml#L27

You can also see it in the updated docs: https://soilsim.readthedocs.io/en/latest/configuration.html

The traceback was more confusing that it should've been because of the way we handle exceptions in multithreading code. We made some minor changes in 0.14.7 to address that.

arodmor commented 4 years ago

Hi,

updated soil to 0.14.7, I can confirm that the updated example.yml runs without issues on my system now.

I will be running additional examples from the various files in the /examples folder over the next few days, and report if I find anything else.

Incidentally (although that's maybe a separate issue), in the requirements.txt there's still a restriction to have scipy==1.2.1 , since "scipy 1.3.0rc1 is not compatible with salib". Is this still the case? Or could this be changed to scipy>=1.3 (current version is 1.4.1)? Should I open a separate issue to test that?

balkian commented 4 years ago

The latest scipy (1.4.1) seems to work just fine. I will updated it in the next release. Thank you!