Skip to content

Commit

Permalink
Merge pull request #32 from qua-platform/lib_skip_node_error_on_scanning
Browse files Browse the repository at this point in the history
Show warning when exception occurs while scanning items
  • Loading branch information
maxim-v4s authored Sep 2, 2024
2 parents 9424c2f + f39517c commit 8340f14
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
16 changes: 13 additions & 3 deletions qualibrate/qualibration_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,15 @@ def scan_folder_for_instances(
for file in sorted(path.iterdir()):
if not file_is_calibration_instance(file, cls.__name__):
continue
cls.scan_graph_file(file, graphs)
try:
cls.scan_graph_file(file, graphs)
except Exception as e:
warnings.warn(
RuntimeWarning(
"An error occurred on scanning graph file "
f"{file.name}.\nError message: {e}"
)
)
finally:
cls.mode.inspection = inspection
return graphs
Expand Down Expand Up @@ -188,9 +196,11 @@ def completed_count(self) -> int:
)

def _get_all_nodes_parameters(
self, nodes_parameters: Mapping[str, Any]
self, nodes_parameters: Mapping[str, Any]
) -> Mapping[str, Any]:
nodes_class = self.full_parameters_class.model_fields["nodes"].annotation
nodes_class = self.full_parameters_class.model_fields[
"nodes"
].annotation
return {
name: nodes_parameters.get(name, {})
for name in cast(NodesParameters, nodes_class).model_fields.keys()
Expand Down
11 changes: 10 additions & 1 deletion qualibrate/qualibration_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,16 @@ def scan_folder_for_instances(
for file in sorted(path.iterdir()):
if not file_is_calibration_instance(file, cls.__name__):
continue
cls.scan_node_file(file, nodes)
try:
cls.scan_node_file(file, nodes)
except Exception as e:
warnings.warn(
RuntimeWarning(
"An error occurred on scanning node file "
f"{file.name}.\nError: {type(e)}: {e}"
)
)

finally:
cls.mode.inspection = inspection
return nodes
Expand Down

0 comments on commit 8340f14

Please sign in to comment.