-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve ergonomics of call and spawn
- Loading branch information
1 parent
5eaa349
commit cd80edb
Showing
10 changed files
with
89 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
models_by_id = {} | ||
|
||
_current_context = [None, None] | ||
_current_context = [None, None, None] | ||
|
||
next_cell_id = 0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,18 @@ | ||
class TaskInstance: | ||
def __init__(self, func, kwargs, model, validations, definition): | ||
""" | ||
A TaskInstance is just a lambda with extra steps | ||
""" | ||
def __init__(self, func): | ||
self.func = func | ||
self.args = kwargs | ||
self.model = model | ||
self.validations = validations # | ||
self.definition = definition | ||
# self.kwargs = kwargs | ||
|
||
def instantiate(self): | ||
if self.model is None: | ||
return self.func(**self.args) #, **self.kwargs) | ||
else: | ||
return self.func(self.model, **self.args) # , **self.kwargs) | ||
# def validate(self): | ||
# return [ | ||
# validation(self.args) | ||
# for validation in self.validations | ||
# ] | ||
|
||
def validate(self): | ||
return [ | ||
validation(self.args) | ||
for validation in self.validations | ||
] | ||
# def __repr__(self): | ||
# return self.repr | ||
|
||
def __repr__(self): | ||
return f"{self.definition.name}({', '.join(f'{k}={v}' for k, v in self.args.items())})" | ||
|
||
def __call__(self, *args, **kwargs): | ||
return self.instantiate() | ||
def run(self): | ||
return self.func() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters