Skip to content
Snippets Groups Projects
Commit 612165a5 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

DataQuality: fix flake8-bugbear warnings

B011: do not use assert False
B026: Star-arg unpacking after a keyword argument
B005: Using .strip() with multi-character strings
B036: Don't except `BaseException` unless you plan to re-raise it
parent 3451c0f6
No related branches found
No related tags found
No related merge requests found
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from __future__ import with_statement, division, print_function
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
from DQUtils import process_iovs
from DQUtils.sugar import IOVSet, define_iov_type
......@@ -225,9 +222,7 @@ class DCSC_Subdetector(object):
if not iovs: continue # Can this happen?
input_channel = iovs[0].channel
if input_channel not in mapping:
# TODO: This could be an error.
assert False, "channel not found in mapping: " + str(input_channel)
continue
raise RuntimeError("channel not found in mapping: " + str(input_channel))
seen_channels.add(input_channel)
output_channel = mapping[input_channel]
result.setdefault(output_channel, []).append(iovs)
......
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
"""
Authors: Peter Waller <peter.waller@cern.ch> and "Peter Onyisi" <peter.onyisi@cern.ch>
......@@ -184,7 +184,7 @@ class DefectsDB(DefectsDBVirtualDefectsMixin,
Causes a ~0.6x slowdown
"""
if ignore is not None and not isinstance(ignore, set):
assert False, "ignore parameter should be set type"
raise RuntimeError("ignore parameter should be set type")
desired_channels = None
# Figure out the IDs of channels to query and their virtuality
......@@ -435,4 +435,4 @@ class DefectsDB(DefectsDBVirtualDefectsMixin,
)
log.debug(r.content)
if not r or r.json()['code'] != 0:
raise RuntimeError(f'Unable to upload defects. Flask server returned error:\n{r.json()["message"]}')
\ No newline at end of file
raise RuntimeError(f'Unable to upload defects. Flask server returned error:\n{r.json()["message"]}')
# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
from __future__ import annotations
from DQDefects import DEFECT_IOV
......@@ -18,7 +18,7 @@ class DefectLogic(object):
self.evaluate = self.bad_evaluator
def bad_evaluator(self, states) -> DEFECT_IOV:
assert False, "bad_evaluation should never be called"
raise RuntimeError("bad_evaluator should never be called")
def set_evaluation(self, full: bool) -> None:
if full:
......
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
from DQUtils import fetch_iovs, process_iovs, IOVSet
......@@ -25,7 +25,7 @@ def get_trigger_channel(trigger, iovrange):
channel = result[0].channel
iovs = fetch_iovs(LVL1_MENU, channels=[channel], what=["ItemName"], *iovrange)
iovs = fetch_iovs(LVL1_MENU, *iovrange, channels=[channel], what=["ItemName"])
return iovs.select(ItemName = trigger)
......@@ -126,13 +126,13 @@ def fetch_lumi_inputs(range_iov, tag="OflLumi-7TeV-002"):
"""
Retrieve information required to calculate the luminosity from the database
"""
lbs = fetch_iovs("LBLB", with_channel=False, #loud=True,
*range_iov)
lbs = fetch_iovs("LBLB", *range_iov, with_channel=False)
if tag == "ONLINE":
lumis = fetch_iovs("COOLONL_TRIGGER::/TRIGGER/LUMI/OnlPrefLumi",
channels=[0], #loud=True,
*range_iov)
*range_iov,
channels=[0])
# Select valid
lumis = IOVSet(l for l in lumis if (l.Valid & 0xFFFF) % 10 == 0)
else:
......@@ -140,8 +140,9 @@ def fetch_lumi_inputs(range_iov, tag="OflLumi-7TeV-002"):
lumi_folder = "COOLOFL_TRIGGER::/TRIGGER/OFLLUMI/OflPrefLumi" # Run-2
#lumi_folder = "COOLOFL_TRIGGER::/TRIGGER/OFLLUMI/LBLESTOFL" # Run-1
lumis = fetch_iovs(lumi_folder,
*range_iov,
tag=tag,
channels=[0], #loud=True,
*range_iov)
channels=[0])
return lbs, lumis
return lbs, lumis
#!/usr/bin/env python
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
# -*- coding: utf-8 -*-
from __future__ import print_function
import os, shutil
import time
from time import sleep
......@@ -342,14 +340,14 @@ def DQWebDisplay( inputFilePath, runAccumulating, c ):
print('handi("Run '+rN+ ', '+sp[1]+', ' + stream + '",' + sp[0] + ','+rundir+sp[3]+')')
_local_apply(handiWithComparisons, ( ('Run '+rN+ ', '+sp[1]+', ' + stream), sp[0], (rundir+sp[3]), runlistLoc, compare, browserMenu, allDirsScriptLoc) )
print("")
mN = sp[1].lstrip("lowStat_")
mN = sp[1].removeprefix("lowStat_")
min10List.append( (sp[3], mN) )
elif sp[1].find("medStat")!=-1: # medium statistics interval
print("Running handi on " + sp[0] + ":")
print('handi("Run '+rN+ ', '+sp[1]+', ' + stream + '",' + sp[0] + ','+rundir+sp[3]+')')
_local_apply(handiWithComparisons, (('Run '+rN+ ', '+sp[1]+', ' + stream), sp[0], (rundir+sp[3]), runlistLoc, compare, browserMenu, allDirsScriptLoc))
print("")
mN = sp[1].lstrip("medStat_")
mN = sp[1].removeprefix("medStat_")
min30List.append( (sp[3], mN) )
#min10List.sort(key=lambda x: int(x[1]))
......
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
from __future__ import print_function
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
def _local_apply_core(func, args, q):
import os
try:
q.put(func(*args))
except BaseException as e:
except Exception as e:
q.put(e)
os._exit(1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment