forked from projectmesa/mesa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This runs the project in the same way a user typically would, by changing to the project directory (so that resources can be located using relative paths). However, rather than executing the `run.py` directly, it assumes that importing `run` will produce a module with a `server` attribute. For the moment, it calls `server.launch()` but it could be modified to call other methods or pass parameters to that server, such as to run "headless"
- Loading branch information
Showing
19 changed files
with
90 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from bank_reserves.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from boidflockers.server import server | ||
from flockers.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from wealth_model.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from wealth_model.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from color_patches.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from game_of_life.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from civil_violence.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from forest_fire.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from hex_snowflake.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from pd_grid.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from shape_model.server import launch_shape_model | ||
|
||
launch_shape_model() | ||
if __name__ == "__main__": | ||
launch_shape_model() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from sugarscape.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from virus_on_network.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from wolf_sheep.server import server | ||
|
||
server.launch() | ||
if __name__ == "__main__": | ||
server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
import os | ||
import importlib | ||
import click | ||
|
||
PROJECT_PATH = click.Path(exists=True, file_okay=False, dir_okay=True, resolve_path=True) | ||
|
||
|
||
@click.group() | ||
def cli(): | ||
'Manage Mesa projects' | ||
|
||
|
||
@cli.command() | ||
@click.argument('project', type=PROJECT_PATH, default='.') | ||
def run(project): | ||
'''Run mesa project PROJECT | ||
PROJECT is the path to the directory containing `run.py`, or the current | ||
directory if not specified. | ||
''' | ||
sys.path.insert(0, project) | ||
os.chdir(project) | ||
run = importlib.import_module('run') | ||
run.server.launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,5 @@ tornado==4.5.3 | |
flake8==2.5.2 | ||
tqdm | ||
networkx==2.1 | ||
|
||
click==6.7 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import sys | ||
import unittest | ||
from unittest.mock import patch | ||
from click.testing import CliRunner | ||
|
||
from mesa.main import cli | ||
|
||
|
||
class TestCli(unittest.TestCase): | ||
''' | ||
Test CLI commands | ||
''' | ||
|
||
def setUp(self): | ||
self.old_sys_path = sys.path[:] | ||
self.runner = CliRunner() | ||
|
||
def tearDown(self): | ||
sys.path[:] = self.old_sys_path | ||
|
||
def test_run(self): | ||
with patch('mesa.visualization.ModularVisualization.ModularServer') as ModularServer: | ||
example_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '../examples/wolf_sheep')) | ||
with self.runner.isolated_filesystem(): | ||
result = self.runner.invoke(cli, ['run', example_dir]) | ||
assert result.exit_code == 0, result.output | ||
assert ModularServer().launch.call_count == 1 |