From 2167d98795f56f2fb46ce6ecb8b28d67eb36c805 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Prinz Date: Tue, 21 Mar 2017 23:39:43 +0100 Subject: [PATCH] run works --- adaptivemd/engine/acemd/acemd.py | 2 +- adaptivemd/engine/engine.py | 148 +++++++++++++++++- adaptivemd/engine/openmm/openmm.py | 56 ++++--- adaptivemd/engine/openmm/openmmrun.py | 39 +++-- adaptivemd/file.py | 4 +- adaptivemd/generator.py | 7 +- adaptivemd/mongodb/dictify.py | 2 +- adaptivemd/mongodb/syncvar.py | 7 +- adaptivemd/tests/test_simple.py | 2 +- examples/ntl9/adaptive.py | 2 +- examples/ntl9/setup.py | 2 +- examples/rp/test_4cuda.py | 2 +- examples/rp/test_adaptive.py | 4 +- examples/rp/test_asyncGPU.py | 2 +- examples/rp/test_setconda.py | 2 +- examples/rp/test_simple.py | 2 +- examples/rp/test_worker_allegro_asyncCPU.py | 4 +- examples/rp/test_worker_asyncCPU.py | 4 +- .../tutorial/1_example_setup_project.ipynb | 10 +- examples/tutorial/2_example_run.ipynb | 61 +++++++- examples/tutorial/test_4cuda.py | 2 +- examples/tutorial/test_adaptive.py | 4 +- examples/tutorial/test_asyncGPU.py | 2 +- examples/tutorial/test_setconda.py | 2 +- 24 files changed, 296 insertions(+), 76 deletions(-) diff --git a/adaptivemd/engine/acemd/acemd.py b/adaptivemd/engine/acemd/acemd.py index 43e2b81..c11fb32 100755 --- a/adaptivemd/engine/acemd/acemd.py +++ b/adaptivemd/engine/acemd/acemd.py @@ -40,7 +40,7 @@ def __init__(self, conf_file, pdb_file, args=None): def call_format_str(self): return 'acemd %s {0}' % self.args - def task_run_trajectory(self, target): + def run(self, target): t = Task() initial_pdb = t.link(self['pdb_file_stage'], Location('initial.pdb')) diff --git a/adaptivemd/engine/engine.py b/adaptivemd/engine/engine.py index e9209e9..9916f7c 100755 --- a/adaptivemd/engine/engine.py +++ b/adaptivemd/engine/engine.py @@ -2,9 +2,9 @@ import random import os -from adaptivemd.file import File, Location +from adaptivemd.file import File from adaptivemd.generator import TaskGenerator -from adaptivemd.mongodb import StorableMixin, SyncVariable +from adaptivemd.mongodb import StorableMixin, ObjectSyncVariable from adaptivemd.task import Task @@ -14,7 +14,27 @@ class Engine(TaskGenerator): """ - def task_run_trajectory(self, target): + def __init__(self): + super(Engine, self).__init__() + + self.types = {} + + # set default output type if nothing is specified + self.add_output_type('master', 'output.dcd', 1) + + @classmethod + def from_dict(cls, dct): + obj = super(Engine, cls).from_dict(dct) + obj.types = dct['types'] + return obj + + def to_dict(self): + dct = super(Engine, self).to_dict() + dct.update({ + 'types': self.types}) + return dct + + def run(self, target): """ Create a task that returns a trajectory given in the input @@ -31,6 +51,25 @@ def task_run_trajectory(self, target): """ return None + def extend(self, target, length): + """ + Create a task that extends a trajectory given in the input + + Parameters + ---------- + target : `Trajectory` + location of the target trajectory to be extended + length : int + number of additional frames to be computed + + Returns + ------- + `Task` + the task object containing the job description + + """ + return None + def file_generators(self): """ Return a list of function to be run with certain classes @@ -47,9 +86,12 @@ def file_generators(self): """ return { - Trajectory: self.task_run_trajectory + Trajectory: self.run } + def add_output_type(self, name, filename=None, stride=1): + self.types[name] = OutputTypeDescription(filename, stride) + # ------------------------------------------------------------------------------ # FILE TYPES @@ -71,7 +113,9 @@ class Trajectory(File): the engine used to create the trajectory """ - engine = SyncVariable('engine', lambda x: not bool(x)) + _find_by = ['created', 'state', 'task', 'engine'] + + engine = ObjectSyncVariable('engine', 'generators', lambda x: not bool(x)) def __init__(self, location, frame, length, engine=None): super(Trajectory, self).__init__(location) @@ -104,12 +148,79 @@ def is_folder(self): return True def file(self, f): - return File(os.path.join(self.location, f)) + if isinstance(f, basestring): + return File(os.path.join(self.location, f)) + elif isinstance(f, OutputTypeDescription): + return self.file(f.filename) @property def restartable(self): return True + def run(self): + if self.engine: + return self.engine.run(self) + else: + return None + + def extend(self, length): + """ + Get a task to extend this trajectory if the engine is set + + Parameters + ---------- + length : int + the length to extend by + + Returns + ------- + `Task` + the task object + """ + if self.engine: + return self.engine.extend(self, length) + else: + return None + + def outputs(self, outtype): + """ + Get a location to the file containing the output by given name + + Parameters + ---------- + outtype : str ot `OutputTypeDescription` + + Returns + ------- + `File` + a file location that points to the concrete file that contains + the data for a particular output type + + """ + if self.engine: + if isinstance(outtype, basestring): + if outtype in self.engine.types: + return self.file(self.engine.types[outtype]) + elif isinstance(outtype, OutputTypeDescription): + return self.file(outtype) + + return None + + @property + def types(self): + """ + Return the OutputTypeDescriptions for this trajectory + Returns + ------- + dict str: `OutputTypeDescription` + the output description dict of the engine + + """ + if self.engine: + return self.engine.types + + return None + class Frame(StorableMixin): """ @@ -156,12 +267,24 @@ class TrajectoryGenerationTask(Task): 'trajectory' ] + def _default_success(self, scheduler): + super(TrajectoryGenerationTask, self)._default_success(scheduler) + + # # give the used engine the credit for making the trajectory + # for t in self.targets: + # if isinstance(t, Trajectory): + # t.engine = self.generator + def __init__(self, generator=None, trajectory=None): super(TrajectoryGenerationTask, self).__init__(generator) + + # set this engine to be run by this self.trajectory = trajectory + if trajectory: + trajectory.engine = self.generator def extend(self, length): - t = self.generator.task_extend_trajectory(self.trajectory, length) + t = self.generator.extend(self.trajectory, length) # this is not really necessary since we require internally that the source exists # but this will cause all dependencies to be submitted, too @@ -193,3 +316,14 @@ def ready(self): return False return True + + +class OutputTypeDescription(StorableMixin): + def __init__(self, filename=None, stride=1): + super(OutputTypeDescription, self).__init__() + + if filename is None: + filename = 'stride-%d.dcd' % stride + + self.filename = filename + self.stride = stride diff --git a/adaptivemd/engine/openmm/openmm.py b/adaptivemd/engine/openmm/openmm.py index 1da8c59..8011cee 100755 --- a/adaptivemd/engine/openmm/openmm.py +++ b/adaptivemd/engine/openmm/openmm.py @@ -1,6 +1,6 @@ import os +import ujson -from adaptivemd.task import PythonTask from adaptivemd.file import Location, File from adaptivemd.engine import Engine, Frame, Trajectory, \ TrajectoryGenerationTask, TrajectoryExtensionTask @@ -25,7 +25,7 @@ class OpenMMEngine(Engine): a list of arguments passed to the `openmmrun.py` script """ - def __init__(self, system_file, integrator_file, pdb_file, args=None, restartable=True): + def __init__(self, system_file, integrator_file, pdb_file, args=None, restartable=False): super(OpenMMEngine, self).__init__() self._items = dict() @@ -41,14 +41,24 @@ def __init__(self, system_file, integrator_file, pdb_file, args=None, restartabl self.initial_staging.append(stage) if args is None: - args = '-p CPU --store-interval 1' + args = '-p CPU' self.args = args self.restartable = restartable - @property - def call_format_str(self): - return 'python openmmrun.py %s {3} -t {0} --length {1} {2}' % self.args + @classmethod + def from_dict(cls, dct): + obj = super(OpenMMEngine, cls).from_dict(dct) + obj.args = dct['args'] + obj.restartable = dct['restartable'] + return obj + + def to_dict(self): + dct = super(OpenMMEngine, self).to_dict() + dct.update({ + 'restartable': self.restartable, + 'args': self.args}) + return dct @staticmethod def then_func_import(project, task, data, inputs): @@ -57,7 +67,14 @@ def then_func_import(project, task, data, inputs): if f not in project.files: project.files.update(f) - def task_run_trajectory(self, target): + def _create_output_str(self): + d = dict() + for name, opt in self.types.iteritems(): + d[name] = opt.to_dict() + + return '--types="%s"' % ujson.dumps(d).replace('"', "'") + + def run(self, target): t = TrajectoryGenerationTask(self, target) initial_pdb = t.link(self['pdb_file_stage'], Location('initial.pdb')) @@ -91,8 +108,9 @@ def task_run_trajectory(self, target): # create the directory t.touch(output) - cmd = 'python openmmrun.py {args} -t {pdb} --length {length} {output}'.format( + cmd = 'python openmmrun.py {args} {types} -t {pdb} --length {length} {output}'.format( pdb=input_pdb, + types=self._create_output_str(), length=target.length, output=output, args=self.args, @@ -103,7 +121,7 @@ def task_run_trajectory(self, target): return t - def task_extend_trajectory(self, source, length): + def extend(self, source, length): if length < 0: return [] @@ -157,16 +175,16 @@ def task_extend_trajectory(self, source, length): return t - def task_import_trajectory_folder(self, source): - t = PythonTask(self) - - t.link(self['pdb_file_stage'], Location('initial.pdb')) - t.call(scan_trajectories, source) - - # call `then_func_import` after success - t.then('then_func_import') - - return t + # def task_import_trajectory_folder(self, source): + # t = PythonTask(self) + # + # t.link(self['pdb_file_stage'], Location('initial.pdb')) + # t.call(scan_trajectories, source=source) + # + # # call `then_func_import` after success + # t.then('then_func_import') + # + # return t def scan_trajectories(source): diff --git a/adaptivemd/engine/openmm/openmmrun.py b/adaptivemd/engine/openmm/openmmrun.py index 4c175fc..85fb0c1 100755 --- a/adaptivemd/engine/openmm/openmmrun.py +++ b/adaptivemd/engine/openmm/openmmrun.py @@ -1,12 +1,12 @@ import argparse +import ujson +from sys import stdout, exit +import socket +import numpy as np from simtk.openmm.app import * from simtk.openmm import * import simtk.unit as u -from sys import stdout, exit -import os -import socket -import numpy as np if __name__ == '__main__': @@ -41,12 +41,12 @@ parser.add_argument( '--store-interval', dest='interval_store', - type=int, default=100, nargs='?', + type=int, default=1, nargs='?', help='store every nth interval') parser.add_argument( '--report-interval', dest='interval_report', - type=int, default=100, nargs='?', + type=int, default=1, nargs='?', help='report every nth interval') parser.add_argument( @@ -77,6 +77,11 @@ help='if set then text output is send to the ' + 'console.') + parser.add_argument( + '--types', dest='types', + type=str, default='', nargs='?', + help='alternative definition for output files and strides') + for p in platform_properties: for v in platform_properties[p]: p_name = (p + '_' + v) @@ -197,9 +202,25 @@ output = args.output - output_file = os.path.join(output, 'output.dcd') - simulation.reporters.append( - DCDReporter(output_file, args.interval_store)) + if args.types: + # seems like we have JSON + types_str = args.types.replace("'", '"') + print types_str + types = ujson.loads(types_str) + if isinstance(types, dict): + for name, opts in types.iteritems(): + if 'filename' in opts and 'stride' in opts: + output_file = os.path.join(output, opts['filename']) + simulation.reporters.append( + DCDReporter(output_file, opts['stride'])) + + print 'Writing stride %d to file `%s`' % (opts['stride'], opts['filename']) + + else: + # use defaults from arguments + output_file = os.path.join(output, 'output.dcd') + simulation.reporters.append( + DCDReporter(output_file, args.interval_store)) if args.report and args.verbose: simulation.reporters.append( diff --git a/adaptivemd/file.py b/adaptivemd/file.py index 68e8eb9..415263f 100755 --- a/adaptivemd/file.py +++ b/adaptivemd/file.py @@ -237,7 +237,7 @@ def __str__(self): class File(Location): - _find_by = ['created', 'state', '_file', 'task'] + _find_by = ['created', '_file', 'task'] created = SyncVariable('created', lambda x: x is not None and x < 0) _file = SyncVariable('_file', lambda x: not bool(x)) @@ -396,7 +396,7 @@ def set_file(self, content): class JSONFile(File): - _find_by = ['created', 'state', '_data'] + _find_by = ['created', '_data', 'task'] _data = JSONDataSyncVariable('_data', lambda x: not None) # _file = SyncVariable('_data', lambda x: not None) diff --git a/adaptivemd/generator.py b/adaptivemd/generator.py index 80d302b..68c4984 100755 --- a/adaptivemd/generator.py +++ b/adaptivemd/generator.py @@ -7,9 +7,8 @@ class TaskGenerator(StorableMixin): """ A generator for `Task` objects """ - def __init__(self, args=None): + def __init__(self): super(TaskGenerator, self).__init__() - self.args = args self._items = dict() self.initial_staging = [] @@ -28,14 +27,12 @@ def from_dict(cls, dct): StorableMixin.__init__(obj) obj._items = dct['_items'] obj.initial_staging = dct['initial_staging'] - obj.args = dct['args'] return obj def to_dict(self): return { '_items': self._items, - 'initial_staging': self.initial_staging, - 'args': self.args + 'initial_staging': self.initial_staging } @property diff --git a/adaptivemd/mongodb/dictify.py b/adaptivemd/mongodb/dictify.py index 3b38cbd..fac8453 100755 --- a/adaptivemd/mongodb/dictify.py +++ b/adaptivemd/mongodb/dictify.py @@ -532,7 +532,7 @@ def to_simple_dict(self, obj, base_type=''): for key in obj._find_by: if hasattr(obj, key): - dct[key] = getattr(obj, key) + dct[key] = self.simplify(getattr(obj, key)) return dct diff --git a/adaptivemd/mongodb/syncvar.py b/adaptivemd/mongodb/syncvar.py index a064a31..e789b33 100644 --- a/adaptivemd/mongodb/syncvar.py +++ b/adaptivemd/mongodb/syncvar.py @@ -16,6 +16,9 @@ def __init__(self, name, fix_fnc=None): def _idx(self, instance): return str(uuid.UUID(int=instance.__uuid__)) + def _hex(self, instance): + return hex(instance.__uuid__) + def _update(self, store, idx): if store is not None: return store._document.find_one( @@ -129,7 +132,7 @@ def _update(self, store, idx): if data is None: return None else: - obj_idx = int(uuid.UUID(data['_hex_uuid'])) + obj_idx = long(data['_hex_uuid'], 16) return getattr(store.storage, self.store).load(obj_idx) def __set__(self, instance, value): @@ -144,7 +147,7 @@ def __set__(self, instance, value): instance.__store__._document.find_and_modify( query={'_id': idx}, update={"$set": {self.name: { - '_hex_uuid': self._idx(value), + '_hex_uuid': self._hex(value), '_store': self.store}}}, upsert=False ) diff --git a/adaptivemd/tests/test_simple.py b/adaptivemd/tests/test_simple.py index eeebd72..b400726 100755 --- a/adaptivemd/tests/test_simple.py +++ b/adaptivemd/tests/test_simple.py @@ -59,7 +59,7 @@ # -------------------------------------------------------------------------- trajectory = project.new_trajectory(engine['pdb_file'], 100, restart=True) - task = engine.task_run_trajectory(trajectory) + task = engine.run(trajectory) # project.queue(task) diff --git a/examples/ntl9/adaptive.py b/examples/ntl9/adaptive.py index 8215037..f1d4c9f 100755 --- a/examples/ntl9/adaptive.py +++ b/examples/ntl9/adaptive.py @@ -79,7 +79,7 @@ def task_generator(): return [ - engine.task_run_trajectory(traj) for traj in + engine.run(traj) for traj in project.new_ml_trajectory(100, 2)] diff --git a/examples/ntl9/setup.py b/examples/ntl9/setup.py index da984bd..074626c 100755 --- a/examples/ntl9/setup.py +++ b/examples/ntl9/setup.py @@ -77,7 +77,7 @@ def task_generator(): return [ - engine.task_run_trajectory(traj) for traj in + engine.run(traj) for traj in scheduler.new_ml_trajectory(100, 2)] scheduler.add_event( diff --git a/examples/rp/test_4cuda.py b/examples/rp/test_4cuda.py index 8ee9aae..864cd6b 100755 --- a/examples/rp/test_4cuda.py +++ b/examples/rp/test_4cuda.py @@ -87,7 +87,7 @@ # print scheduler.resource.resource trajectories = project.new_trajectory(engine['pdb_file'], 100, 4) - task = engine.task_run_trajectory(trajectories) + task = engine.run(trajectories) scheduler(task) diff --git a/examples/rp/test_adaptive.py b/examples/rp/test_adaptive.py index 0b4df32..fa71080 100755 --- a/examples/rp/test_adaptive.py +++ b/examples/rp/test_adaptive.py @@ -75,7 +75,7 @@ # create 4 blocks a 4 trajectories trajectories = [project.new_trajectory(engine['pdb_file'], 100, 4) for _ in range(4)] - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) print trajectories @@ -92,7 +92,7 @@ for loop in range(2): trajectories = [project.new_ml_trajectory(length=100, number=4) for _ in range(4)] print trajectories - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) finals = scheduler(tasks) scheduler.wait() diff --git a/examples/rp/test_asyncGPU.py b/examples/rp/test_asyncGPU.py index b8c073f..bd07f7a 100755 --- a/examples/rp/test_asyncGPU.py +++ b/examples/rp/test_asyncGPU.py @@ -86,7 +86,7 @@ def strategy_trajectory(scheduler, loops, num): for loop in range(loops): trajectories = [project.new_ml_trajectory(length=20, number=4) for _ in range(num)] - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) tasklist = scheduler(tasks) yield tasklist.is_done() diff --git a/examples/rp/test_setconda.py b/examples/rp/test_setconda.py index 55f5cd6..d72df60 100755 --- a/examples/rp/test_setconda.py +++ b/examples/rp/test_setconda.py @@ -73,7 +73,7 @@ scheduler = project.get_scheduler(cores=1) trajectory = project.new_trajectory(engine['pdb_file'], 100) - task = engine.task_run_trajectory(trajectory) + task = engine.run(trajectory) scheduler(task) diff --git a/examples/rp/test_simple.py b/examples/rp/test_simple.py index cbbd7c8..2447519 100755 --- a/examples/rp/test_simple.py +++ b/examples/rp/test_simple.py @@ -85,7 +85,7 @@ scheduler = project.get_scheduler(cores=1) trajectory = project.new_trajectory(engine['pdb_file'], 100) - task = engine.task_run_trajectory(trajectory) + task = engine.run(trajectory) scheduler(task) diff --git a/examples/rp/test_worker_allegro_asyncCPU.py b/examples/rp/test_worker_allegro_asyncCPU.py index b7f4432..49b6720 100755 --- a/examples/rp/test_worker_allegro_asyncCPU.py +++ b/examples/rp/test_worker_allegro_asyncCPU.py @@ -76,14 +76,14 @@ # create 4 trajectories trajectories = project.new_trajectory(pdb_file, 100, 4) - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) map(project.tasks.add, tasks) # now start adaptive loop def strategy_trajectory(loops, num): for loop in range(loops): trajectories = project.new_ml_trajectory(20, number=num) - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) map(project.tasks.add, tasks) yield [t.is_done for t in tasks] diff --git a/examples/rp/test_worker_asyncCPU.py b/examples/rp/test_worker_asyncCPU.py index 4078e27..756015f 100755 --- a/examples/rp/test_worker_asyncCPU.py +++ b/examples/rp/test_worker_asyncCPU.py @@ -76,14 +76,14 @@ # create 4 trajectories trajectories = project.new_trajectory(pdb_file, 100, 4) - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) map(project.tasks.add, tasks) # now start adaptive loop def strategy_trajectory(loops, num): for loop in range(loops): trajectories = project.new_ml_trajectory(20, number=num) - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) map(project.tasks.add, tasks) yield [t.is_done for t in tasks] diff --git a/examples/tutorial/1_example_setup_project.ipynb b/examples/tutorial/1_example_setup_project.ipynb index 96c568f..1cb16a6 100755 --- a/examples/tutorial/1_example_setup_project.ipynb +++ b/examples/tutorial/1_example_setup_project.ipynb @@ -151,7 +151,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 7, @@ -585,11 +585,11 @@ "cell_type": "code", "execution_count": 22, "metadata": { - "collapsed": true + "collapsed": false }, "outputs": [], "source": [ - "task = engine.task_run_trajectory(trajectory)" + "task = engine.run(trajectory)" ] }, { @@ -653,8 +653,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "\n", - "\n" + "\n", + "\n" ] } ], diff --git a/examples/tutorial/2_example_run.ipynb b/examples/tutorial/2_example_run.ipynb index 9fc9e01..ee37053 100755 --- a/examples/tutorial/2_example_run.ipynb +++ b/examples/tutorial/2_example_run.ipynb @@ -81,9 +81,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "\n", - "\n", - "\n" + "\n", + "\n", + "\n" ] } ], @@ -191,7 +191,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "metadata": { "collapsed": false }, @@ -235,15 +235,62 @@ "##### The `Task` object" ] }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "{'_items': {'_executable_file': 'openmmrun.py',\n", + " '_executable_file_stage': 'openmmrun.py',\n", + " 'integrator_file': 'integrator.xml',\n", + " 'integrator_file_stage': 'integrator.xml',\n", + " 'pdb_file': 'alanine.pdb',\n", + " 'pdb_file_stage': 'alanine.pdb',\n", + " 'system_file': 'system.xml',\n", + " 'system_file_stage': 'system.xml'},\n", + " 'initial_staging': [Transfer('file://{}/openmmrun.py' > 'staging:///openmmrun.py),\n", + " Transfer('file://{}/alanine.pdb' > 'staging:///alanine.pdb),\n", + " Transfer('file://{}/integrator.xml' > 'staging:///integrator.xml),\n", + " Transfer('file://{}/system.xml' > 'staging:///system.xml)]}" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "engine.to_dict()" + ] + }, { "cell_type": "code", "execution_count": 9, "metadata": { - "collapsed": true + "collapsed": false }, - "outputs": [], + "outputs": [ + { + "ename": "AttributeError", + "evalue": "'OpenMMEngine' object has no attribute 'types'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtask_run\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mengine\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrajectory\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/Users/jan-hendrikprinz/Studium/git/adaptivemd/adaptivemd/engine/openmm/openmm.pyc\u001b[0m in \u001b[0;36mrun\u001b[0;34m(self, target)\u001b[0m\n\u001b[1;32m 98\u001b[0m cmd = 'python openmmrun.py {args} {types} -t {pdb} --length {length} {output}'.format(\n\u001b[1;32m 99\u001b[0m \u001b[0mpdb\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0minput_pdb\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 100\u001b[0;31m \u001b[0mtypes\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_create_output_str\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 101\u001b[0m \u001b[0mlength\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mtarget\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlength\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 102\u001b[0m \u001b[0moutput\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0moutput\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/Users/jan-hendrikprinz/Studium/git/adaptivemd/adaptivemd/engine/openmm/openmm.pyc\u001b[0m in \u001b[0;36m_create_output_str\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 57\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m_create_output_str\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[0md\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 59\u001b[0;31m \u001b[0;32mfor\u001b[0m \u001b[0mname\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mopt\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtypes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0miteritems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 60\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mopt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_dict\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 61\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mAttributeError\u001b[0m: 'OpenMMEngine' object has no attribute 'types'" + ] + } + ], "source": [ - "task_run = engine.task_run_trajectory(trajectory)" + "task_run = engine.run(trajectory)" ] }, { diff --git a/examples/tutorial/test_4cuda.py b/examples/tutorial/test_4cuda.py index b92ed63..9b5fe7c 100755 --- a/examples/tutorial/test_4cuda.py +++ b/examples/tutorial/test_4cuda.py @@ -49,7 +49,7 @@ # print scheduler.resource.resource trajectories = project.new_trajectory(engine['pdb_file'], 100, 4) - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) project.queue(tasks) diff --git a/examples/tutorial/test_adaptive.py b/examples/tutorial/test_adaptive.py index 0b4df32..fa71080 100755 --- a/examples/tutorial/test_adaptive.py +++ b/examples/tutorial/test_adaptive.py @@ -75,7 +75,7 @@ # create 4 blocks a 4 trajectories trajectories = [project.new_trajectory(engine['pdb_file'], 100, 4) for _ in range(4)] - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) print trajectories @@ -92,7 +92,7 @@ for loop in range(2): trajectories = [project.new_ml_trajectory(length=100, number=4) for _ in range(4)] print trajectories - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) finals = scheduler(tasks) scheduler.wait() diff --git a/examples/tutorial/test_asyncGPU.py b/examples/tutorial/test_asyncGPU.py index b8c073f..bd07f7a 100755 --- a/examples/tutorial/test_asyncGPU.py +++ b/examples/tutorial/test_asyncGPU.py @@ -86,7 +86,7 @@ def strategy_trajectory(scheduler, loops, num): for loop in range(loops): trajectories = [project.new_ml_trajectory(length=20, number=4) for _ in range(num)] - tasks = map(engine.task_run_trajectory, trajectories) + tasks = map(engine.run, trajectories) tasklist = scheduler(tasks) yield tasklist.is_done() diff --git a/examples/tutorial/test_setconda.py b/examples/tutorial/test_setconda.py index 55f5cd6..d72df60 100755 --- a/examples/tutorial/test_setconda.py +++ b/examples/tutorial/test_setconda.py @@ -73,7 +73,7 @@ scheduler = project.get_scheduler(cores=1) trajectory = project.new_trajectory(engine['pdb_file'], 100) - task = engine.task_run_trajectory(trajectory) + task = engine.run(trajectory) scheduler(task)