Skip to content

Commit

Permalink
try revert Firework
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Apr 26, 2024
1 parent 711d4ac commit 14ca013
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions fireworks/core/firework.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ def __init__(
not only to direct children, but to all dependent FireWorks
down to the Workflow's leaves.
"""
mod_spec = mod_spec or []
additions = additions or []
detours = detours or []
mod_spec = mod_spec if mod_spec is not None else []
additions = additions if additions is not None else []
detours = detours if detours is not None else []

self.stored_data = stored_data or {}
self.stored_data = stored_data if stored_data else {}
self.exit = exit
self.update_spec = update_spec or {}
self.update_spec = update_spec if update_spec else {}
self.mod_spec = mod_spec if isinstance(mod_spec, (list, tuple)) else [mod_spec]
self.additions = additions if isinstance(additions, (list, tuple)) else [additions]
self.detours = detours if isinstance(detours, (list, tuple)) else [detours]
Expand Down Expand Up @@ -267,13 +267,13 @@ def __init__(
NEGATIVE_FWID_CTR -= 1
self.fw_id = NEGATIVE_FWID_CTR

self.launches = launches or []
self.archived_launches = archived_launches or []
self.launches = launches if launches else []
self.archived_launches = archived_launches if archived_launches else []
self.created_on = created_on or datetime.utcnow()
self.updated_on = updated_on or datetime.utcnow()

parents = [parents] if isinstance(parents, Firework) else parents
self.parents = parents or []
self.parents = parents if parents else []

self._state = state

Expand Down Expand Up @@ -476,9 +476,9 @@ def __init__(
self.fworker = fworker or FWorker()
self.host = host or get_my_host()
self.ip = ip or get_my_ip()
self.trackers = trackers or []
self.action = action or None
self.state_history = state_history or []
self.trackers = trackers if trackers else []
self.action = action if action else None
self.state_history = state_history if state_history else []
self.state = state
self.launch_id = launch_id
self.fw_id = fw_id
Expand Down Expand Up @@ -579,7 +579,7 @@ def reservedtime_secs(self):
"""
start = self.time_reserved
if start:
end = self.time_start or datetime.utcnow()
end = self.time_start if self.time_start else datetime.utcnow()
return (end - start).total_seconds()
return None

Expand Down Expand Up @@ -643,7 +643,7 @@ def _update_state_history(self, state) -> None:
now_time = datetime.utcnow()
new_history_entry = {"state": state, "created_on": now_time}
if state != "COMPLETED" and last_checkpoint:
new_history_entry.update(checkpoint=last_checkpoint)
new_history_entry.update({"checkpoint": last_checkpoint})
self.state_history.append(new_history_entry)
if state in ["RUNNING", "RESERVED"]:
self.touch_history() # add updated_on key
Expand Down Expand Up @@ -986,7 +986,7 @@ def rerun_fw(self, fw_id, updated_ids=None):
Returns:
list[int]: list of Firework ids that were updated.
"""
updated_ids = updated_ids or set()
updated_ids = updated_ids if updated_ids else set()
m_fw = self.id_fw[fw_id]
m_fw._rerun()
updated_ids.add(fw_id)
Expand Down Expand Up @@ -1089,7 +1089,7 @@ def refresh(self, fw_id, updated_ids=None):
set(int): list of Firework ids that were updated
"""
# these are the fw_ids to re-enter into the database
updated_ids = updated_ids or set()
updated_ids = updated_ids if updated_ids else set()

fw = self.id_fw[fw_id]
prev_state = fw.state
Expand Down Expand Up @@ -1346,7 +1346,7 @@ def from_firework(cls, fw: Firework, name: str | None = None, metadata=None) ->
Returns:
Workflow
"""
name = name or fw.name
name = name if name else fw.name
return Workflow([fw], None, name=name, metadata=metadata, created_on=fw.created_on, updated_on=fw.updated_on)

def __str__(self) -> str:
Expand Down

0 comments on commit 14ca013

Please sign in to comment.