Skip to content

Commit b536607

Browse files
be-smithml-evs
authored andcommitted
Switched logger warnings to warnings.warn to show user useful messages
1 parent dcf0a1e commit b536607

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

pydatalab/src/pydatalab/apps/uvvis/__init__.py

+3-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from pydatalab.blocks.base import DataBlock
1010
from pydatalab.bokeh_plots import DATALAB_BOKEH_THEME, selectable_axes_plot
1111
from pydatalab.file_utils import get_file_info_by_id
12-
from pydatalab.logger import LOGGER
1312

1413

1514
class UVVisBlock(DataBlock):
@@ -80,7 +79,7 @@ def _format_UV_Vis_plot(
8079
input list is empty or plotting is skipped internally.
8180
"""
8281
if not absorbance_data_list:
83-
LOGGER.warning("Received an empty list of absorbance data. No plot generated.")
82+
warnings.warn("Received an empty list of absorbance data. No plot generated.")
8483
return None
8584

8685
# Basic validation of input data structure
@@ -138,7 +137,7 @@ def _format_UV_Vis_plot(
138137
def generate_absorbance_plot(self):
139138
absorbance_data = None
140139
if "selected_file_order" not in self.data:
141-
LOGGER.warning("No file set in the DataBlock - selected_file_order")
140+
warnings.warn("No file set in the DataBlock - selected_file_order")
142141
return
143142

144143
else:
@@ -154,12 +153,6 @@ def generate_absorbance_plot(self):
154153
ext = "".join(Path(file["location"]).suffixes).lower()
155154
# ext = os.path.splitext(file["location"].split("/")[-1])[-1].lower()
156155
if ext not in {ext.lower() for ext in self.accepted_file_extensions}:
157-
LOGGER.warning(
158-
"Unsupported file extension (must be one of %s, not %s)",
159-
self.accepted_file_extensions,
160-
ext,
161-
)
162-
163156
raise ValueError(
164157
f"Unsupported file extension (must be one of {self.accepted_file_extensions}, not {ext})"
165158
)
@@ -169,7 +162,7 @@ def generate_absorbance_plot(self):
169162
for file in file_info[1:]:
170163
sample_data = self.parse_uvvis_txt(Path(file["location"]))
171164
if sample_data is None or reference_data is None:
172-
LOGGER.warning("Could not parse the UV-Vis data files")
165+
warnings.warn("Could not parse the UV-Vis data files")
173166
return
174167
# Calculate absorbance
175168
absorbance_data.append(self.find_absorbance(sample_data, reference_data))

0 commit comments

Comments
 (0)