From 7309331a05eecb9dd216b103214e27190665a662 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 28 Jul 2025 16:05:55 -0700 Subject: [PATCH 1/2] Create unsupported Conversion and skip --- omf/fileio/geoh5.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/omf/fileio/geoh5.py b/omf/fileio/geoh5.py index 760ec66..7de7816 100644 --- a/omf/fileio/geoh5.py +++ b/omf/fileio/geoh5.py @@ -25,9 +25,11 @@ Data, DataTypeEnum, FloatData, + GeometricDataConstants, IntegerData, NumericData, ReferencedData, + VisualParameters, ) from geoh5py.groups import ContainerGroup, PropertyGroup, RootGroup from geoh5py.objects import BlockModel, Curve, Grid2D, ObjectBase, Points, Surface @@ -245,7 +247,11 @@ def process_dependents( converter = get_conversion_map( child, workspace, compression=compression, parent=element ) + if isinstance(converter, KnownUnsupported): + continue + converted = getattr(converter, method)(child, **kwargs) + if isinstance(converted, list): children += converted else: @@ -305,6 +311,18 @@ def collect_attributes( return kwargs +class KnownUnsupported(BaseConversion): + """ + Conversion class that silently ignores unsupported conversions. + """ + + def from_omf(self, *_, **kwargs) -> dict: + return {} + + def from_geoh5(self, *_, **kwargs) -> dict: + return {} + + class DataConversion(BaseConversion): """ Conversion between :obj:`omf.data.Data` and @@ -1376,6 +1394,7 @@ def block_model_reordering(entity: BlockModel | VolumeElement, values: np.ndarra ContainerGroup: ContainerGroupConversion, Curve: CurveConversion, FloatData: ScalarDataConversion, + GeometricDataConstants: KnownUnsupported, Grid2D: SurfaceGridConversion, Int2Array: ArrayConversion, IntegerData: ScalarDataConversion, @@ -1392,6 +1411,7 @@ def block_model_reordering(entity: BlockModel | VolumeElement, values: np.ndarra Surface: SurfaceConversion, SurfaceElement: SurfaceConversion, Vector3Array: ArrayConversion, + VisualParameters: KnownUnsupported, VolumeElement: VolumeConversion, } From 338dddb2a1bc26c3c005b49ae3c92ec08983fd28 Mon Sep 17 00:00:00 2001 From: dominiquef Date: Mon, 28 Jul 2025 16:16:12 -0700 Subject: [PATCH 2/2] Add unitest --- tests/convert_pointset_test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/convert_pointset_test.py b/tests/convert_pointset_test.py index 3ca2cb9..6124424 100644 --- a/tests/convert_pointset_test.py +++ b/tests/convert_pointset_test.py @@ -18,7 +18,7 @@ import omf -def test_pointset_to_geoh5(tmp_path: Path): +def test_pointset_to_geoh5(tmp_path: Path, caplog): """Test pointset geometry validation""" colormap = omf.ColorArray( array=[ @@ -49,18 +49,24 @@ def test_pointset_to_geoh5(tmp_path: Path): file = str(tmp_path / "pointset.geoh5") omf.OMFWriter(orig_pts, file) + # Check that the file was created with Workspace(file) as workspace: geoh5_points = workspace.get_entity("Random Points")[0] np.testing.assert_array_almost_equal( np.r_[orig_pts.geometry.vertices.array], geoh5_points.vertices ) + geoh5_points.add_default_visual_parameters() data = geoh5_points.get_entity("rand data")[0] np.testing.assert_array_almost_equal(np.r_[orig_pts.data[0].array], data.values) converter = omf.fileio.geoh5.get_conversion_map(geoh5_points, workspace) - converted_omf = converter.from_geoh5(geoh5_points) + with caplog.at_level("WARNING"): + converted_omf = converter.from_geoh5(geoh5_points) + + assert len(caplog.text) == 0, "No warnings should be raised during conversion" + assert len(converted_omf.data) == 1 # Skip the visual parameters omf.fileio.utils.compare_elements(converted_omf, orig_pts) project = omf.fileio.geoh5.GeoH5Reader(file).project