1
0
mirror of https://github.com/gsi-upm/soil synced 2025-08-23 19:52:19 +00:00

Fix py3.4 and pypi bugs

This commit is contained in:
J. Fernando Sánchez
2017-10-19 18:28:17 +02:00
parent a7c51742f6
commit a4b32afa2f
5 changed files with 10 additions and 104 deletions

View File

@@ -4,7 +4,7 @@ import os
import pdb
import logging
__version__ = "0.10"
__version__ = "0.10.1"
try:
basestring

View File

@@ -1,36 +1,4 @@
import importlib
import sys
import os
import argparse
import logging
from . import simulation
logger = logging.getLogger(__name__)
def main():
parser = argparse.ArgumentParser(description='Run a SOIL simulation')
parser.add_argument('file', type=str,
nargs="?",
default='simulation.yml',
help='python module containing the simulation configuration.')
parser.add_argument('--module', '-m', type=str,
help='file containing the code of any custom agents.')
parser.add_argument('--dry-run', '--dry', action='store_true',
help='Do not store the results of the simulation.')
parser.add_argument('--output', '-o', type=str,
help='folder to write results to. It defaults to the current directory.')
args = parser.parse_args()
if args.module:
sys.path.append(os.getcwd())
importlib.import_module(args.module)
print('Loading config file: {}'.format(args.file, args.output))
simulation.run_from_config(args.file, dump=not args.dry_run, results_dir=args.output)
from . import main
if __name__ == '__main__':
main()

View File

@@ -145,15 +145,13 @@ class SoilEnvironment(nxsim.NetworkEnvironment):
def __getitem__(self, key):
if isinstance(key, tuple):
values = {"agent_id": key[0],
"t_step": key[1],
"key": key[2],
"value": None,
"value_type": None
}
fields = list(k for k, v in values.items() if v is None)
conditions = " and ".join("{}='{}'".format(k, v) for k, v in values.items() if v is not None)
values = [("agent_id", key[0]),
("t_step", key[1]),
("key", key[2]),
("value", None),
("value_type", None)]
fields = list(k for k, v in values if v is None)
conditions = " and ".join("{}='{}'".format(k, v) for k, v in values if v is not None)
query = """SELECT {fields} from history""".format(fields=",".join(fields))
if conditions: