From c663e3d01230712bbd589b1d5a81c8b20767f563 Mon Sep 17 00:00:00 2001 From: Matthew Evans Date: Wed, 11 Oct 2023 14:13:26 +0100 Subject: [PATCH] Run linting with new black rules and fix warnings stacklevel warning --- src/jobflow_remote/cli/flow.py | 1 - src/jobflow_remote/cli/formatting.py | 1 - src/jobflow_remote/cli/job.py | 1 - src/jobflow_remote/cli/utils.py | 1 - src/jobflow_remote/config/settings.py | 1 - src/jobflow_remote/fireworks/launcher.py | 1 - src/jobflow_remote/fireworks/launchpad.py | 3 --- src/jobflow_remote/jobs/daemon.py | 1 - src/jobflow_remote/jobs/jobcontroller.py | 2 -- src/jobflow_remote/remote/data.py | 1 - src/jobflow_remote/utils/db.py | 6 ++---- 11 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/jobflow_remote/cli/flow.py b/src/jobflow_remote/cli/flow.py index a13a2a6e..3ba4b0f6 100644 --- a/src/jobflow_remote/cli/flow.py +++ b/src/jobflow_remote/cli/flow.py @@ -171,7 +171,6 @@ def flow_info( flow_ids = [jf_id] with loading_spinner(): - jc = JobController() flows_info = jc.get_flows_info( diff --git a/src/jobflow_remote/cli/formatting.py b/src/jobflow_remote/cli/formatting.py index 7f942481..2b9fcf72 100644 --- a/src/jobflow_remote/cli/formatting.py +++ b/src/jobflow_remote/cli/formatting.py @@ -142,7 +142,6 @@ def format_job_info(job_info: JobInfo, show_none: bool = False): def format_flow_info(flow_info: FlowInfo): - title = f"Flow: {flow_info.name} - {flow_info.flow_id} - {flow_info.state.name}" table = Table(title=title) table.title_style = "bold" diff --git a/src/jobflow_remote/cli/job.py b/src/jobflow_remote/cli/job.py index 07f35780..9b215db1 100644 --- a/src/jobflow_remote/cli/job.py +++ b/src/jobflow_remote/cli/job.py @@ -159,7 +159,6 @@ def job_info( db_id, job_id = get_job_db_ids(job_db_id, job_index) with loading_spinner(): - jc = JobController() job_info = jc.get_job_info( diff --git a/src/jobflow_remote/cli/utils.py b/src/jobflow_remote/cli/utils.py index 355d0a03..ca250628 100644 --- a/src/jobflow_remote/cli/utils.py +++ b/src/jobflow_remote/cli/utils.py @@ -205,7 +205,6 @@ def convert_metadata(string_metadata: str | None) -> dict | None: def get_start_date(start_date: datetime | None, days: int | None, hours: int | None): - if start_date and (start_date.year, start_date.month, start_date.day) == ( 1900, 1, diff --git a/src/jobflow_remote/config/settings.py b/src/jobflow_remote/config/settings.py index 4b0610b1..82096b1c 100644 --- a/src/jobflow_remote/config/settings.py +++ b/src/jobflow_remote/config/settings.py @@ -10,7 +10,6 @@ class JobflowRemoteSettings(BaseSettings): - config_file: str = Field( DEFAULT_CONFIG_FILE_PATH, description="Location of the config file for jobflow remote.", diff --git a/src/jobflow_remote/fireworks/launcher.py b/src/jobflow_remote/fireworks/launcher.py index 0da92980..a666b0ec 100644 --- a/src/jobflow_remote/fireworks/launcher.py +++ b/src/jobflow_remote/fireworks/launcher.py @@ -32,7 +32,6 @@ def checkout_remote( launch_id = None try: - fw, launch_id = rlpad.lpad.reserve_fw(fworker, ".", fw_id=fw_id) if not fw: logger.info("No jobs exist in the LaunchPad for submission to queue!") diff --git a/src/jobflow_remote/fireworks/launchpad.py b/src/jobflow_remote/fireworks/launchpad.py index 2ae68c9a..8536ae1e 100644 --- a/src/jobflow_remote/fireworks/launchpad.py +++ b/src/jobflow_remote/fireworks/launchpad.py @@ -610,7 +610,6 @@ def get_remote_run( job_id: str | None = None, job_index: int | None = None, ) -> RemoteRun: - query, sort = self.generate_id_query(fw_id, job_id, job_index) fw = self.fireworks.find_one(query) @@ -697,7 +696,6 @@ def get_wf_fw_data( sort: dict | None = None, limit: int = 0, ) -> list[dict]: - pipeline: list[dict] = [ { "$lookup": { @@ -767,7 +765,6 @@ def get_fw_launch_remote_run_data( sort: dict | None = None, limit: int = 0, ) -> list[dict]: - # only take the most recent launch pipeline: list[dict] = [ { diff --git a/src/jobflow_remote/jobs/daemon.py b/src/jobflow_remote/jobs/daemon.py index 838746f6..32c1e6eb 100644 --- a/src/jobflow_remote/jobs/daemon.py +++ b/src/jobflow_remote/jobs/daemon.py @@ -58,7 +58,6 @@ class DaemonStatus(Enum): class DaemonManager: - conf_template = Template(supervisord_conf_str) def __init__( diff --git a/src/jobflow_remote/jobs/jobcontroller.py b/src/jobflow_remote/jobs/jobcontroller.py index 3740092e..8596a373 100644 --- a/src/jobflow_remote/jobs/jobcontroller.py +++ b/src/jobflow_remote/jobs/jobcontroller.py @@ -147,7 +147,6 @@ def _build_query_wf( end_date: datetime | None = None, name: str | None = None, ) -> dict: - if job_ids is not None and not isinstance(job_ids, (list, tuple)): job_ids = [job_ids] if db_ids is not None and not isinstance(db_ids, (list, tuple)): @@ -391,7 +390,6 @@ def rerun_jobs( return fw_ids def reset(self, reset_output: bool = False, max_limit: int = 25) -> bool: - password = datetime.now().strftime("%Y-%m-%d") if max_limit == 0 else None try: self.rlpad.reset( diff --git a/src/jobflow_remote/remote/data.py b/src/jobflow_remote/remote/data.py index 65d5e53d..9945a259 100644 --- a/src/jobflow_remote/remote/data.py +++ b/src/jobflow_remote/remote/data.py @@ -76,7 +76,6 @@ def get_remote_store_filenames(store: JobStore) -> list[str]: def update_store(store, remote_store, save): - # TODO is it correct? data = list(remote_store.query(load=save)) if len(data) > 1: diff --git a/src/jobflow_remote/utils/db.py b/src/jobflow_remote/utils/db.py index cc1a46ca..c1025dbc 100644 --- a/src/jobflow_remote/utils/db.py +++ b/src/jobflow_remote/utils/db.py @@ -12,7 +12,6 @@ class MongoLock: - LOCK_KEY = "_lock_id" LOCK_TIME_KEY = "_lock_time" @@ -98,7 +97,7 @@ def acquire(self): msg = ( f"The lock was broken. Previous lock id: {self.get_lock_id(result)}" ) - warnings.warn(msg) + warnings.warn(msg, stacklevel=2) self.locked_document = result @@ -119,7 +118,7 @@ def release(self, exc_type, exc_val, exc_tb): # Check if the lock was successfully released if result.modified_count == 0: msg = f"Could not release lock for document {self.locked_document['_id']}" - warnings.warn(msg) + warnings.warn(msg, stacklevel=2) self.locked_document = None @@ -128,6 +127,5 @@ def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): - if self.locked_document: self.release(exc_type, exc_val, exc_tb)