diff --git a/fireworks/core/launchpad.py b/fireworks/core/launchpad.py index 02a9fb43b..c43a343dd 100644 --- a/fireworks/core/launchpad.py +++ b/fireworks/core/launchpad.py @@ -189,11 +189,11 @@ def __init__( # set up logger self.logdir = logdir - self.strm_lvl = strm_lvl or "INFO" + self.strm_lvl = strm_lvl if strm_lvl else "INFO" self.m_logger = get_fw_logger("launchpad", l_dir=self.logdir, stream_level=self.strm_lvl) - self.user_indices = user_indices or [] - self.wf_user_indices = wf_user_indices or [] + self.user_indices = user_indices if user_indices else [] + self.wf_user_indices = wf_user_indices if wf_user_indices else [] # get connection if uri_mode: @@ -344,7 +344,7 @@ def maintain(self, infinite=True, maintain_interval=None) -> None: infinite (bool) maintain_interval (seconds): sleep time """ - maintain_interval = maintain_interval or MAINTAIN_INTERVAL + maintain_interval = maintain_interval if maintain_interval else MAINTAIN_INTERVAL while True: self.m_logger.info("Performing maintenance on Launchpad...") @@ -729,7 +729,7 @@ def get_fw_ids(self, query=None, sort=None, limit=0, count_only=False, launches_ list: list of firework ids matching the query """ coll = "launches" if launches_mode else "fireworks" - criteria = query or {} + criteria = query if query else {} if launches_mode: lids = self._get_active_launch_ids() criteria["launch_id"] = {"$in": lids} @@ -775,7 +775,7 @@ def get_wf_ids(self, query=None, sort=None, limit=0, count_only=False): Returns: list: list of firework ids """ - criteria = query or {} + criteria = query if query else {} aggregation = [] if criteria is not None: @@ -898,7 +898,7 @@ def future_run_exists(self, fworker=None) -> bool: return True # retrieve all [RUNNING/RESERVED] fireworks q = fworker.query if fworker else {} - q.update(state={"$in": ["RUNNING", "RESERVED"]}) + q.update({"state": {"$in": ["RUNNING", "RESERVED"]}}) active = self.get_fw_ids(q) # then check if they have WAITING children for fw_id in active: @@ -1670,7 +1670,7 @@ def rerun_fw(self, fw_id, rerun_duplicates=True, recover_launch=None, recover_mo # Launch recovery if recover_launch is not None: recovery = self.get_recovery(fw_id, recover_launch) - recovery.update(_mode=recover_mode) + recovery.update({"_mode": recover_mode}) set_spec = recursive_dict({"$set": {"spec._recovery": recovery}}) if recover_mode == "prev_dir": prev_dir = self.get_launch_by_id(recovery.get("_launch_id")).launch_dir @@ -1714,7 +1714,7 @@ def get_recovery(self, fw_id, launch_id="last"): m_fw = self.get_fw_by_id(fw_id) launch = m_fw.launches[-1] if launch_id == "last" else self.get_launch_by_id(launch_id) recovery = launch.state_history[-1].get("checkpoint") - recovery.update(_prev_dir=launch.launch_dir, _launch_id=launch.launch_id) + recovery.update({"_prev_dir": launch.launch_dir, "_launch_id": launch.launch_id}) return recovery def _refresh_wf(self, fw_id) -> None: