From 47842a5d4eb0b8403f5afaa37ea98753153f133c Mon Sep 17 00:00:00 2001 From: afernand Date: Thu, 18 Jan 2024 09:26:17 +0100 Subject: [PATCH] Update minimum python version --- .github/workflows/ci_cd.yml | 2 +- pyproject.toml | 2 +- src/ansys/rocky/core/client.py | 16 +++++++--------- src/ansys/rocky/core/examples.py | 6 +++++- src/ansys/rocky/core/exceptions.py | 6 ++++-- src/ansys/rocky/core/launcher.py | 4 ++-- tests/test_examples.py | 1 + 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 7ceee9a0..69aba1db 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -28,7 +28,7 @@ jobs: python-version: ${{ env.MAIN_PYTHON_VERSION }} vale-config: "doc/.vale.ini" vale-version: "2.29.6" - + docs-style: name: Documentation Style Check runs-on: ubuntu-latest diff --git a/pyproject.toml b/pyproject.toml index 09cbdb0d..ffa63ede 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ version = "0.1.dev0" authors = [{ name="ANSYS, Inc.", email="pyansys.core@ansys.com" }] description = "A Python wrapper for Ansys Rocky PrePost UI" readme = "README.rst" -requires-python = ">=3.8,<4" +requires-python = ">=3.9,<4" license = { file = "LICENSE" } classifiers = [ "Development Status :: 4 - Beta", diff --git a/src/ansys/rocky/core/client.py b/src/ansys/rocky/core/client.py index 1f4431da..2274edeb 100644 --- a/src/ansys/rocky/core/client.py +++ b/src/ansys/rocky/core/client.py @@ -18,7 +18,7 @@ def connect_to_rocky(host: str = "localhost", port: int = 50615) -> "RockyClient The host name where the application is running, by default "localhost". port : int, optional The service port to connect, by default 50615. - + Returns ------- RockyClient @@ -33,12 +33,13 @@ def connect_to_rocky(host: str = "localhost", port: int = 50615) -> "RockyClient class RockyClient: """A client object to interact with the Rocky Application. - + Parameters ---------- rocky_api : Pyro5.api.Proxy The Pyro5 proxy object to interact with the Rocky Application. """ + def __init__(self, rocky_api): self._api_adapter = rocky_api @@ -52,7 +53,7 @@ def close(self): class _ApiElementProxy: """A proxy object for API Elements. - + Parameters ---------- pyro_api : Pyro5.api.Proxy @@ -60,6 +61,7 @@ class _ApiElementProxy: pool_id : int The ID of the API Element. """ + def __init__(self, pyro_api, pool_id): self._pool_id = pool_id self._pyro_api = pyro_api @@ -106,8 +108,7 @@ def serialize(cls, classname: str, obj) -> dict: class _ApiListProxy(_ApiElementProxy): - """A proxy object for API Elements that implement the sequence interface. - """ + """A proxy object for API Elements that implement the sequence interface.""" def __len__(self) -> int: return self._pyro_api.SendToApiElement(self._pool_id, "__len__") @@ -125,7 +126,7 @@ def __delitem__(self, index: int) -> None: def deserialize_api_error(classname: str, serialized: dict) -> RockyApiError: """Deserialize an API Error. - + Parameters ---------- serialized : dict @@ -162,6 +163,3 @@ def deserialize_numpy(classname, serialized) -> "Any": Pyro5.api.register_dict_to_class("ndarray", deserialize_numpy) Pyro5.api.register_class_to_dict(_ApiElementProxy, _ApiElementProxy.serialize) - - - diff --git a/src/ansys/rocky/core/examples.py b/src/ansys/rocky/core/examples.py index 2001ec50..98b593f2 100644 --- a/src/ansys/rocky/core/examples.py +++ b/src/ansys/rocky/core/examples.py @@ -10,7 +10,11 @@ ANSYS_EXAMPLE_DATA_REPO = "https://github.com/ansys/example-data/raw/master" -def _get_file_url(file_name: str, file_host: str = ANSYS_EXAMPLE_DATA_REPO, directory: Optional[str] = None) -> str: +def _get_file_url( + file_name: str, + file_host: str = ANSYS_EXAMPLE_DATA_REPO, + directory: Optional[str] = None, +) -> str: """Get file URL.""" if directory: return f"{file_host}/{directory}/{file_name}" diff --git a/src/ansys/rocky/core/exceptions.py b/src/ansys/rocky/core/exceptions.py index 20c83ac3..68fd1851 100644 --- a/src/ansys/rocky/core/exceptions.py +++ b/src/ansys/rocky/core/exceptions.py @@ -1,10 +1,12 @@ class PyRockyError(Exception): """Generic exception for PyRocky API""" + class RockyLaunchError(PyRockyError): """Raised for errors occurred during Rocky application launch""" - + + class RockyApiError(Exception): """ Exception class representing an error generated in the API layer. - """ \ No newline at end of file + """ diff --git a/src/ansys/rocky/core/launcher.py b/src/ansys/rocky/core/launcher.py index 300250c2..bb7d6a01 100644 --- a/src/ansys/rocky/core/launcher.py +++ b/src/ansys/rocky/core/launcher.py @@ -18,7 +18,7 @@ def launch_rocky( """ Launch Rocky executable with PyRocky server enabled, wait Rocky to start up and return a `RockyClient` instance. - + Parameters ---------- rocky_exe : Optional[Path], optional @@ -26,7 +26,7 @@ def launch_rocky( environment variables `AWP_ROOT241` and `AWP_ROOT232`. headless : bool, optional Whether to launch Rocky in headless mode. Default is `True`. - + Returns ------- RockyClient diff --git a/tests/test_examples.py b/tests/test_examples.py index 83763432..d3cb0bdb 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -8,6 +8,7 @@ ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) EXAMPLES_DIR = Path(os.path.join(ROOT_DIR, "examples")) + @pytest.mark.parametrize("example_path", list(EXAMPLES_DIR.rglob("*.py"))) def test_examples(example_path: Path) -> None: subprocess.check_call([sys.executable, str(example_path.absolute())])