From e44a139ccce391e0b6d2d89627aebede478f6443 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Prinz Date: Fri, 10 Mar 2017 13:53:30 +0100 Subject: [PATCH 1/2] faster build script --- devtools/build_conda.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devtools/build_conda.sh b/devtools/build_conda.sh index e787b57..a1cf78d 100755 --- a/devtools/build_conda.sh +++ b/devtools/build_conda.sh @@ -9,7 +9,9 @@ BUILD_PATH=~/anaconda/conda-bld BUILD_OS=osx-64 # install conda-build -conda install --yes conda-build +if conda list | grep conda-build ; then + conda install --yes conda-build +fi # build the conda package conda build conda-recipe From d3edb1a5e57e378fd9627e13e5664dd8a8bde173 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Prinz Date: Fri, 10 Mar 2017 14:12:57 +0100 Subject: [PATCH 2/2] strategy idea --- adaptivemd/__init__.py | 2 +- adaptivemd/event.py | 12 ++++++++++++ adaptivemd/strategy.py | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 adaptivemd/strategy.py diff --git a/adaptivemd/__init__.py b/adaptivemd/__init__.py index d52a3d0..314ec14 100755 --- a/adaptivemd/__init__.py +++ b/adaptivemd/__init__.py @@ -1,5 +1,5 @@ from brain import Brain -from event import StopEvent, Event, TasksFinished, FunctionalEvent +from event import StopEvent, Event, TasksFinished, FunctionalEvent, event from condition import Condition, Now, Never from file import File, Copy, Link, Move, Remove, Transfer, Directory, AddPathAction, Location from bundle import Bundle, SortedBundle, ViewBundle diff --git a/adaptivemd/event.py b/adaptivemd/event.py index 9e5c171..7c82c6e 100755 --- a/adaptivemd/event.py +++ b/adaptivemd/event.py @@ -4,6 +4,8 @@ from itertools import chain from task import Task +import functools + class Event(object): """ @@ -298,3 +300,13 @@ class StopEvent(Event): """ def __call__(self, scheduler): return StopIteration + + +# decorator @event to convert a generator function into an callable event + +def event(fnc): + @functools.wraps(fnc) + def _wrapper(*args, **kwargs): + return FunctionalEvent(fnc(*args, **kwargs)) + + return _wrapper diff --git a/adaptivemd/strategy.py b/adaptivemd/strategy.py new file mode 100644 index 0000000..9d6a28d --- /dev/null +++ b/adaptivemd/strategy.py @@ -0,0 +1,14 @@ +from mongodb import StorableMixin +from event import event + + +class Strategy(StorableMixin): + def __init__(self): + super(Strategy, self).__init__() + + def __call__(self, project): + project.add_event(self.default(project)) + + @event + def default(self, project): + pass