Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Strategy class #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion adaptivemd/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions adaptivemd/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from itertools import chain
from task import Task

import functools


class Event(object):
"""
Expand Down Expand Up @@ -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
14 changes: 14 additions & 0 deletions adaptivemd/strategy.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion devtools/build_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down