From fc987ecb6cd715b9508e5d9cf2828b3da25e6f56 Mon Sep 17 00:00:00 2001 From: Roy Willy Haug Date: Fri, 22 Mar 2024 16:49:44 +0100 Subject: [PATCH] OpenVDS not supported on python 3.12 --- .github/workflows/run_tests.yaml | 2 +- pyproject.toml | 2 +- src/fmu/sumo/explorer/objects/cube.py | 9 +++------ tests/test_explorer.py | 20 +++++++++++++++----- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml index d0e7bbeb..1d57af5f 100644 --- a/.github/workflows/run_tests.yaml +++ b/.github/workflows/run_tests.yaml @@ -12,7 +12,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] os: [ubuntu-latest, windows-latest, macos-latest] permissions: contents: read diff --git a/pyproject.toml b/pyproject.toml index 63063483..30ac652e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ dependencies = [ "sumo-wrapper-python", "xtgeo", "pyarrow; python_version > '3.6.1'", - "OpenVDS; sys_platform != 'darwin'", + "OpenVDS; sys_platform != 'darwin' and python_version < '3.12'", ] [project.urls] diff --git a/src/fmu/sumo/explorer/objects/cube.py b/src/fmu/sumo/explorer/objects/cube.py index 021d794e..e14f0889 100644 --- a/src/fmu/sumo/explorer/objects/cube.py +++ b/src/fmu/sumo/explorer/objects/cube.py @@ -6,13 +6,10 @@ import sys import warnings -if sys.platform == "darwin": - try: - import openvds - except ImportError: - warnings.warn("OpenVDS is missing. Some Cube methods will not work.") -else: +try: import openvds +except ImportError: + warnings.warn("OpenVDS is missing. Some Cube methods will not work.") class Cube(Child): diff --git a/tests/test_explorer.py b/tests/test_explorer.py index 14284b09..272a5d5b 100644 --- a/tests/test_explorer.py +++ b/tests/test_explorer.py @@ -1,6 +1,9 @@ """Tests explorer""" + +from platform import python_version import sys -if not sys.platform.startswith('darwin'): + +if not sys.platform.startswith("darwin") and sys.version_info < (3, 12): import openvds import logging import json @@ -41,11 +44,13 @@ def fixture_case_uuid() -> str: """Returns case uuid""" return "2c2f47cf-c7ab-4112-87f9-b4797ec51cb6" + @pytest.fixture(name="seismic_case_uuid") def fixture_seismic_case_uuid() -> str: """Returns seismic case uuid""" return "c616019d-d344-4094-b2ee-dd4d6d336217" + @pytest.fixture(name="explorer") def fixture_explorer(token: str) -> Explorer: """Returns explorer""" @@ -269,7 +274,11 @@ def test_get_case_by_uuid(explorer: Explorer, case_uuid: str, case_name: str): assert case.uuid == case_uuid assert case.name == case_name -@pytest.mark.skipif(sys.platform.startswith('darwin'), reason="do not run OpenVDS SEGYImport on mac os") + +@pytest.mark.skipif( + sys.platform.startswith("darwin") or sys.version_info > (3, 11), + reason="do not run OpenVDS SEGYImport on mac os or python 3.12", +) def test_seismic_case_by_uuid(explorer: Explorer, seismic_case_uuid: str): """Test that explorer returns openvds compatible cubes for seismic case""" case = explorer.get_case_by_uuid(seismic_case_uuid) @@ -286,9 +295,10 @@ def test_seismic_case_by_uuid(explorer: Explorer, seismic_case_uuid: str): channel_list = [] for i in range(channel_count): channel_list.append(layout.getChannelName(i)) - assert 'Amplitude' in channel_list - assert 'Trace' in channel_list - assert 'SEGYTraceHeader' in channel_list + assert "Amplitude" in channel_list + assert "Trace" in channel_list + assert "SEGYTraceHeader" in channel_list + def test_utils_extend_query_object(utils: Utils): """Test extension of query"""