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 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