Skip to content

Commit

Permalink
Merge pull request ome#84 from sbesson/flake8
Browse files Browse the repository at this point in the history
Fix flake8 issue raised following the Rocky Linux 9 image upgrade
  • Loading branch information
jburel authored Jan 15, 2024
2 parents dd23237 + cd4f657 commit 358524c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
41 changes: 21 additions & 20 deletions src/omero_metadata/populate.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def resolve_plate(self, column, row, value):
try:
return self.plates_by_name[value].id.val
except KeyError:
log.warn('Screen is missing plate: %s' % value)
log.warning('Screen is missing plate: %s' % value)
return Skip()

def _load(self):
Expand All @@ -673,7 +673,8 @@ def _load(self):
self.plates_by_id = dict()
images_by_id = dict()
self.images_by_id[self.target_object.id.val] = images_by_id
for plate in (l.child for l in self.target_object.copyPlateLinks()):
plates = [link.child for link in self.target_object.copyPlateLinks()]
for plate in plates:
parameters = omero.sys.ParametersI()
parameters.addId(plate.id.val)
plate = query_service.findByQuery((
Expand Down Expand Up @@ -774,10 +775,10 @@ def resolve_roi(self, column, row, value):
try:
return self.rois_by_id[int(value)].id.val
except KeyError:
log.warn('Dataset is missing ROI: %s' % value)
log.warning('Dataset is missing ROI: %s' % value)
return -1
except ValueError:
log.warn('Wrong input type for ROI ID: %s' % value)
log.warning('Wrong input type for ROI ID: %s' % value)
return -1

def resolve_shape(self, value):
Expand All @@ -787,10 +788,10 @@ def resolve_shape(self, value):
try:
return self.shapes_by_id[int(value)].id.val
except KeyError:
log.warn('Dataset is missing Shape: %s' % value)
log.warning('Dataset is missing Shape: %s' % value)
return -1
except ValueError:
log.warn('Wrong input type for Shape ID: %s' % value)
log.warning('Wrong input type for Shape ID: %s' % value)
return -1

def get_image_id_by_name(self, iname, dname=None):
Expand Down Expand Up @@ -900,7 +901,7 @@ def resolve_dataset(self, column, row, value):
else:
return self.datasets_by_name[value].id.val
except KeyError:
log.warn('Project is missing dataset: %s' % value)
log.warning('Project is missing dataset: %s' % value)
return Skip()

def _load(self):
Expand Down Expand Up @@ -982,20 +983,20 @@ def resolve_shape(self, value):
try:
return self.shapes_by_id[int(value)].id.val
except KeyError:
log.warn('Image is missing Shape: %s' % value)
log.warning('Image is missing Shape: %s' % value)
return -1
except ValueError:
log.warn('Wrong input type for Shape ID: %s' % value)
log.warning('Wrong input type for Shape ID: %s' % value)
return -1

def resolve_roi(self, column, row, value):
try:
return self.rois_by_id[int(value)].id.val
except KeyError:
log.warn('Image is missing ROI: %s' % value)
log.warning('Image is missing ROI: %s' % value)
return -1
except ValueError:
log.warn('Wrong input type for ROI ID: %s' % value)
log.warning('Wrong input type for ROI ID: %s' % value)
return -1

def _load(self):
Expand Down Expand Up @@ -1035,7 +1036,7 @@ def _load(self):
rois_by_id[rid] = roi
shapes_by_id[shape.id.val] = shape
if unwrap(roi.name) in rois_by_name.keys():
log.warn('Conflicting ROI names.')
log.warning('Conflicting ROI names.')
self.ambiguous_naming = True
rois_by_name[unwrap(roi.name)] = roi
self.rois_by_id = rois_by_id
Expand Down Expand Up @@ -1153,7 +1154,7 @@ def preprocess_from_handle(self, data):
self.columns = self.header_resolver.create_columns()
log.debug('Columns: %r' % self.columns)
if len(self.columns) > MAX_COLUMN_COUNT:
log.warn("Column count exceeds max column count")
log.warning("Column count exceeds max column count")

self.preprocess_data(reader)

Expand Down Expand Up @@ -1366,7 +1367,7 @@ def post_process(self):
for column in self.columns:
columns_by_name[column.name.lower()] = column
if column.__class__ is PlateColumn:
log.warn("PlateColumn is unimplemented")
log.warning("PlateColumn is unimplemented")
elif column.__class__ is WellColumn:
well_column = column
elif column.name == WELL_NAME_COLUMN:
Expand Down Expand Up @@ -1416,7 +1417,7 @@ def post_process(self):
plate = columns_by_name["plate"].values[i]
v = self.value_resolver.get_well_name(well_id, plate)
except KeyError:
log.warn(
log.warning(
'Skipping table row %d! Missing well row or column '
'for well name population!' % i, exc_info=True
)
Expand Down Expand Up @@ -1444,7 +1445,7 @@ def post_process(self):
iname = self.value_resolver.get_image_name_by_id(
iid, did)
except KeyError:
log.warn(
log.warning(
"%d not found in image ids" % iid)
assert i == len(image_name_column.values)
image_name_column.values.append(iname)
Expand All @@ -1470,7 +1471,7 @@ def post_process(self):
iid = self.value_resolver.get_image_id_by_name(
iname, did)
except KeyError:
log.warn(
log.warning(
"%d not found in image ids" % iid)
assert i == len(image_column.values)
image_column.values.append(iid)
Expand Down Expand Up @@ -1509,7 +1510,7 @@ def post_process(self):
if rname is None:
rname = ""
except KeyError:
log.warn(
log.warning(
"%d not found in roi ids" % rid)
assert i == len(roi_name_column.values)
roi_name_column.values.append(rname)
Expand All @@ -1526,7 +1527,7 @@ def post_process(self):
rname = roi_name_column.values[i]
rid = self.value_resolver.get_roi_id_by_name(rname)
except KeyError:
log.warn(
log.warning(
"%d not found in roi names" % rname)
assert i == len(roi_column.values)
roi_column.values.append(rid)
Expand Down Expand Up @@ -1899,7 +1900,7 @@ def idcolumn_to_omeroclass(col):
targets.append(obj)
targets.extend(self._get_additional_targets(obj))
else:
log.warn("Invalid Id:%d found in row %s", row[n], row)
log.warning("Invalid Id:%d found in row %s", row[n], row)
if targets:
for tr in trs:
rowkvs = tr.transform(row)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/clitest/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ def test_deletebulkanns(self, capfd):
o = self.invoke(capfd)
assert "FileAnnotation:" in o

# Should be empty since it's deleted
# Should have no FileAnnotation since it's deleted
o = self.invoke(capfd)
assert len(o.strip()) == 0
assert "FileAnnotation:" not in o

@pytest.mark.parametrize('report', [False, True])
def test_measures(self, capfd, report):
Expand Down

0 comments on commit 358524c

Please sign in to comment.