From de3a483d8b6600483279e1ebc8f3ea21270a8733 Mon Sep 17 00:00:00 2001 From: ltenorio Date: Thu, 5 Sep 2024 16:12:35 +0200 Subject: [PATCH 1/8] fix bare-except E722 --- autosubmit_api/common/utils.py | 6 +++--- .../components/experiment/configuration_facade.py | 4 ++-- autosubmit_api/components/jobs/joblist_helper.py | 2 +- autosubmit_api/components/jobs/joblist_loader.py | 4 ++-- autosubmit_api/components/jobs/utils.py | 2 +- autosubmit_api/config/ymlConfigStrategy.py | 2 +- autosubmit_api/database/db_jobdata.py | 2 +- autosubmit_api/database/db_structure.py | 2 +- autosubmit_api/logger.py | 2 +- autosubmit_api/views/v4.py | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/autosubmit_api/common/utils.py b/autosubmit_api/common/utils.py index 416fc9a..cf544a5 100644 --- a/autosubmit_api/common/utils.py +++ b/autosubmit_api/common/utils.py @@ -46,10 +46,10 @@ def tostamp(string_date: str) -> int: if string_date and len(string_date) > 0: try: timestamp_value = int(time.mktime(datetime.datetime.strptime(string_date,"%Y-%m-%d %H:%M:%S").timetuple())) - except: + except Exception: try: timestamp_value = int(time.mktime(datetime.datetime.strptime(string_date,"%Y-%m-%d-%H:%M:%S").timetuple())) - except: + except Exception: pass return timestamp_value @@ -66,7 +66,7 @@ def parse_number_processors(processors_str: str) -> int: try: processors = int(processors_str) return processors - except: + except Exception: return 1 diff --git a/autosubmit_api/components/experiment/configuration_facade.py b/autosubmit_api/components/experiment/configuration_facade.py index 9f0b602..ba64f16 100644 --- a/autosubmit_api/components/experiment/configuration_facade.py +++ b/autosubmit_api/components/experiment/configuration_facade.py @@ -160,7 +160,7 @@ class AutosubmitConfigurationFacade(ConfigurationFacade): stdout = os.popen("id -nu {0}".format(str(self.get_owner_id()))) owner_name = stdout.read().strip() return str(owner_name) - except: + except Exception: return "NA" def get_autosubmit_version(self) -> str: @@ -245,7 +245,7 @@ class AutosubmitConfigurationFacade(ConfigurationFacade): conf_job_processors, num_processors)) else: num_processors = int(conf_job_processors) - except: + except Exception: self._add_warning( "CHSY Critical | Autosubmit API could not parse the number of processors for the SIM job.") pass diff --git a/autosubmit_api/components/jobs/joblist_helper.py b/autosubmit_api/components/jobs/joblist_helper.py index 4eadd69..f7a35f7 100644 --- a/autosubmit_api/components/jobs/joblist_helper.py +++ b/autosubmit_api/components/jobs/joblist_helper.py @@ -35,7 +35,7 @@ class JobListHelper(object): self.package_to_jobs = job_package_reader.package_to_jobs self.package_to_package_id = job_package_reader.package_to_package_id self.package_to_symbol = job_package_reader.package_to_symbol - except: + except Exception: self.warning_messages.append("Failed to read job_packages") self.job_name_to_job_row, self.job_running_time_to_text, self.warning_messages = JobList.get_job_times_collection( diff --git a/autosubmit_api/components/jobs/joblist_loader.py b/autosubmit_api/components/jobs/joblist_loader.py index 21f0231..6fc4a17 100644 --- a/autosubmit_api/components/jobs/joblist_loader.py +++ b/autosubmit_api/components/jobs/joblist_loader.py @@ -209,7 +209,7 @@ class JobListLoader(object): out_set = [name for name in file_names if name.split('.')[-1] == 'out'] out_set.sort() new_outs = {name.split('.')[0]: name for name in out_set} - except: + except Exception: out_set = set() new_outs = dict() @@ -217,7 +217,7 @@ class JobListLoader(object): err_set = [name for name in file_names if name.split('.')[-1] == 'err'] err_set.sort() new_errs = {name.split('.')[0]: name for name in err_set} - except: + except Exception: err_set = set() new_errs = dict() diff --git a/autosubmit_api/components/jobs/utils.py b/autosubmit_api/components/jobs/utils.py index 4a7f8f1..14643aa 100644 --- a/autosubmit_api/components/jobs/utils.py +++ b/autosubmit_api/components/jobs/utils.py @@ -122,7 +122,7 @@ def get_folder_package_title(package_name: str, jobs_count: int, counters: Dict[ def convert_int_default(value, default_value=None): try: return int(value) - except: + except Exception: return default_value def get_job_total_stats(status_code: int, name: str, tmp_path: str) -> Tuple[datetime.datetime, datetime.datetime, datetime.datetime, str]: diff --git a/autosubmit_api/config/ymlConfigStrategy.py b/autosubmit_api/config/ymlConfigStrategy.py index 9dbd671..6dc7e9d 100644 --- a/autosubmit_api/config/ymlConfigStrategy.py +++ b/autosubmit_api/config/ymlConfigStrategy.py @@ -328,7 +328,7 @@ class ymlConfigStrategy(IConfigStrategy): try: # return DEFAULT.HPCARCH return self._conf_parser.get_platform() - except: + except Exception: return "" def set_platform(self, hpc): diff --git a/autosubmit_api/database/db_jobdata.py b/autosubmit_api/database/db_jobdata.py index b19d6c2..aa3f0e8 100644 --- a/autosubmit_api/database/db_jobdata.py +++ b/autosubmit_api/database/db_jobdata.py @@ -477,7 +477,7 @@ class MainDataBase(): try: conn = sqlite3.connect(db_file) return conn - except: + except Exception: return None def create_table(self): diff --git a/autosubmit_api/database/db_structure.py b/autosubmit_api/database/db_structure.py index 06ad129..009c6d6 100644 --- a/autosubmit_api/database/db_structure.py +++ b/autosubmit_api/database/db_structure.py @@ -68,7 +68,7 @@ def create_connection(db_file): try: conn = sqlite3.connect(db_file) return conn - except: + except Exception: return None diff --git a/autosubmit_api/logger.py b/autosubmit_api/logger.py index 3778030..b5c4a8f 100644 --- a/autosubmit_api/logger.py +++ b/autosubmit_api/logger.py @@ -23,7 +23,7 @@ def with_log_run_times( try: path = request.full_path method = request.method - except: + except Exception: path = "" method = "" _logger.info("{}|RECEIVED|{}{}".format(_tag, method, path)) diff --git a/autosubmit_api/views/v4.py b/autosubmit_api/views/v4.py index d7101ce..aa93b83 100644 --- a/autosubmit_api/views/v4.py +++ b/autosubmit_api/views/v4.py @@ -231,7 +231,7 @@ class ExperimentView(MethodView): else: page_size = None offset = None - except: + except Exception: return {"error": {"message": "Invalid params"}}, HTTPStatus.BAD_REQUEST # Query -- GitLab From 2101aff14c3e4db1dea156992e913c01d4460596 Mon Sep 17 00:00:00 2001 From: ltenorio Date: Thu, 5 Sep 2024 16:18:48 +0200 Subject: [PATCH 2/8] fix none-comparison E711 --- autosubmit_api/autosubmit_legacy/job/job_list.py | 2 +- autosubmit_api/components/jobs/job_factory.py | 2 +- autosubmit_api/monitor/monitor.py | 4 ++-- tests/test_endpoints_v3.py | 4 ++-- tests/test_endpoints_v4.py | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/autosubmit_api/autosubmit_legacy/job/job_list.py b/autosubmit_api/autosubmit_legacy/job/job_list.py index c3110f4..47722a8 100644 --- a/autosubmit_api/autosubmit_legacy/job/job_list.py +++ b/autosubmit_api/autosubmit_legacy/job/job_list.py @@ -232,7 +232,7 @@ class JobList: # current_title = current_title + target # if len(job._parents) == 0: # current_title = current_title + source - if job.member == None: + if job.member is None: current_title = current_title + sync sync_jobs.append(job.job_name) current_title = current_title + wrapped diff --git a/autosubmit_api/components/jobs/job_factory.py b/autosubmit_api/components/jobs/job_factory.py index 34f4e57..2e8653a 100644 --- a/autosubmit_api/components/jobs/job_factory.py +++ b/autosubmit_api/components/jobs/job_factory.py @@ -175,7 +175,7 @@ class Job(metaclass=ABCMeta): title += JUtils.target_tag if len(self.parents_names) == 0: title += JUtils.source_tag - if self.date is not None and self.member == None: + if self.date is not None and self.member is None: title += JUtils.sync_tag if self.package and len(self.package) > 0: title += self.package_tag diff --git a/autosubmit_api/monitor/monitor.py b/autosubmit_api/monitor/monitor.py index 98a2a97..a8314b8 100644 --- a/autosubmit_api/monitor/monitor.py +++ b/autosubmit_api/monitor/monitor.py @@ -90,7 +90,7 @@ class Monitor: Log.debug('Creating job graph...') jobs_packages_dict = dict() - if packages != None and packages: + if packages is not None and packages: for (exp_id, package_name, job_name) in packages: jobs_packages_dict[job_name] = package_name @@ -98,7 +98,7 @@ class Monitor: date_member_cluster = dict() # print("Iteration joblist: ") for job in joblist: - if job.date != None and job.member != None and job.has_parents(): + if job.date is not None and job.member is not None and job.has_parents(): date_member_cluster[job.name] = str( str(job.name[0:13]) + str(job.member)) # date_member_cluster[(job.long_name[0:13], job.member)].append(job.name) diff --git a/tests/test_endpoints_v3.py b/tests/test_endpoints_v3.py index b5d0113..2ce9926 100644 --- a/tests/test_endpoints_v3.py +++ b/tests/test_endpoints_v3.py @@ -196,7 +196,7 @@ class TestTree: if job["section"] == "SIM": assert isinstance(job["wrapper"], str) and len(job["wrapper"]) > 0 else: - assert job["wrapper"] == None + assert job["wrapper"] is None assert ( resp_obj["tree"][2]["title"] == "Wrappers" and resp_obj["tree"][2]["folder"] @@ -351,7 +351,7 @@ class TestGraph: if node["section"] == "SIM": assert isinstance(node["wrapper"], str) and len(node["wrapper"]) > 0 else: - assert node["wrapper"] == None + assert node["wrapper"] is None assert "packages" in list(resp_obj.keys()) assert len(resp_obj["packages"].keys()) > 0 diff --git a/tests/test_endpoints_v4.py b/tests/test_endpoints_v4.py index dc83894..337c45c 100644 --- a/tests/test_endpoints_v4.py +++ b/tests/test_endpoints_v4.py @@ -44,7 +44,7 @@ class TestJWTVerify: assert response.status_code == HTTPStatus.UNAUTHORIZED assert resp_obj.get("authenticated") == False - assert resp_obj.get("user") == None + assert resp_obj.get("user") is None def test_unauthorized_random_token(self, fixture_client: FlaskClient): random_token = str(uuid4()) @@ -55,7 +55,7 @@ class TestJWTVerify: assert response.status_code == HTTPStatus.UNAUTHORIZED assert resp_obj.get("authenticated") == False - assert resp_obj.get("user") == None + assert resp_obj.get("user") is None def test_authorized(self, fixture_client: FlaskClient): random_user = str(uuid4()) @@ -99,7 +99,7 @@ class TestExperimentList: # Unbounded page size response = fixture_client.get(self.endpoint, query_string={"page_size": -1}) resp_obj: dict = response.get_json() - assert resp_obj["pagination"]["page_size"] == None + assert resp_obj["pagination"]["page_size"] is None assert ( resp_obj["pagination"]["page_items"] == resp_obj["pagination"]["total_items"] -- GitLab From addf07811223bc274175da68ccb335bb9410c22e Mon Sep 17 00:00:00 2001 From: ltenorio Date: Thu, 5 Sep 2024 16:25:45 +0200 Subject: [PATCH 3/8] fix true-false-comparison E712 --- .../autosubmit_legacy/job/job_list.py | 6 +- autosubmit_api/config/confConfigStrategy.py | 12 ++-- autosubmit_api/database/db_jobdata.py | 18 ++--- autosubmit_api/views/v3.py | 4 +- tests/test_auth.py | 6 +- tests/test_config.py | 4 +- tests/test_endpoints_v3.py | 66 +++++++++---------- tests/test_endpoints_v4.py | 6 +- 8 files changed, 61 insertions(+), 61 deletions(-) diff --git a/autosubmit_api/autosubmit_legacy/job/job_list.py b/autosubmit_api/autosubmit_legacy/job/job_list.py index 47722a8..e7fa503 100644 --- a/autosubmit_api/autosubmit_legacy/job/job_list.py +++ b/autosubmit_api/autosubmit_legacy/job/job_list.py @@ -771,7 +771,7 @@ class JobList: _, c_start, _, _, _ = job_times.get(name, (0, t_start, t_finish, 0, 0)) job_data.start = c_start if t_start > c_start else t_start - if seconds == False: + if seconds is False: queue_time = math.ceil(job_data.queuing_time / 60) running_time = math.ceil(job_data.running_time / 60) else: @@ -783,7 +783,7 @@ class JobList: return JobRow(job_data.job_name, int(queue_time), int(running_time), status, energy, t_submit, t_start, t_finish, job_data.ncpus, job_data.run_id) # Using standard procedure - if status_code in [Status.RUNNING, Status.SUBMITTED, Status.QUEUING, Status.FAILED] or make_exception == True: + if status_code in [Status.RUNNING, Status.SUBMITTED, Status.QUEUING, Status.FAILED] or make_exception is True: # COMPLETED adds too much overhead so these values are now stored in a database and retrieved separatedly submit_time, start_time, finish_time, status = JobList._job_running_check(status_code, name, tmp_path) if status_code in [Status.RUNNING, Status.FAILED]: @@ -831,7 +831,7 @@ class JobList: (-1) if seconds_queued < 0 else seconds_queued seconds_running = seconds_running * \ (-1) if seconds_running < 0 else seconds_running - if seconds == False: + if seconds is False: queue_time = math.ceil( seconds_queued / 60) if seconds_queued > 0 else 0 running_time = math.ceil( diff --git a/autosubmit_api/config/confConfigStrategy.py b/autosubmit_api/config/confConfigStrategy.py index fb8bcd6..ff15bdc 100644 --- a/autosubmit_api/config/confConfigStrategy.py +++ b/autosubmit_api/config/confConfigStrategy.py @@ -53,31 +53,31 @@ class confConfigStrategy(IConfigStrategy): self._conf_parser: ConfigParser = None self._conf_parser_file = os.path.join(self.basic_config.LOCAL_ROOT_DIR, expid, "conf", "autosubmit_" + expid + extension) - if os.path.exists(self._conf_parser_file) == False: + if os.path.exists(self._conf_parser_file) is False: return None self._exp_parser: ConfigParser = None self._exp_parser_file = os.path.join(self.basic_config.LOCAL_ROOT_DIR, expid, "conf", "expdef_" + expid + extension) - if os.path.exists(self._exp_parser_file) == False: + if os.path.exists(self._exp_parser_file) is False: return None self._platforms_parser: ConfigParser = None self._platforms_parser_file = os.path.join(self.basic_config.LOCAL_ROOT_DIR, expid, "conf", "platforms_" + expid + extension) - if os.path.exists(self._platforms_parser_file) == False: + if os.path.exists(self._platforms_parser_file) is False: return None self._jobs_parser: ConfigParser = None self._jobs_parser_file = os.path.join(self.basic_config.LOCAL_ROOT_DIR, expid, "conf", "jobs_" + expid + extension) - if os.path.exists(self._jobs_parser_file) == False: + if os.path.exists(self._jobs_parser_file) is False: return None self._proj_parser: ConfigParser = None self._proj_parser_file = os.path.join(self.basic_config.LOCAL_ROOT_DIR, expid, "conf", "proj_" + expid + extension) - if os.path.exists(self._proj_parser_file) == False: + if os.path.exists(self._proj_parser_file) is False: return None @@ -988,7 +988,7 @@ class confConfigStrategy(IConfigStrategy): """ member_list = list() string = self._exp_parser.get('experiment', - 'MEMBERS') if run_only == False else self._exp_parser.get_option( + 'MEMBERS') if run_only is False else self._exp_parser.get_option( 'experiment', 'RUN_ONLY_MEMBERS', '') if not string.startswith("["): string = '[{0}]'.format(string) diff --git a/autosubmit_api/database/db_jobdata.py b/autosubmit_api/database/db_jobdata.py index aa3f0e8..d461090 100644 --- a/autosubmit_api/database/db_jobdata.py +++ b/autosubmit_api/database/db_jobdata.py @@ -497,7 +497,7 @@ class MainDataBase(): Log.warning(exp) return None except sqlite3.Error as e: - if _debug == True: + if _debug is True: Log.info(traceback.format_exc()) Log.warning("Error on create table : " + str(type(e).__name__)) return None @@ -516,7 +516,7 @@ class MainDataBase(): Log.warning(exp) return None except sqlite3.Error as e: - if _debug == True: + if _debug is True: Log.info(traceback.format_exc()) Log.debug(str(type(e).__name__)) Log.warning("Error on create index . create_index") @@ -603,7 +603,7 @@ class ExperimentGraphDrawing(MainDataBase): :return: Last row Id :rtype: int """ - lock_name = "calculation_{}_in_progress.lock".format(self.expid) if independent == True else self.lock_name + lock_name = "calculation_{}_in_progress.lock".format(self.expid) if independent is True else self.lock_name lock_path_file = os.path.join(self.folder_path, lock_name) try: with portalocker.Lock(lock_path_file, timeout=1) as fh: @@ -826,7 +826,7 @@ class JobDataStructure(MainDataBase): raise Exception("Job data folder not found {0} or the database version is outdated.".format( str(self.database_path))) except Exception as exp: - if _debug == True: + if _debug is True: Log.info(traceback.format_exc()) Log.debug(traceback.format_exc()) Log.warning( @@ -892,7 +892,7 @@ class JobDataStructure(MainDataBase): else: raise Exception("Not a valid connection.") except sqlite3.Error as e: - if _debug == True: + if _debug is True: print((traceback.format_exc())) print(("Error while retrieving run {0} information. {1}".format( run_id, "_get_experiment_run_by_id"))) @@ -918,7 +918,7 @@ class JobDataStructure(MainDataBase): # Starting value return None except sqlite3.Error as e: - if _debug == True: + if _debug is True: Log.info(traceback.format_exc()) Log.debug(traceback.format_exc()) Log.warning("Error while retrieving version: " + @@ -948,7 +948,7 @@ class JobDataStructure(MainDataBase): return None return None except sqlite3.Error as e: - if _debug == True: + if _debug is True: Log.info(traceback.format_exc()) Log.debug(traceback.format_exc()) Log.warning("Error on select max run_id : " + @@ -970,7 +970,7 @@ class JobDataStructure(MainDataBase): self.conn.text_factory = str cur = self.conn.cursor() request_string = "" - if all_states == False: + if all_states is False: if self.db_version >= CURRENT_DB_VERSION: request_string = "SELECT id, counter, job_name, created, modified, submit, start, finish, status, rowtype, ncpus, wallclock, qos, energy, date, section, member, chunk, last, platform, job_id, extra_data, nnodes, run_id, MaxRSS, AveRSS, out, err, rowstatus from job_data WHERE run_id=? and last=1 and finish > 0 and rowtype >= 2 ORDER BY id" else: @@ -990,7 +990,7 @@ class JobDataStructure(MainDataBase): else: return None except sqlite3.Error as e: - if _debug == True: + if _debug is True: print((traceback.format_exc())) print(("Error on select job data: {0}".format( str(type(e).__name__)))) diff --git a/autosubmit_api/views/v3.py b/autosubmit_api/views/v3.py index 23c9d62..76e9514 100644 --- a/autosubmit_api/views/v3.py +++ b/autosubmit_api/views/v3.py @@ -47,7 +47,7 @@ def login(): if referrer and referrer.find(allowed_client) >= 0: referrer = allowed_client is_allowed = True - if is_allowed == False: + if is_allowed is False: return { "authenticated": False, "user": None, @@ -250,7 +250,7 @@ def shutdown(route, user_id: Optional[str] = None): logger.info("Workers before: " + str(D)) lock.acquire() for k, v in list(D.items()): - if v[0] == user and v[1] == route and v[-1] == True: + if v[0] == user and v[1] == route and v[-1] is True: if v[2] == expid: D[k] = [user, route, expid, False] else: diff --git a/tests/test_auth.py b/tests/test_auth.py index 5fef206..8ecf3ed 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -84,13 +84,13 @@ class TestCommonAuth: ): # No ALLOWED_CLIENTS monkeypatch.setattr(APIBasicConfig, "ALLOWED_CLIENTS", []) - assert False == validate_client(str(uuid4())) + assert validate_client(str(uuid4())) is False # Wildcard ALLOWED_CLIENTS monkeypatch.setattr(APIBasicConfig, "ALLOWED_CLIENTS", ["*"]) - assert True == validate_client(str(uuid4())) + assert validate_client(str(uuid4())) is True # Registered client. The received with longer path random_client = str(uuid4()) monkeypatch.setattr(APIBasicConfig, "ALLOWED_CLIENTS", [random_client]) - assert True == validate_client(random_client + str(uuid4())) + assert validate_client(random_client + str(uuid4())) is True diff --git a/tests/test_config.py b/tests/test_config.py index 64b1245..faefbad 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -61,7 +61,7 @@ class TestConfigResolver: class TestYMLConfigStrategy: def test_exclusive(self, fixture_mock_basic_config): wrapper = ymlConfigStrategy("a007", fixture_mock_basic_config) - assert True == wrapper.get_exclusive(JobSection.SIM) + assert wrapper.get_exclusive(JobSection.SIM) is True wrapper = ymlConfigStrategy("a003", fixture_mock_basic_config) - assert False == wrapper.get_exclusive(JobSection.SIM) + assert wrapper.get_exclusive(JobSection.SIM) is False diff --git a/tests/test_endpoints_v3.py b/tests/test_endpoints_v3.py index 2ce9926..d8de174 100644 --- a/tests/test_endpoints_v3.py +++ b/tests/test_endpoints_v3.py @@ -23,7 +23,7 @@ class TestLogin: resp_obj: dict = response.get_json() assert response.status_code == HTTPStatus.UNAUTHORIZED - assert resp_obj.get("authenticated") == False + assert resp_obj.get("authenticated") is False def test_redirect( self, @@ -51,7 +51,7 @@ class TestVerifyToken: resp_obj: dict = response.get_json() assert response.status_code == HTTPStatus.UNAUTHORIZED - assert resp_obj.get("isValid") == False + assert resp_obj.get("isValid") is False def test_unauthorized_random_token(self, fixture_client: FlaskClient): random_token = str(uuid4()) @@ -61,7 +61,7 @@ class TestVerifyToken: resp_obj: dict = response.get_json() assert response.status_code == HTTPStatus.UNAUTHORIZED - assert resp_obj.get("isValid") == False + assert resp_obj.get("isValid") is False def test_authorized(self, fixture_client: FlaskClient): random_user = str(uuid4()) @@ -79,7 +79,7 @@ class TestVerifyToken: resp_obj: dict = response.get_json() assert response.status_code == HTTPStatus.OK - assert resp_obj.get("isValid") == True + assert resp_obj.get("isValid") is True class TestExpInfo: @@ -90,7 +90,7 @@ class TestExpInfo: response = fixture_client.get(self.endpoint.format(expid=expid)) resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["expid"] == expid assert resp_obj["total_jobs"] == 8 @@ -99,7 +99,7 @@ class TestExpInfo: response = fixture_client.get(self.endpoint.format(expid=expid)) resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["expid"] == expid assert resp_obj["total_jobs"] == 55 assert resp_obj["completed_jobs"] == 28 @@ -160,7 +160,7 @@ class TestTree: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total"] == 8 assert resp_obj["total"] == len(resp_obj["jobs"]) for job in resp_obj["jobs"]: @@ -176,7 +176,7 @@ class TestTree: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total"] == 55 assert resp_obj["total"] == len(resp_obj["jobs"]) assert ( @@ -213,7 +213,7 @@ class TestRunsList: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert isinstance(resp_obj["runs"], list) @@ -227,7 +227,7 @@ class TestRunDetail: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total"] == 8 @@ -240,7 +240,7 @@ class TestQuick: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total"] == len(resp_obj["tree_view"]) assert resp_obj["total"] == len(resp_obj["view_data"]) @@ -257,7 +257,7 @@ class TestGraph: ) resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total_jobs"] == len(resp_obj["nodes"]) def test_graph_standard_datemember(self, fixture_client: FlaskClient): @@ -271,7 +271,7 @@ class TestGraph: ) resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total_jobs"] == len(resp_obj["nodes"]) def test_graph_standard_status(self, fixture_client: FlaskClient): @@ -283,7 +283,7 @@ class TestGraph: ) resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total_jobs"] == len(resp_obj["nodes"]) def test_graph_laplacian_none(self, fixture_client: FlaskClient): @@ -295,7 +295,7 @@ class TestGraph: ) resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total_jobs"] == len(resp_obj["nodes"]) def test_graph_standard_none_retro3(self, fixture_client: FlaskClient): @@ -307,7 +307,7 @@ class TestGraph: ) resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total_jobs"] == len(resp_obj["nodes"]) def test_graph_standard_datemember_retro3(self, fixture_client: FlaskClient): @@ -321,7 +321,7 @@ class TestGraph: ) resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total_jobs"] == len(resp_obj["nodes"]) def test_graph_standard_status_retro3(self, fixture_client: FlaskClient): @@ -333,7 +333,7 @@ class TestGraph: ) resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total_jobs"] == len(resp_obj["nodes"]) def test_wrappers(self, fixture_client: FlaskClient): @@ -366,7 +366,7 @@ class TestExpCount: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total"] == sum( [resp_obj["counters"][key] for key in resp_obj["counters"]] ) @@ -380,7 +380,7 @@ class TestExpCount: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["total"] == sum( [resp_obj["counters"][key] for key in resp_obj["counters"]] ) @@ -405,7 +405,7 @@ class TestSummary: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["n_sim"] > 0 @@ -420,7 +420,7 @@ class TestStatistics: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert resp_obj["Statistics"]["Period"]["From"] == "None" @@ -433,7 +433,7 @@ class TestCurrentConfig: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert ( resp_obj["configuration_filesystem"]["CONFIG"]["AUTOSUBMIT_VERSION"] == "4.0.95" @@ -445,7 +445,7 @@ class TestCurrentConfig: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert ( resp_obj["configuration_filesystem"]["conf"]["config"]["AUTOSUBMIT_VERSION"] == "3.13.0" @@ -461,7 +461,7 @@ class TestPklInfo: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert len(resp_obj["pkl_content"]) == 8 for job_obj in resp_obj["pkl_content"]: @@ -477,7 +477,7 @@ class TestPklTreeInfo: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert len(resp_obj["pkl_content"]) == 8 for job_obj in resp_obj["pkl_content"]: @@ -493,8 +493,8 @@ class TestExpRunLog: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False - assert resp_obj["found"] == True + assert resp_obj["error"] is False + assert resp_obj["found"] is True class TestIfRunFromLog: @@ -506,7 +506,7 @@ class TestIfRunFromLog: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert isinstance(resp_obj["is_running"], bool) assert isinstance(resp_obj["log_path"], str) assert isinstance(resp_obj["timediff"], int) @@ -521,7 +521,7 @@ class TestQuickIfRun: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert isinstance(resp_obj["running"], bool) @@ -534,8 +534,8 @@ class TestJobLogLines: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False - assert resp_obj["found"] == True + assert resp_obj["error"] is False + assert resp_obj["found"] is True assert isinstance(resp_obj["lastModified"], str) assert isinstance(resp_obj["logfile"], str) assert isinstance(resp_obj["timeStamp"], int) @@ -555,7 +555,7 @@ class TestJobHistory: resp_obj: dict = response.get_json() assert resp_obj["error_message"] == "" - assert resp_obj["error"] == False + assert resp_obj["error"] is False assert isinstance(resp_obj["path_to_logs"], str) assert isinstance(resp_obj["history"], list) assert len(resp_obj["history"]) > 0 diff --git a/tests/test_endpoints_v4.py b/tests/test_endpoints_v4.py index 337c45c..8bafa9d 100644 --- a/tests/test_endpoints_v4.py +++ b/tests/test_endpoints_v4.py @@ -43,7 +43,7 @@ class TestJWTVerify: resp_obj: dict = response.get_json() assert response.status_code == HTTPStatus.UNAUTHORIZED - assert resp_obj.get("authenticated") == False + assert resp_obj.get("authenticated") is False assert resp_obj.get("user") is None def test_unauthorized_random_token(self, fixture_client: FlaskClient): @@ -54,7 +54,7 @@ class TestJWTVerify: resp_obj: dict = response.get_json() assert response.status_code == HTTPStatus.UNAUTHORIZED - assert resp_obj.get("authenticated") == False + assert resp_obj.get("authenticated") is False assert resp_obj.get("user") is None def test_authorized(self, fixture_client: FlaskClient): @@ -75,7 +75,7 @@ class TestJWTVerify: resp_obj: dict = response.get_json() assert response.status_code == HTTPStatus.OK - assert resp_obj.get("authenticated") == True + assert resp_obj.get("authenticated") is True assert resp_obj.get("user") == random_user -- GitLab From 359da8db9e73132951dd6234f446d45fef4e4285 Mon Sep 17 00:00:00 2001 From: ltenorio Date: Thu, 5 Sep 2024 16:40:19 +0200 Subject: [PATCH 4/8] fix undefined-local-with-import-star F405 --- autosubmit_api/autosubmit_legacy/job/job_list.py | 2 +- autosubmit_api/common/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autosubmit_api/autosubmit_legacy/job/job_list.py b/autosubmit_api/autosubmit_legacy/job/job_list.py index e7fa503..5b79aa8 100644 --- a/autosubmit_api/autosubmit_legacy/job/job_list.py +++ b/autosubmit_api/autosubmit_legacy/job/job_list.py @@ -26,7 +26,7 @@ import math # End Spectral imports from time import time, mktime -from dateutil.relativedelta import * +from dateutil.relativedelta import relativedelta from autosubmit_api.autosubmit_legacy.job.job_utils import SubJob from autosubmit_api.autosubmit_legacy.job.job_utils import SubJobManager, job_times_to_text diff --git a/autosubmit_api/common/utils.py b/autosubmit_api/common/utils.py index cf544a5..dd89d25 100644 --- a/autosubmit_api/common/utils.py +++ b/autosubmit_api/common/utils.py @@ -6,7 +6,7 @@ import datetime import math from collections import namedtuple from bscearth.utils.date import date2str -from dateutil.relativedelta import * +from dateutil.relativedelta import relativedelta from typing import List, Tuple class Section: -- GitLab From f17757b65f1dbf7a19857e99dc27bcccc0573f9e Mon Sep 17 00:00:00 2001 From: ltenorio Date: Thu, 5 Sep 2024 16:43:31 +0200 Subject: [PATCH 5/8] fix f-string-missing-placeholders F541 --- autosubmit_api/database/queries.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autosubmit_api/database/queries.py b/autosubmit_api/database/queries.py index 88c8acd..55cca9e 100644 --- a/autosubmit_api/database/queries.py +++ b/autosubmit_api/database/queries.py @@ -55,12 +55,12 @@ def generate_query_listexp_extended( filter_stmts.append(tables.details_table.c.user == owner) if exp_type == "test": - filter_stmts.append(tables.experiment_table.c.name.like(f"t%")) + filter_stmts.append(tables.experiment_table.c.name.like("t%")) elif exp_type == "operational": - filter_stmts.append(tables.experiment_table.c.name.like(f"o%")) + filter_stmts.append(tables.experiment_table.c.name.like("o%")) elif exp_type == "experiment": - filter_stmts.append(tables.experiment_table.c.name.not_like(f"t%")) - filter_stmts.append(tables.experiment_table.c.name.not_like(f"o%")) + filter_stmts.append(tables.experiment_table.c.name.not_like("t%")) + filter_stmts.append(tables.experiment_table.c.name.not_like("o%")) if autosubmit_version: filter_stmts.append( -- GitLab From d7ec41e0a28954674287bdf10655a257fa8d947c Mon Sep 17 00:00:00 2001 From: ltenorio Date: Thu, 5 Sep 2024 16:45:52 +0200 Subject: [PATCH 6/8] fix multiple-statements-on-one-line-colon E701 --- .../experiment/configuration_facade.py | 9 ++++++--- autosubmit_api/config/confConfigStrategy.py | 16 ++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/autosubmit_api/components/experiment/configuration_facade.py b/autosubmit_api/components/experiment/configuration_facade.py index ba64f16..763612b 100644 --- a/autosubmit_api/components/experiment/configuration_facade.py +++ b/autosubmit_api/components/experiment/configuration_facade.py @@ -47,9 +47,12 @@ class ConfigurationFacade(metaclass=ABCMeta): self.tmp_path = exp_paths.tmp_dir self.log_path = exp_paths.tmp_log_dir self.structures_path = self.basic_configuration.STRUCTURES_DIR - if not os.path.exists(self.experiment_path): raise IOError("Experiment folder {0} not found".format(self.experiment_path)) - if not os.path.exists(self.pkl_path): raise IOError("Required file {0} not found.".format(self.pkl_path)) - if not os.path.exists(self.tmp_path): raise IOError("Required folder {0} not found.".format(self.tmp_path)) + if not os.path.exists(self.experiment_path): + raise IOError("Experiment folder {0} not found".format(self.experiment_path)) + if not os.path.exists(self.pkl_path): + raise IOError("Required file {0} not found.".format(self.pkl_path)) + if not os.path.exists(self.tmp_path): + raise IOError("Required folder {0} not found.".format(self.tmp_path)) @abstractmethod def _process_advanced_config(self): diff --git a/autosubmit_api/config/confConfigStrategy.py b/autosubmit_api/config/confConfigStrategy.py index ff15bdc..df23ad3 100644 --- a/autosubmit_api/config/confConfigStrategy.py +++ b/autosubmit_api/config/confConfigStrategy.py @@ -663,14 +663,14 @@ class confConfigStrategy(IConfigStrategy): """ Creates parser objects for configuration files """ - if not os.path.exists(self._conf_parser_file): raise IOError( - "Required file not found {0}".format(self._conf_parser_file)) - if not os.path.exists(self._platforms_parser_file): raise IOError( - "Required file not found {0}".format(self._platforms_parser_file)) - if not os.path.exists(self._jobs_parser_file): raise IOError( - "Required file not found {0}".format(self._jobs_parser_file)) - if not os.path.exists(self._exp_parser_file): raise IOError( - "Required file not found {0}".format(self._exp_parser_file)) + if not os.path.exists(self._conf_parser_file): + raise IOError("Required file not found {0}".format(self._conf_parser_file)) + if not os.path.exists(self._platforms_parser_file): + raise IOError("Required file not found {0}".format(self._platforms_parser_file)) + if not os.path.exists(self._jobs_parser_file): + raise IOError("Required file not found {0}".format(self._jobs_parser_file)) + if not os.path.exists(self._exp_parser_file): + raise IOError("Required file not found {0}".format(self._exp_parser_file)) self._conf_parser = confConfigStrategy.get_parser(self.parser_factory, self._conf_parser_file) self._platforms_parser = confConfigStrategy.get_parser(self.parser_factory, self._platforms_parser_file) self._jobs_parser = confConfigStrategy.get_parser(self.parser_factory, self._jobs_parser_file) -- GitLab From debde22db98e3c46e049dd954470a41794598712 Mon Sep 17 00:00:00 2001 From: ltenorio Date: Thu, 5 Sep 2024 16:47:29 +0200 Subject: [PATCH 7/8] fix type-comparison E721 --- autosubmit_api/statistics/statistics.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autosubmit_api/statistics/statistics.py b/autosubmit_api/statistics/statistics.py index 712264e..dba0d94 100644 --- a/autosubmit_api/statistics/statistics.py +++ b/autosubmit_api/statistics/statistics.py @@ -58,9 +58,9 @@ class Statistics(object): job_stat.completed_run_time += max(job_stat.finish_time - job_stat.start_time, timedelta()) else: job_stat.inc_failed_retrial_count() - job_stat.submit_time = retrial[0] if len(retrial) >= 1 and type(retrial[0]) == datetime else None - job_stat.start_time = retrial[1] if len(retrial) >= 2 and type(retrial[1]) == datetime else None - job_stat.finish_time = retrial[2] if len(retrial) >= 3 and type(retrial[2]) == datetime else None + job_stat.submit_time = retrial[0] if len(retrial) >= 1 and isinstance(retrial[0], datetime) else None + job_stat.start_time = retrial[1] if len(retrial) >= 2 and isinstance(retrial[1], datetime) else None + job_stat.finish_time = retrial[2] if len(retrial) >= 3 and isinstance(retrial[2], datetime) else None if job_stat.finish_time and job_stat.start_time: job_stat.failed_run_time += max(job_stat.finish_time - job_stat.start_time, timedelta()) if job_stat.start_time and job_stat.submit_time: -- GitLab From bca668eacc371acbb758db30d695b54ffb9628cd Mon Sep 17 00:00:00 2001 From: ltenorio Date: Thu, 5 Sep 2024 16:55:25 +0200 Subject: [PATCH 8/8] fix unused-variable F841 --- autosubmit_api/autosubmit_legacy/job/job_list.py | 10 +++++----- autosubmit_api/autosubmit_legacy/job/job_utils.py | 6 +++--- autosubmit_api/common/utils.py | 2 +- autosubmit_api/components/jobs/utils.py | 2 +- autosubmit_api/config/confConfigStrategy.py | 4 ++-- autosubmit_api/database/db_common.py | 10 +++++----- autosubmit_api/database/db_jobdata.py | 10 +++++----- autosubmit_api/database/db_structure.py | 4 ++-- .../history/database_managers/database_manager.py | 2 +- .../database_managers/experiment_history_db_manager.py | 2 +- autosubmit_api/monitor/monitor.py | 2 +- autosubmit_api/views/v3.py | 4 ++-- autosubmit_api/views/v4.py | 4 ++-- .../workers/business/process_graph_drawings.py | 2 +- tests/test_endpoints_v3.py | 1 - 15 files changed, 32 insertions(+), 33 deletions(-) diff --git a/autosubmit_api/autosubmit_legacy/job/job_list.py b/autosubmit_api/autosubmit_legacy/job/job_list.py index 5b79aa8..dfc6fe5 100644 --- a/autosubmit_api/autosubmit_legacy/job/job_list.py +++ b/autosubmit_api/autosubmit_legacy/job/job_list.py @@ -584,9 +584,9 @@ class JobList: :return: job running to min (queue, run, status), job running to text (text) """ # Getting information - path_local_root = basic_config.LOCAL_ROOT_DIR + # path_local_root = basic_config.LOCAL_ROOT_DIR path_structure = basic_config.STRUCTURES_DIR - db_file = os.path.join(path_local_root, basic_config.DB_FILE) + # db_file = os.path.join(path_local_root, basic_config.DB_FILE) # Job information from job historic data # print("Get current job data structure...") job_data = None @@ -598,7 +598,7 @@ class JobList: # Result variables job_running_time_seconds = dict() job_running_to_runtext = dict() - result = dict() + # result = dict() current_table_structure = dict() job_name_to_job_info = dict() # Work variables @@ -688,7 +688,7 @@ class JobList: values) > 1 else submit_time finish_time = parse_date(values[2]) if len( values) > 2 else start_time - except Exception as exp: + except Exception: start_time = now finish_time = now # NA if reading fails @@ -823,7 +823,7 @@ class JobList: start_time = 0 finish_time = 0 - except Exception as exp: + except Exception: print((traceback.format_exc())) return diff --git a/autosubmit_api/autosubmit_legacy/job/job_utils.py b/autosubmit_api/autosubmit_legacy/job/job_utils.py index a32a1eb..9795b1a 100644 --- a/autosubmit_api/autosubmit_legacy/job/job_utils.py +++ b/autosubmit_api/autosubmit_legacy/job/job_utils.py @@ -26,7 +26,7 @@ import time def transitive_reduction(graph): try: return networkx.algorithms.dag.transitive_reduction(graph) - except Exception as exp: + except Exception: return None # if not is_directed_acyclic_graph(graph): # raise NetworkXError("Transitive reduction only uniquely defined on directed acyclic graphs.") @@ -235,7 +235,7 @@ def parse_output_number(self, string_number): number = string_number try: number = float(number) * multiplier - except Exception as exp: + except Exception: number = 0.0 pass return number @@ -278,7 +278,7 @@ def datechunk_to_year(chunk_unit: str, chunk_size: int) -> float: :rtype: float """ chunk_size = chunk_size * 1.0 - options = ["year", "month", "day", "hour"] + # options = ["year", "month", "day", "hour"] if (chunk_unit == "year"): return chunk_size elif (chunk_unit == "month"): diff --git a/autosubmit_api/common/utils.py b/autosubmit_api/common/utils.py index dd89d25..81d0c86 100644 --- a/autosubmit_api/common/utils.py +++ b/autosubmit_api/common/utils.py @@ -209,7 +209,7 @@ def datechunk_to_year(chunk_unit: int, chunk_size: int) -> float: :rtype: float """ chunk_size = chunk_size * 1.0 - options = ["year", "month", "day", "hour"] + # options = ["year", "month", "day", "hour"] if (chunk_unit == "year"): return chunk_size elif (chunk_unit == "month"): diff --git a/autosubmit_api/components/jobs/utils.py b/autosubmit_api/components/jobs/utils.py index 14643aa..b60ded5 100644 --- a/autosubmit_api/components/jobs/utils.py +++ b/autosubmit_api/components/jobs/utils.py @@ -178,7 +178,7 @@ def get_job_total_stats(status_code: int, name: str, tmp_path: str) -> Tuple[dat values) > 1 else submit_time finish_time = parse_date(values[2]) if len( values) > 2 else start_time - except Exception as exp: + except Exception: start_time = now finish_time = now # NA if reading fails diff --git a/autosubmit_api/config/confConfigStrategy.py b/autosubmit_api/config/confConfigStrategy.py index df23ad3..01e0464 100644 --- a/autosubmit_api/config/confConfigStrategy.py +++ b/autosubmit_api/config/confConfigStrategy.py @@ -159,7 +159,7 @@ class confConfigStrategy(IConfigStrategy): """ try: return json.dumps(self.get_full_config_as_dict()) - except Exception as exp: + except Exception: Log.warning( "Autosubmit was not able to retrieve and save the configuration into the historical database.") return "" @@ -1322,6 +1322,6 @@ class confConfigStrategy(IConfigStrategy): if file_path.find('proj_') > 0: parser.read(file_path) else: - with open(file_path) as f: + with open(file_path): parser.read(file_path) return parser diff --git a/autosubmit_api/database/db_common.py b/autosubmit_api/database/db_common.py index 69e4920..02d6aa1 100644 --- a/autosubmit_api/database/db_common.py +++ b/autosubmit_api/database/db_common.py @@ -257,7 +257,7 @@ def search_experiment_by_id(query, exp_type=None, only_active=None, owner=None): wrapper = autosubmit_config_facade.get_wrapper_type() last_modified_pkl_datetime = autosubmit_config_facade.get_pkl_last_modified_time_as_datetime() hpc = autosubmit_config_facade.get_main_platform() - except Exception as exp: + except Exception: last_modified_pkl_datetime = None pass @@ -276,7 +276,7 @@ def search_experiment_by_id(query, exp_type=None, only_active=None, owner=None): running = current_run.running failed = current_run.failed suspended = current_run.suspended - last_modified_timestamp = current_run.modified_timestamp + # last_modified_timestamp = current_run.modified_timestamp except Exception as exp: print(("Exception on search_experiment_by_id : {}".format(exp))) pass @@ -338,7 +338,7 @@ def get_current_running_exp(): wrapper = autosubmit_config_facade.get_wrapper_type() last_modified_pkl_datetime = autosubmit_config_facade.get_pkl_last_modified_time_as_datetime() hpc = autosubmit_config_facade.get_main_platform() - except Exception as exp: + except Exception: last_modified_pkl_datetime = None pass if (expid in experiment_times): @@ -361,7 +361,7 @@ def get_current_running_exp(): running = current_run.running failed = current_run.failed suspended = current_run.suspended - last_modified_timestamp = current_run.modified_timestamp + # last_modified_timestamp = current_run.modified_timestamp except Exception as exp: print(("Exception on get_current_running_exp : {}".format(exp))) pass @@ -483,7 +483,7 @@ def _update_experiment_descrip_version(name, description=None, version=None): return False try: (conn, cursor) = open_conn() - except DbException as e: + except DbException: raise Exception( "Could not establish a connection to the database.") conn.isolation_level = None diff --git a/autosubmit_api/database/db_jobdata.py b/autosubmit_api/database/db_jobdata.py index d461090..321bdf5 100644 --- a/autosubmit_api/database/db_jobdata.py +++ b/autosubmit_api/database/db_jobdata.py @@ -201,7 +201,7 @@ class JobData(object): self.job_id = job_id if job_id else 0 try: self.extra_data = loads(extra_data) - except Exception as exp: + except Exception: self.extra_data = "" pass self.nnodes = nnodes @@ -575,7 +575,7 @@ class ExperimentGraphDrawing(MainDataBase): except portalocker.AlreadyLocked: print("It is locked") self.locked = True - except Exception as exp: + except Exception: self.locked = True def get_validated_data(self, allJobs): @@ -861,7 +861,7 @@ class JobDataStructure(MainDataBase): jobitem.wallclock, jobitem.qos, jobitem.energy, jobitem.date, jobitem.section, jobitem.member, jobitem.chunk, jobitem.last, jobitem.platform, jobitem.job_id, jobitem.extra_data, jobitem.nnodes, jobitem.run_id)) return current_collection return None - except Exception as exp: + except Exception: print((traceback.format_exc())) print(( "Error on returning current job data. run_id {0}".format(run_id))) @@ -891,7 +891,7 @@ class JobDataStructure(MainDataBase): return None else: raise Exception("Not a valid connection.") - except sqlite3.Error as e: + except sqlite3.Error: if _debug is True: print((traceback.format_exc())) print(("Error while retrieving run {0} information. {1}".format( @@ -1025,7 +1025,7 @@ def parse_output_number(string_number): number = string_number try: number = float(number) * multiplier - except Exception as exp: + except Exception: number = 0.0 pass return number diff --git a/autosubmit_api/database/db_structure.py b/autosubmit_api/database/db_structure.py index 009c6d6..ebaa86a 100644 --- a/autosubmit_api/database/db_structure.py +++ b/autosubmit_api/database/db_structure.py @@ -55,7 +55,7 @@ def get_structure(expid, structures_path): # pkl folder not found raise Exception("structures db not found " + str(db_structure_path)) - except Exception as exp: + except Exception: print((traceback.format_exc())) @@ -99,6 +99,6 @@ def _get_exp_structure(path): "SELECT e_from, e_to FROM experiment_structure") rows = cur.fetchall() return rows - except Exception as exp: + except Exception: print((traceback.format_exc())) return dict() diff --git a/autosubmit_api/history/database_managers/database_manager.py b/autosubmit_api/history/database_managers/database_manager.py index dd94e23..3187503 100644 --- a/autosubmit_api/history/database_managers/database_manager.py +++ b/autosubmit_api/history/database_managers/database_manager.py @@ -85,7 +85,7 @@ class DatabaseManager(metaclass=ABCMeta): for statement in statements: try: self.execute_statement_on_dbfile(path, statement) - except Exception as exp: + except Exception: pass def get_from_statement(self, path: str, statement: str) -> List[Tuple]: diff --git a/autosubmit_api/history/database_managers/experiment_history_db_manager.py b/autosubmit_api/history/database_managers/experiment_history_db_manager.py index 4888a17..38f7334 100644 --- a/autosubmit_api/history/database_managers/experiment_history_db_manager.py +++ b/autosubmit_api/history/database_managers/experiment_history_db_manager.py @@ -304,7 +304,7 @@ class ExperimentHistoryDbManager(DatabaseManager): return [] def get_job_data_dcs_COMPLETED_by_section(self, section: str) -> List[JobData]: - arguments = {"status": "COMPLETED", "section": section} + # arguments = {"status": "COMPLETED", "section": section} job_data_rows = self._get_job_data_COMPLETD_by_section(section) return [JobData.from_model(row) for row in job_data_rows] diff --git a/autosubmit_api/monitor/monitor.py b/autosubmit_api/monitor/monitor.py index a8314b8..1469e01 100644 --- a/autosubmit_api/monitor/monitor.py +++ b/autosubmit_api/monitor/monitor.py @@ -94,7 +94,7 @@ class Monitor: for (exp_id, package_name, job_name) in packages: jobs_packages_dict[job_name] = package_name - packages_subgraphs_dict = dict() + # packages_subgraphs_dict = dict() date_member_cluster = dict() # print("Iteration joblist: ") for job in joblist: diff --git a/autosubmit_api/views/v3.py b/autosubmit_api/views/v3.py index 76e9514..49f5a64 100644 --- a/autosubmit_api/views/v3.py +++ b/autosubmit_api/views/v3.py @@ -237,7 +237,7 @@ def shutdown(route, user_id: Optional[str] = None): try: user = request.args.get("loggedUser", default="null", type=str) expid = request.args.get("expid", default="null", type=str) - except Exception as exp: + except Exception: logger.info("Bad parameters for user and expid in route.") if user != "null": @@ -261,7 +261,7 @@ def shutdown(route, user_id: Optional[str] = None): logger.info("killed worker " + str(k)) lock.release() logger.info("Workers now: " + str(D)) - except Exception as exp: + except Exception: logger.info( "[CRITICAL] Could not shutdown process " + expid diff --git a/autosubmit_api/views/v4.py b/autosubmit_api/views/v4.py index aa93b83..3cdf223 100644 --- a/autosubmit_api/views/v4.py +++ b/autosubmit_api/views/v4.py @@ -270,7 +270,7 @@ class ExperimentView(MethodView): exp = exp_builder.product # Get current run data from history - last_modified_timestamp = exp.created + # last_modified_timestamp = exp.created completed = 0 total = 0 submitted = 0 @@ -292,7 +292,7 @@ class ExperimentView(MethodView): running = current_run.running failed = current_run.failed suspended = current_run.suspended - last_modified_timestamp = current_run.modified_timestamp + # last_modified_timestamp = current_run.modified_timestamp except Exception as exc: logger.warning((f"Exception getting the current run on search: {exc}")) logger.warning(traceback.format_exc()) diff --git a/autosubmit_api/workers/business/process_graph_drawings.py b/autosubmit_api/workers/business/process_graph_drawings.py index c536d42..ccff87c 100644 --- a/autosubmit_api/workers/business/process_graph_drawings.py +++ b/autosubmit_api/workers/business/process_graph_drawings.py @@ -38,7 +38,7 @@ def process_active_graphs(): autosubmit_configuration_facade.get_autosubmit_version() ): _process_graph(expid, autosubmit_configuration_facade.chunk_size) - except Exception as exp: + except Exception: print((traceback.format_exc())) print(("Error while processing: {}".format(expid))) diff --git a/tests/test_endpoints_v3.py b/tests/test_endpoints_v3.py index d8de174..dd159df 100644 --- a/tests/test_endpoints_v3.py +++ b/tests/test_endpoints_v3.py @@ -577,7 +577,6 @@ class TestRunningExps: endpoint = "/v3/running/" def test_search_by_expid(self, fixture_client: FlaskClient): - expid = "a3tb" response = fixture_client.get(self.endpoint) resp_obj: dict = response.get_json() -- GitLab