Skip to content

Commit

Permalink
refactor: Add _add_provenance method to TaskWorker class
Browse files Browse the repository at this point in the history
  • Loading branch information
provos committed Sep 12, 2024
1 parent cc2dd8d commit d6d4648
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/planai/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ def consume_work(self, task: Task):
"""
pass

def _add_provenance(self, task: Task) -> Task:
with self._state_lock:
self._id += 1
task._provenance.append((self.name, self._id))
return task

def publish_work(self, task: Task, input_task: Optional[Task]):
"""
Publish a work item.
Expand Down Expand Up @@ -398,10 +404,8 @@ def publish_work(self, task: Task, input_task: Optional[Task]):
task._provenance = []
task._input_provenance = []

with self._state_lock:
self._id += 1
self._add_provenance(task)

task._provenance.append((self.name, self._id))
logging.info(
"Task %s published work with provenance %s", self.name, task._provenance
)
Expand Down

0 comments on commit d6d4648

Please sign in to comment.