Skip to content

Commit

Permalink
code styling: remove nested logic in engine queue
Browse files Browse the repository at this point in the history
  • Loading branch information
leaexplores authored and isra17 committed May 7, 2024
1 parent 5cc26c3 commit 50f2d6a
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/saturn_engine/models/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,24 @@ def queue_item(self) -> QueueItemWithState:
return self._queue_item

def join_definitions(self, static_definitions: StaticDefinitions) -> None:
if self.job:
state = QueueItemState(
cursor=Cursor(self.job.cursor) if self.job.cursor else None,
started_at=self.job.started_at,
)
if self.job.job_definition_name is not None:
self._queue_item = dataclasses.replace(
static_definitions.job_definitions[
self.job.job_definition_name
].template,
name=JobId(self.name),
).with_state(state)
else:
self._queue_item = dataclasses.replace(
static_definitions.jobs[self.job.name],
name=JobId(self.name),
).with_state(state)
else:
if not self.job:
self._queue_item = dataclasses.replace(
static_definitions.jobs[self.job.name],
name=JobId(self.name),
).with_state(state)
return

if self.job.job_definition_name is None:
raise NotImplementedError("Only support Job queue")

state = QueueItemState(
cursor=Cursor(self.job.cursor) if self.job.cursor else None,
started_at=self.job.started_at,
)

self._queue_item = dataclasses.replace(
static_definitions.job_definitions[
self.job.job_definition_name
].template,
name=JobId(self.name),
).with_state(state)

0 comments on commit 50f2d6a

Please sign in to comment.