Skip to content

Commit

Permalink
Done method before execute overridable closes runprism#29
Browse files Browse the repository at this point in the history
  • Loading branch information
NotNullBool committed Aug 13, 2023
1 parent 73b2496 commit 7b6f31f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions prism/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ def set_task_manager(self, task_manager: prism.infra.task_manager.PrismTaskManag
def set_hooks(self, hooks: prism.infra.hooks.PrismHooks):
self.hooks = hooks

def _done(self, hooks: prism.infra.hooks.PrismHooks) -> bool:
"""
A protected method meant to be overrided by sub classes. Will be called
automatically at the begin of exec()
"""
return True


def exec(self):

# If the `target` decorator isn't applied, then only execute the `run` function
Expand All @@ -63,6 +71,7 @@ def exec(self):
# If bool_run, then execute the `run` function and set the `output`
# attribute to its result
if self.bool_run:
self._done(self.hooks) #call done method
self.output = self.run(self.task_manager, self.hooks)
if self.output is None:
raise prism.exceptions.RuntimeException(
Expand Down

0 comments on commit 7b6f31f

Please sign in to comment.