merge visualization branch
The web server is included as a submodule. The dependencies for the web (tornado) are not installed by default, but they can be installed as an extra: ``` pip install soil[web] ``` Once installed, the soil web can be used like this: ``` soil-web OR python -m soil.web ``` There are other minor changes: * History re-connects to the sqlite database if it is used from a different thread. * Environment accepts additional parameters (so it can run simulations with `visualization_params` or any other in the future). * The simulator class is no longer necessary * Logging is done in the same thread, and the simulation is run in a separate one. This had to be done because it was creating some problems with tornado not being able to find the current thread during logs, which caused hundreds of repeated lines in the web "console". * The player is slightly modified in this version. I noticed that when the visualization was playing, if you clicked somewhere it would change for a second, and then go back to the previous place. The code for the playback seemed too complex, especially speed control, so I rewrote some parts. I might've introduced new bugs.exporters 0.12.0
@ -1,3 +1,5 @@
|
||||
FROM python:3.4-onbuild
|
||||
|
||||
RUN pip install '.[web]'
|
||||
|
||||
ENTRYPOINT ["python", "-m", "soil"]
|
||||
|
@ -1 +1 @@
|
||||
0.11.3
|
||||
0.12.0
|
@ -0,0 +1,5 @@
|
||||
from . import main
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@ -1,36 +0,0 @@
|
||||
import os
|
||||
import networkx as nx
|
||||
from soil.simulation import SoilSimulation
|
||||
|
||||
|
||||
class Simulator():
|
||||
""" Simulator for running simulations. Using SOIL."""
|
||||
|
||||
def __init__(self, dump=False, dir_path='output'):
|
||||
self.name = 'soil'
|
||||
self.dump = dump
|
||||
self.dir_path = dir_path
|
||||
|
||||
def run(self, config):
|
||||
name = config['name']
|
||||
print('Using config(s): {name}'.format(name=name))
|
||||
|
||||
sim = SoilSimulation(**config)
|
||||
sim.dir_path = os.path.join(self.dir_path, name)
|
||||
sim.dump = self.dump
|
||||
|
||||
print('Dumping results to {} : {}'.format(sim.dir_path, sim.dump))
|
||||
|
||||
simulation_results = sim.run_simulation()
|
||||
|
||||
# G = simulation_results[0].history_to_graph()
|
||||
# for node in G.nodes():
|
||||
# if 'pos' in G.node[node]:
|
||||
# G.node[node]['viz'] = {"position": {"x": G.node[node]['pos'][0], "y": G.node[node]['pos'][1], "z": 0.0}}
|
||||
# del (G.node[node]['pos'])
|
||||
# nx.write_gexf(G, 'test.gexf', version='1.2draft')
|
||||
|
||||
return simulation_results
|
||||
|
||||
def reset(self):
|
||||
pass
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 8.0 MiB After Width: | Height: | Size: 8.0 MiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 101 KiB |
Before Width: | Height: | Size: 462 B After Width: | Height: | Size: 462 B |
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 812 B |
Before Width: | Height: | Size: 697 B After Width: | Height: | Size: 697 B |
Before Width: | Height: | Size: 992 B After Width: | Height: | Size: 992 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |