From 7996a1eed04088709a3c76bebaf31aeeb40ca953 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 10:41:30 -0300 Subject: [PATCH 01/51] Testing version installed --- tests/test_pyrocky.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index f4fe351c..76cf7479 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,11 +19,12 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import os import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import DEFAULT_SERVER_PORT +from ansys.rocky.core.client import DEFAULT_SERVER_PORT, _ROCKY_VERSION from ansys.rocky.core.launcher import RockyLaunchError @@ -68,6 +69,11 @@ def test_minimal_simulation(rocky_session, tmp_path): assert any(pid_values), "Particle ID should not be a zero-array" assert len(pid_values) > 20, "Too few values for the grid function" + awp_roots = sorted( + [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True + ) + assert False, f"cur_version: {_ROCKY_VERSION}, all_versions: {awp_roots}" + def test_sequences_interface(rocky_session): """Ensure that API objects that are sequences have their dunder methods exposed.""" From 061ff7d519e28cf2af340bc3cd2d0c360a6f926e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 13:42:35 +0000 Subject: [PATCH 02/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 76cf7479..2e1409fe 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,7 @@ import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import DEFAULT_SERVER_PORT, _ROCKY_VERSION +from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError From 5c27e5fc8a38e9b014895f78452af9a8a643798a Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 11:08:18 -0300 Subject: [PATCH 03/51] Fix global --- tests/test_pyrocky.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 2e1409fe..f3f216d9 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,11 @@ import pytest import ansys.rocky.core as pyrocky +<<<<<<< Updated upstream from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT +======= +from ansys.rocky.core.client import DEFAULT_SERVER_PORT +>>>>>>> Stashed changes from ansys.rocky.core.launcher import RockyLaunchError @@ -69,6 +73,7 @@ def test_minimal_simulation(rocky_session, tmp_path): assert any(pid_values), "Particle ID should not be a zero-array" assert len(pid_values) > 20, "Too few values for the grid function" + global _ROCKY_VERSION awp_roots = sorted( [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True ) From 66acbf4cbcb68ec90709c5f0527d8a947a652632 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:09:10 +0000 Subject: [PATCH 04/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index f3f216d9..6bed9ac8 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,10 +24,13 @@ import pytest import ansys.rocky.core as pyrocky + <<<<<<< Updated upstream from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT + ======= from ansys.rocky.core.client import DEFAULT_SERVER_PORT + >>>>>>> Stashed changes from ansys.rocky.core.launcher import RockyLaunchError From b53306b9a618c37c2ce2c3b37740268c708ee989 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 11:11:45 -0300 Subject: [PATCH 05/51] Fixed import --- tests/test_pyrocky.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 6bed9ac8..08a967e3 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -25,13 +25,8 @@ import ansys.rocky.core as pyrocky -<<<<<<< Updated upstream -from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT - -======= from ansys.rocky.core.client import DEFAULT_SERVER_PORT ->>>>>>> Stashed changes from ansys.rocky.core.launcher import RockyLaunchError From 1c203908e14486aef70ba860dd9a0efbcb9665c2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:12:00 +0000 Subject: [PATCH 06/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 08a967e3..d04484c0 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,9 +24,7 @@ import pytest import ansys.rocky.core as pyrocky - from ansys.rocky.core.client import DEFAULT_SERVER_PORT - from ansys.rocky.core.launcher import RockyLaunchError From a346389212198b39e57dfd742b622e31300735e3 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 11:19:28 -0300 Subject: [PATCH 07/51] Another small fix --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index d04484c0..ea8abcaa 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,7 @@ import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import DEFAULT_SERVER_PORT +from ansys.rocky.core.client import DEFAULT_SERVER_PORT, _ROCKY_VERSION from ansys.rocky.core.launcher import RockyLaunchError From 130aa3a5f222a09fba78d4f4e7cad1540f6da483 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:19:42 +0000 Subject: [PATCH 08/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index ea8abcaa..cdc6ee78 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,7 @@ import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import DEFAULT_SERVER_PORT, _ROCKY_VERSION +from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError From a76ff2ea5db3387bcf157804f6d5f35dc8e70314 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 11:28:17 -0300 Subject: [PATCH 09/51] another small fix --- src/ansys/rocky/core/client.py | 2 +- tests/test_pyrocky.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ansys/rocky/core/client.py b/src/ansys/rocky/core/client.py index 6079eb42..e2d04119 100644 --- a/src/ansys/rocky/core/client.py +++ b/src/ansys/rocky/core/client.py @@ -104,7 +104,7 @@ def _get_numerical_version(rocky_api: Pyro5.api.Proxy) -> int: assert rocky_api is not None, "API Proxy not initialized" try: # From 25.1 onwards we may use this to obtain the current rocky version. - rocky_version = _ROCKY_API.GetVersion().split(".") + rocky_version = rocky_api.GetVersion().split(".") return int(rocky_version[0] + rocky_version[1]) # major + minor except: # The rocky version is older than 25.1, the specific version is not really diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index cdc6ee78..d18590cb 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,7 @@ import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT +from ansys.rocky.core.client import DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError @@ -69,6 +69,7 @@ def test_minimal_simulation(rocky_session, tmp_path): assert any(pid_values), "Particle ID should not be a zero-array" assert len(pid_values) > 20, "Too few values for the grid function" + from ansys.rocky.core.client import _ROCKY_VERSION global _ROCKY_VERSION awp_roots = sorted( [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True From 8660ed9f2eae69c5ed257c69fd3e29d413b680df Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:29:48 +0000 Subject: [PATCH 10/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index d18590cb..68d5fa1c 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -70,6 +70,7 @@ def test_minimal_simulation(rocky_session, tmp_path): assert len(pid_values) > 20, "Too few values for the grid function" from ansys.rocky.core.client import _ROCKY_VERSION + global _ROCKY_VERSION awp_roots = sorted( [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True From 7b3548b07fa1a4019a57caae4b9ea3731ec17418 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Mon, 8 Jul 2024 17:43:33 -0300 Subject: [PATCH 11/51] Add exporttoolkit test --- tests/test_pyrocky.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 68d5fa1c..d04d9a24 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -26,6 +26,8 @@ import ansys.rocky.core as pyrocky from ansys.rocky.core.client import DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError +from ansys.rocky.core.rocky_api_proxies import ApiExportToolkitProxy +from pathlib import Path @pytest.fixture() @@ -102,6 +104,34 @@ def test_sequences_interface(rocky_session): assert {e.GetName() for e in inlets_outlets} == {"Inlet2"} +def test_export_toolkit(rocky_session, tmp_path): + rocky = pyrocky.connect_to_rocky() + project = rocky.api.CreateProject() + + study = project.GetStudy() + particle = study.CreateParticle() + + inlet_surface = study.CreateCircularSurface() + study.CreateParticleInlet(entry_point=inlet_surface, particle=particle) + + domain = study.GetDomainSettings() + domain.DisableUseBoundaryLimits() + domain.SetCoordinateLimitsMaxValues((10, 1, 10)) + + solver = study.GetSolver() + solver.SetSimulationDuration(2) # Simulate for 2 sec. + + project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) + study.StartSimulation() + + export_toolkit = study.GetExportToolkit() + assert isinstance(export_toolkit, ApiExportToolkitProxy) + + stl_to_save = str(tmp_path / "particles_as_stl.stl") + export_toolkit.ExportParticleToStl(stl_to_save, 'Particle <1>') + assert Path(stl_to_save).is_file() + + def test_pyrocky_launch_multiple_servers(): """ Test that start multiple rocky servers is not allowed. From d3325d688c99c9a2bb4fe4e28e2f93068bdbcd8b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 20:44:37 +0000 Subject: [PATCH 12/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index d04d9a24..69961164 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -20,6 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import os +from pathlib import Path import pytest @@ -27,7 +28,6 @@ from ansys.rocky.core.client import DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError from ansys.rocky.core.rocky_api_proxies import ApiExportToolkitProxy -from pathlib import Path @pytest.fixture() @@ -128,7 +128,7 @@ def test_export_toolkit(rocky_session, tmp_path): assert isinstance(export_toolkit, ApiExportToolkitProxy) stl_to_save = str(tmp_path / "particles_as_stl.stl") - export_toolkit.ExportParticleToStl(stl_to_save, 'Particle <1>') + export_toolkit.ExportParticleToStl(stl_to_save, "Particle <1>") assert Path(stl_to_save).is_file() From 5bc14972e2a9d350db96df1cf93577fae42336e6 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Mon, 8 Jul 2024 17:46:50 -0300 Subject: [PATCH 13/51] Fix some leftovers --- tests/test_pyrocky.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 69961164..800a8c8d 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,7 +19,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import os from pathlib import Path import pytest @@ -71,14 +70,6 @@ def test_minimal_simulation(rocky_session, tmp_path): assert any(pid_values), "Particle ID should not be a zero-array" assert len(pid_values) > 20, "Too few values for the grid function" - from ansys.rocky.core.client import _ROCKY_VERSION - - global _ROCKY_VERSION - awp_roots = sorted( - [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True - ) - assert False, f"cur_version: {_ROCKY_VERSION}, all_versions: {awp_roots}" - def test_sequences_interface(rocky_session): """Ensure that API objects that are sequences have their dunder methods exposed.""" From 5e4b68177e8f0eb514fad5e2d88464524463509c Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 09:27:42 -0300 Subject: [PATCH 14/51] Fixed test --- tests/test_pyrocky.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 800a8c8d..2a14dbc5 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -110,7 +110,8 @@ def test_export_toolkit(rocky_session, tmp_path): domain.SetCoordinateLimitsMaxValues((10, 1, 10)) solver = study.GetSolver() - solver.SetSimulationDuration(2) # Simulate for 2 sec. + solver.SetSimulationDuration(0.1) # Simulate for 0.1 sec. + solver.SetTimeInterval(0.1, 's') # With 0.1 sec as timestep. project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) study.StartSimulation() @@ -119,7 +120,7 @@ def test_export_toolkit(rocky_session, tmp_path): assert isinstance(export_toolkit, ApiExportToolkitProxy) stl_to_save = str(tmp_path / "particles_as_stl.stl") - export_toolkit.ExportParticleToStl(stl_to_save, "Particle <1>") + export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") assert Path(stl_to_save).is_file() From 4a441a6700dfd82b81825be7b443e5d1adbb34fb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:28:01 +0000 Subject: [PATCH 15/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 2a14dbc5..e517db78 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -111,7 +111,7 @@ def test_export_toolkit(rocky_session, tmp_path): solver = study.GetSolver() solver.SetSimulationDuration(0.1) # Simulate for 0.1 sec. - solver.SetTimeInterval(0.1, 's') # With 0.1 sec as timestep. + solver.SetTimeInterval(0.1, "s") # With 0.1 sec as timestep. project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) study.StartSimulation() From 69b6e76699c14265f15c7ea947679b96ba365681 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 09:54:51 -0300 Subject: [PATCH 16/51] test tinkering --- tests/test_pyrocky.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index e517db78..d0aac7f4 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,6 +19,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import time from pathlib import Path import pytest @@ -121,6 +122,8 @@ def test_export_toolkit(rocky_session, tmp_path): stl_to_save = str(tmp_path / "particles_as_stl.stl") export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") + + time.sleep(1) assert Path(stl_to_save).is_file() From 7af4bef37edea43f859ed55b547d579e680c5dfd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:55:10 +0000 Subject: [PATCH 17/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index d0aac7f4..27052b26 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,8 +19,8 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import time from pathlib import Path +import time import pytest From 9279f72ddc8a7c92e3fe5659c00aaa7fb0611258 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 10:43:43 -0300 Subject: [PATCH 18/51] testing the ci --- tests/test_pyrocky.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 27052b26..900c68b1 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -124,6 +124,11 @@ def test_export_toolkit(rocky_session, tmp_path): export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") time.sleep(1) + + from os import listdir + from os.path import isfile, join + onlyfiles = [f for f in listdir(tmp_path) if isfile(join(tmp_path, f))] + assert False, f"{onlyfiles}" assert Path(stl_to_save).is_file() From dcc19300f4df53482c7b3fc3a294bc37e4a876f0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:45:27 +0000 Subject: [PATCH 19/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 900c68b1..56c4557e 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -127,6 +127,7 @@ def test_export_toolkit(rocky_session, tmp_path): from os import listdir from os.path import isfile, join + onlyfiles = [f for f in listdir(tmp_path) if isfile(join(tmp_path, f))] assert False, f"{onlyfiles}" assert Path(stl_to_save).is_file() From 581c979b0b1be3bd025e6183113094a2b4bd59f6 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 12:32:08 -0300 Subject: [PATCH 20/51] fixing test --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 56c4557e..f0734056 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -128,7 +128,7 @@ def test_export_toolkit(rocky_session, tmp_path): from os import listdir from os.path import isfile, join - onlyfiles = [f for f in listdir(tmp_path) if isfile(join(tmp_path, f))] + onlyfiles = [f for f in listdir(tmp_path)] assert False, f"{onlyfiles}" assert Path(stl_to_save).is_file() From bdd51de744ee36bdb124473848c23e3257a9e869 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 13:53:29 -0300 Subject: [PATCH 21/51] testing --- tests/test_pyrocky.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index f0734056..b6546bc6 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -122,6 +122,7 @@ def test_export_toolkit(rocky_session, tmp_path): stl_to_save = str(tmp_path / "particles_as_stl.stl") export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") + inlets = study.GetInletsOutletsCollection() time.sleep(1) @@ -129,7 +130,7 @@ def test_export_toolkit(rocky_session, tmp_path): from os.path import isfile, join onlyfiles = [f for f in listdir(tmp_path)] - assert False, f"{onlyfiles}" + assert False, f"stl_filename:{stl_to_save}\nall_files:{onlyfiles}" assert Path(stl_to_save).is_file() From 034aaea0188c2002b84b2f66ce0e76e892c64074 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 14:23:55 -0300 Subject: [PATCH 22/51] testing 2 --- tests/test_pyrocky.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index b6546bc6..a84a4ae6 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -125,6 +125,7 @@ def test_export_toolkit(rocky_session, tmp_path): inlets = study.GetInletsOutletsCollection() time.sleep(1) + project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) from os import listdir from os.path import isfile, join From b6084a8368c643a33c4a405a95c7fef19a3b2ccb Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Wed, 10 Jul 2024 10:25:06 -0300 Subject: [PATCH 23/51] improve tests --- tests/test_pyrocky.py | 48 +++++++++++++------------------------------ 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index a84a4ae6..52cb6998 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -37,9 +37,10 @@ def rocky_session(): rocky.close() -def test_minimal_simulation(rocky_session, tmp_path): - rocky = pyrocky.connect_to_rocky() - project = rocky.api.CreateProject() +def _create_basic_project_with_results(rocky_api, project_filename, simulation_duration: float = 2, time_interval: float = 0.25): + """Helper to create a basic scenario. Returns the study proxy. + """ + project = rocky_api.CreateProject() assert project, "No project created" study = project.GetStudy() @@ -53,10 +54,17 @@ def test_minimal_simulation(rocky_session, tmp_path): domain.SetCoordinateLimitsMaxValues((10, 1, 10)) solver = study.GetSolver() - solver.SetSimulationDuration(2) # Simulate for 2 sec. + solver.SetSimulationDuration(simulation_duration) + solver.SetTimeInterval(time_interval, "s") - project.SaveProject(str(tmp_path / "rocky-testing.rocky")) + project.SaveProject(project_filename) study.StartSimulation() + return study + + +def test_minimal_simulation(rocky_session, tmp_path): + rocky = pyrocky.connect_to_rocky() + study = _create_basic_project_with_results(rocky.api, str(tmp_path / "rocky-testing.rocky")) seconds = study.GetTimeSet() assert seconds[-1] > 1.75 @@ -98,41 +106,13 @@ def test_sequences_interface(rocky_session): def test_export_toolkit(rocky_session, tmp_path): rocky = pyrocky.connect_to_rocky() - project = rocky.api.CreateProject() - - study = project.GetStudy() - particle = study.CreateParticle() - - inlet_surface = study.CreateCircularSurface() - study.CreateParticleInlet(entry_point=inlet_surface, particle=particle) - - domain = study.GetDomainSettings() - domain.DisableUseBoundaryLimits() - domain.SetCoordinateLimitsMaxValues((10, 1, 10)) - - solver = study.GetSolver() - solver.SetSimulationDuration(0.1) # Simulate for 0.1 sec. - solver.SetTimeInterval(0.1, "s") # With 0.1 sec as timestep. - - project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) - study.StartSimulation() + study = _create_basic_project_with_results(rocky.api, str(tmp_path / "rocky-testing-export.rocky"), simulation_duration=0.1, time_interval=0.1) export_toolkit = study.GetExportToolkit() assert isinstance(export_toolkit, ApiExportToolkitProxy) stl_to_save = str(tmp_path / "particles_as_stl.stl") export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") - inlets = study.GetInletsOutletsCollection() - - time.sleep(1) - project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) - - from os import listdir - from os.path import isfile, join - - onlyfiles = [f for f in listdir(tmp_path)] - assert False, f"stl_filename:{stl_to_save}\nall_files:{onlyfiles}" - assert Path(stl_to_save).is_file() def test_pyrocky_launch_multiple_servers(): From 4e9d0f3729591b28270c88205703057568e255f4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 10 Jul 2024 13:25:16 +0000 Subject: [PATCH 24/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 52cb6998..088767d5 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -37,9 +37,13 @@ def rocky_session(): rocky.close() -def _create_basic_project_with_results(rocky_api, project_filename, simulation_duration: float = 2, time_interval: float = 0.25): - """Helper to create a basic scenario. Returns the study proxy. - """ +def _create_basic_project_with_results( + rocky_api, + project_filename, + simulation_duration: float = 2, + time_interval: float = 0.25, +): + """Helper to create a basic scenario. Returns the study proxy.""" project = rocky_api.CreateProject() assert project, "No project created" @@ -64,7 +68,9 @@ def _create_basic_project_with_results(rocky_api, project_filename, simulation_d def test_minimal_simulation(rocky_session, tmp_path): rocky = pyrocky.connect_to_rocky() - study = _create_basic_project_with_results(rocky.api, str(tmp_path / "rocky-testing.rocky")) + study = _create_basic_project_with_results( + rocky.api, str(tmp_path / "rocky-testing.rocky") + ) seconds = study.GetTimeSet() assert seconds[-1] > 1.75 @@ -106,7 +112,12 @@ def test_sequences_interface(rocky_session): def test_export_toolkit(rocky_session, tmp_path): rocky = pyrocky.connect_to_rocky() - study = _create_basic_project_with_results(rocky.api, str(tmp_path / "rocky-testing-export.rocky"), simulation_duration=0.1, time_interval=0.1) + study = _create_basic_project_with_results( + rocky.api, + str(tmp_path / "rocky-testing-export.rocky"), + simulation_duration=0.1, + time_interval=0.1, + ) export_toolkit = study.GetExportToolkit() assert isinstance(export_toolkit, ApiExportToolkitProxy) From fed168a15737dcdcbf450cb41e830679b334d98c Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Wed, 10 Jul 2024 10:37:25 -0300 Subject: [PATCH 25/51] fixed codespell --- tests/test_pyrocky.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 088767d5..dd02c1be 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,9 +19,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from pathlib import Path -import time - import pytest import ansys.rocky.core as pyrocky @@ -37,7 +34,7 @@ def rocky_session(): rocky.close() -def _create_basic_project_with_results( +def create_basic_project_with_results( rocky_api, project_filename, simulation_duration: float = 2, @@ -68,7 +65,7 @@ def _create_basic_project_with_results( def test_minimal_simulation(rocky_session, tmp_path): rocky = pyrocky.connect_to_rocky() - study = _create_basic_project_with_results( + study = create_basic_project_with_results( rocky.api, str(tmp_path / "rocky-testing.rocky") ) @@ -112,7 +109,7 @@ def test_sequences_interface(rocky_session): def test_export_toolkit(rocky_session, tmp_path): rocky = pyrocky.connect_to_rocky() - study = _create_basic_project_with_results( + study = create_basic_project_with_results( rocky.api, str(tmp_path / "rocky-testing-export.rocky"), simulation_duration=0.1, From ad4aa1b42863763e32a19f5dd50209aeb345b2e0 Mon Sep 17 00:00:00 2001 From: Augusto Finger Pacheco <44980634+fingeraugusto@users.noreply.github.com> Date: Thu, 11 Jul 2024 15:26:59 -0300 Subject: [PATCH 26/51] Added test for different app versions (#76) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- tests/test_pyrocky.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index f4fe351c..d65a5e61 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -34,8 +34,28 @@ def rocky_session(): rocky.close() -def test_minimal_simulation(rocky_session, tmp_path): +@pytest.mark.parametrize( + "version, expected_version", + [ + ("25.1", 251), + ("24.2", 240), + ], +) +def test_minimal_simulation(version, expected_version, tmp_path, request): + """Minimal test to be run with all the supported Rocky version to ensure + minimal backwards compatibility. + """ + short_v = version.replace(".", "") + exe_file = f"C:\\Program Files\\ANSYS Inc\\v{short_v}\\Rocky\\bin\\Rocky.exe" + pyrocky.launch_rocky(exe_file) rocky = pyrocky.connect_to_rocky() + request.addfinalizer(rocky.close) + + from ansys.rocky.core.client import _ROCKY_VERSION + + global _ROCKY_VERSION + assert _ROCKY_VERSION == expected_version + project = rocky.api.CreateProject() assert project, "No project created" From 64925ea5a87eaca5b7d281043b725cfd44e731cf Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 10:41:30 -0300 Subject: [PATCH 27/51] Testing version installed --- tests/test_pyrocky.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index d65a5e61..0ba9efc8 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,11 +19,12 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import os import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import DEFAULT_SERVER_PORT +from ansys.rocky.core.client import DEFAULT_SERVER_PORT, _ROCKY_VERSION from ansys.rocky.core.launcher import RockyLaunchError @@ -88,6 +89,11 @@ def test_minimal_simulation(version, expected_version, tmp_path, request): assert any(pid_values), "Particle ID should not be a zero-array" assert len(pid_values) > 20, "Too few values for the grid function" + awp_roots = sorted( + [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True + ) + assert False, f"cur_version: {_ROCKY_VERSION}, all_versions: {awp_roots}" + def test_sequences_interface(rocky_session): """Ensure that API objects that are sequences have their dunder methods exposed.""" From d2c165e00f786d6cfe59083584563563a94090bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 13:42:35 +0000 Subject: [PATCH 28/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 0ba9efc8..5db19e0b 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,7 @@ import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import DEFAULT_SERVER_PORT, _ROCKY_VERSION +from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError From 81f84438a44a42761a9d122bb901443b85c647ee Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 11:08:18 -0300 Subject: [PATCH 29/51] Fix global --- tests/test_pyrocky.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 5db19e0b..0995d97c 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,11 @@ import pytest import ansys.rocky.core as pyrocky +<<<<<<< Updated upstream from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT +======= +from ansys.rocky.core.client import DEFAULT_SERVER_PORT +>>>>>>> Stashed changes from ansys.rocky.core.launcher import RockyLaunchError @@ -89,6 +93,7 @@ def test_minimal_simulation(version, expected_version, tmp_path, request): assert any(pid_values), "Particle ID should not be a zero-array" assert len(pid_values) > 20, "Too few values for the grid function" + global _ROCKY_VERSION awp_roots = sorted( [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True ) From e1f12148c466954be43ffee84751b27bdb2f7672 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:09:10 +0000 Subject: [PATCH 30/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 0995d97c..ea609520 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,10 +24,13 @@ import pytest import ansys.rocky.core as pyrocky + <<<<<<< Updated upstream from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT + ======= from ansys.rocky.core.client import DEFAULT_SERVER_PORT + >>>>>>> Stashed changes from ansys.rocky.core.launcher import RockyLaunchError From b5fe43eba52541c9d08e95422a7caca0dad0b009 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 11:11:45 -0300 Subject: [PATCH 31/51] Fixed import --- tests/test_pyrocky.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index ea609520..ad62c284 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -25,13 +25,8 @@ import ansys.rocky.core as pyrocky -<<<<<<< Updated upstream -from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT - -======= from ansys.rocky.core.client import DEFAULT_SERVER_PORT ->>>>>>> Stashed changes from ansys.rocky.core.launcher import RockyLaunchError From 4813a8ff6ac6250f560c3e31cf7dd1d0130ffc30 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:12:00 +0000 Subject: [PATCH 32/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index ad62c284..373fad52 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,9 +24,7 @@ import pytest import ansys.rocky.core as pyrocky - from ansys.rocky.core.client import DEFAULT_SERVER_PORT - from ansys.rocky.core.launcher import RockyLaunchError From 13ce019667c042222c9849e00c6971f9bdeb96a1 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 11:19:28 -0300 Subject: [PATCH 33/51] Another small fix --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 373fad52..f63c2a50 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,7 @@ import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import DEFAULT_SERVER_PORT +from ansys.rocky.core.client import DEFAULT_SERVER_PORT, _ROCKY_VERSION from ansys.rocky.core.launcher import RockyLaunchError From f81767115e4ad7a3d265ba210f410302b96ba23e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:19:42 +0000 Subject: [PATCH 34/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index f63c2a50..71659aed 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,7 @@ import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import DEFAULT_SERVER_PORT, _ROCKY_VERSION +from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError From bef0087a2aec6e8929ceee2955359a53f2e7d295 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Fri, 5 Jul 2024 11:28:17 -0300 Subject: [PATCH 35/51] another small fix --- src/ansys/rocky/core/client.py | 2 +- tests/test_pyrocky.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ansys/rocky/core/client.py b/src/ansys/rocky/core/client.py index 6079eb42..e2d04119 100644 --- a/src/ansys/rocky/core/client.py +++ b/src/ansys/rocky/core/client.py @@ -104,7 +104,7 @@ def _get_numerical_version(rocky_api: Pyro5.api.Proxy) -> int: assert rocky_api is not None, "API Proxy not initialized" try: # From 25.1 onwards we may use this to obtain the current rocky version. - rocky_version = _ROCKY_API.GetVersion().split(".") + rocky_version = rocky_api.GetVersion().split(".") return int(rocky_version[0] + rocky_version[1]) # major + minor except: # The rocky version is older than 25.1, the specific version is not really diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 71659aed..60036880 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -24,7 +24,7 @@ import pytest import ansys.rocky.core as pyrocky -from ansys.rocky.core.client import _ROCKY_VERSION, DEFAULT_SERVER_PORT +from ansys.rocky.core.client import DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError @@ -89,6 +89,7 @@ def test_minimal_simulation(version, expected_version, tmp_path, request): assert any(pid_values), "Particle ID should not be a zero-array" assert len(pid_values) > 20, "Too few values for the grid function" + from ansys.rocky.core.client import _ROCKY_VERSION global _ROCKY_VERSION awp_roots = sorted( [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True From 91d6cc8fdac7ce9bb4aea3a45c623e29470ef256 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:29:48 +0000 Subject: [PATCH 36/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 60036880..031c7b20 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -90,6 +90,7 @@ def test_minimal_simulation(version, expected_version, tmp_path, request): assert len(pid_values) > 20, "Too few values for the grid function" from ansys.rocky.core.client import _ROCKY_VERSION + global _ROCKY_VERSION awp_roots = sorted( [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True From b799aeb5e982ed7fde33c4a2b62e8949ee24e1e6 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Mon, 8 Jul 2024 17:43:33 -0300 Subject: [PATCH 37/51] Add exporttoolkit test --- tests/test_pyrocky.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 031c7b20..3f4dc5b5 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -26,6 +26,8 @@ import ansys.rocky.core as pyrocky from ansys.rocky.core.client import DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError +from ansys.rocky.core.rocky_api_proxies import ApiExportToolkitProxy +from pathlib import Path @pytest.fixture() @@ -122,6 +124,34 @@ def test_sequences_interface(rocky_session): assert {e.GetName() for e in inlets_outlets} == {"Inlet2"} +def test_export_toolkit(rocky_session, tmp_path): + rocky = pyrocky.connect_to_rocky() + project = rocky.api.CreateProject() + + study = project.GetStudy() + particle = study.CreateParticle() + + inlet_surface = study.CreateCircularSurface() + study.CreateParticleInlet(entry_point=inlet_surface, particle=particle) + + domain = study.GetDomainSettings() + domain.DisableUseBoundaryLimits() + domain.SetCoordinateLimitsMaxValues((10, 1, 10)) + + solver = study.GetSolver() + solver.SetSimulationDuration(2) # Simulate for 2 sec. + + project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) + study.StartSimulation() + + export_toolkit = study.GetExportToolkit() + assert isinstance(export_toolkit, ApiExportToolkitProxy) + + stl_to_save = str(tmp_path / "particles_as_stl.stl") + export_toolkit.ExportParticleToStl(stl_to_save, 'Particle <1>') + assert Path(stl_to_save).is_file() + + def test_pyrocky_launch_multiple_servers(): """ Test that start multiple rocky servers is not allowed. From fac6dfc4e226d21cca5390294450f8ec4436d420 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 20:44:37 +0000 Subject: [PATCH 38/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 3f4dc5b5..2f345167 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -20,6 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. import os +from pathlib import Path import pytest @@ -27,7 +28,6 @@ from ansys.rocky.core.client import DEFAULT_SERVER_PORT from ansys.rocky.core.launcher import RockyLaunchError from ansys.rocky.core.rocky_api_proxies import ApiExportToolkitProxy -from pathlib import Path @pytest.fixture() @@ -148,7 +148,7 @@ def test_export_toolkit(rocky_session, tmp_path): assert isinstance(export_toolkit, ApiExportToolkitProxy) stl_to_save = str(tmp_path / "particles_as_stl.stl") - export_toolkit.ExportParticleToStl(stl_to_save, 'Particle <1>') + export_toolkit.ExportParticleToStl(stl_to_save, "Particle <1>") assert Path(stl_to_save).is_file() From a5740d6cdf1452f8134b452be05f5d6b9e983c3e Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Mon, 8 Jul 2024 17:46:50 -0300 Subject: [PATCH 39/51] Fix some leftovers --- tests/test_pyrocky.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 2f345167..1b02ce3b 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,7 +19,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import os from pathlib import Path import pytest @@ -91,14 +90,6 @@ def test_minimal_simulation(version, expected_version, tmp_path, request): assert any(pid_values), "Particle ID should not be a zero-array" assert len(pid_values) > 20, "Too few values for the grid function" - from ansys.rocky.core.client import _ROCKY_VERSION - - global _ROCKY_VERSION - awp_roots = sorted( - [k for k in os.environ.keys() if k.startswith("AWP_ROOT")], reverse=True - ) - assert False, f"cur_version: {_ROCKY_VERSION}, all_versions: {awp_roots}" - def test_sequences_interface(rocky_session): """Ensure that API objects that are sequences have their dunder methods exposed.""" From b49853bbd0c70bedd8f472a0f0a6672b883c5fd1 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 09:27:42 -0300 Subject: [PATCH 40/51] Fixed test --- tests/test_pyrocky.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 1b02ce3b..eaacb4f7 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -130,7 +130,8 @@ def test_export_toolkit(rocky_session, tmp_path): domain.SetCoordinateLimitsMaxValues((10, 1, 10)) solver = study.GetSolver() - solver.SetSimulationDuration(2) # Simulate for 2 sec. + solver.SetSimulationDuration(0.1) # Simulate for 0.1 sec. + solver.SetTimeInterval(0.1, 's') # With 0.1 sec as timestep. project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) study.StartSimulation() @@ -139,7 +140,7 @@ def test_export_toolkit(rocky_session, tmp_path): assert isinstance(export_toolkit, ApiExportToolkitProxy) stl_to_save = str(tmp_path / "particles_as_stl.stl") - export_toolkit.ExportParticleToStl(stl_to_save, "Particle <1>") + export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") assert Path(stl_to_save).is_file() From 8af6419cfa5e43587752cfbdd8d78832736f50dc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:28:01 +0000 Subject: [PATCH 41/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index eaacb4f7..8a1cd473 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -131,7 +131,7 @@ def test_export_toolkit(rocky_session, tmp_path): solver = study.GetSolver() solver.SetSimulationDuration(0.1) # Simulate for 0.1 sec. - solver.SetTimeInterval(0.1, 's') # With 0.1 sec as timestep. + solver.SetTimeInterval(0.1, "s") # With 0.1 sec as timestep. project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) study.StartSimulation() From 44612ed908ecfa54bf333a260cfe8b34fd331e50 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 09:54:51 -0300 Subject: [PATCH 42/51] test tinkering --- tests/test_pyrocky.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 8a1cd473..bc16a308 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,6 +19,7 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +import time from pathlib import Path import pytest @@ -141,6 +142,8 @@ def test_export_toolkit(rocky_session, tmp_path): stl_to_save = str(tmp_path / "particles_as_stl.stl") export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") + + time.sleep(1) assert Path(stl_to_save).is_file() From 8ec260d6159e95d7aa51092f3c3fcf31fe6d7790 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:55:10 +0000 Subject: [PATCH 43/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index bc16a308..9c0a3f70 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,8 +19,8 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -import time from pathlib import Path +import time import pytest From 9000423d88a8249b45182fbd8d97103f9ee46df2 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 10:43:43 -0300 Subject: [PATCH 44/51] testing the ci --- tests/test_pyrocky.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 9c0a3f70..52cc4a40 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -144,6 +144,11 @@ def test_export_toolkit(rocky_session, tmp_path): export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") time.sleep(1) + + from os import listdir + from os.path import isfile, join + onlyfiles = [f for f in listdir(tmp_path) if isfile(join(tmp_path, f))] + assert False, f"{onlyfiles}" assert Path(stl_to_save).is_file() From ba62ee81dc7b1d8cea133f0a0c40fbcc5df12d3c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:45:27 +0000 Subject: [PATCH 45/51] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_pyrocky.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 52cc4a40..9cf9b3b0 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -147,6 +147,7 @@ def test_export_toolkit(rocky_session, tmp_path): from os import listdir from os.path import isfile, join + onlyfiles = [f for f in listdir(tmp_path) if isfile(join(tmp_path, f))] assert False, f"{onlyfiles}" assert Path(stl_to_save).is_file() From f3a2d3fdf9db82ae03a098ba66a285a79e2c8d74 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 12:32:08 -0300 Subject: [PATCH 46/51] fixing test --- tests/test_pyrocky.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 9cf9b3b0..09aaa447 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -148,7 +148,7 @@ def test_export_toolkit(rocky_session, tmp_path): from os import listdir from os.path import isfile, join - onlyfiles = [f for f in listdir(tmp_path) if isfile(join(tmp_path, f))] + onlyfiles = [f for f in listdir(tmp_path)] assert False, f"{onlyfiles}" assert Path(stl_to_save).is_file() From 1ec02bde6a2fa477b4fa92958c0ea5e95972aa65 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 13:53:29 -0300 Subject: [PATCH 47/51] testing --- tests/test_pyrocky.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 09aaa447..87940530 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -142,6 +142,7 @@ def test_export_toolkit(rocky_session, tmp_path): stl_to_save = str(tmp_path / "particles_as_stl.stl") export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") + inlets = study.GetInletsOutletsCollection() time.sleep(1) @@ -149,7 +150,7 @@ def test_export_toolkit(rocky_session, tmp_path): from os.path import isfile, join onlyfiles = [f for f in listdir(tmp_path)] - assert False, f"{onlyfiles}" + assert False, f"stl_filename:{stl_to_save}\nall_files:{onlyfiles}" assert Path(stl_to_save).is_file() From badd4680c7d37948b69f55095d973a86a552845c Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Tue, 9 Jul 2024 14:23:55 -0300 Subject: [PATCH 48/51] testing 2 --- tests/test_pyrocky.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 87940530..6318c13b 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -145,6 +145,7 @@ def test_export_toolkit(rocky_session, tmp_path): inlets = study.GetInletsOutletsCollection() time.sleep(1) + project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) from os import listdir from os.path import isfile, join From 24d8372de7cd9f80d90928573be02157f2902625 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Wed, 10 Jul 2024 10:25:06 -0300 Subject: [PATCH 49/51] Improve tests --- tests/test_pyrocky.py | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index 6318c13b..f0ad6a1c 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -118,41 +118,13 @@ def test_sequences_interface(rocky_session): def test_export_toolkit(rocky_session, tmp_path): rocky = pyrocky.connect_to_rocky() - project = rocky.api.CreateProject() - - study = project.GetStudy() - particle = study.CreateParticle() - - inlet_surface = study.CreateCircularSurface() - study.CreateParticleInlet(entry_point=inlet_surface, particle=particle) - - domain = study.GetDomainSettings() - domain.DisableUseBoundaryLimits() - domain.SetCoordinateLimitsMaxValues((10, 1, 10)) - - solver = study.GetSolver() - solver.SetSimulationDuration(0.1) # Simulate for 0.1 sec. - solver.SetTimeInterval(0.1, "s") # With 0.1 sec as timestep. - - project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) - study.StartSimulation() + study = _create_basic_project_with_results(rocky.api, str(tmp_path / "rocky-testing-export.rocky"), simulation_duration=0.1, time_interval=0.1) export_toolkit = study.GetExportToolkit() assert isinstance(export_toolkit, ApiExportToolkitProxy) stl_to_save = str(tmp_path / "particles_as_stl.stl") export_toolkit.ExportParticleToStl(stl_to_save, "Particle <01>") - inlets = study.GetInletsOutletsCollection() - - time.sleep(1) - project.SaveProject(str(tmp_path / "rocky-testing-export.rocky")) - - from os import listdir - from os.path import isfile, join - - onlyfiles = [f for f in listdir(tmp_path)] - assert False, f"stl_filename:{stl_to_save}\nall_files:{onlyfiles}" - assert Path(stl_to_save).is_file() def test_pyrocky_launch_multiple_servers(): From fb9840c94a6827c1475f4c7b81f1cd9059460d01 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Wed, 10 Jul 2024 10:37:25 -0300 Subject: [PATCH 50/51] fixed codespell --- tests/test_pyrocky.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index f0ad6a1c..d627a9b0 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -19,9 +19,6 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -from pathlib import Path -import time - import pytest import ansys.rocky.core as pyrocky @@ -118,7 +115,12 @@ def test_sequences_interface(rocky_session): def test_export_toolkit(rocky_session, tmp_path): rocky = pyrocky.connect_to_rocky() - study = _create_basic_project_with_results(rocky.api, str(tmp_path / "rocky-testing-export.rocky"), simulation_duration=0.1, time_interval=0.1) + study = create_basic_project_with_results( + rocky.api, + str(tmp_path / "rocky-testing-export.rocky"), + simulation_duration=0.1, + time_interval=0.1, + ) export_toolkit = study.GetExportToolkit() assert isinstance(export_toolkit, ApiExportToolkitProxy) From 59abbeb3d1210ae05a6dd874bf2f4bcf36fa52c7 Mon Sep 17 00:00:00 2001 From: Augusto Pacheco Date: Thu, 11 Jul 2024 15:37:27 -0300 Subject: [PATCH 51/51] Rebased with main --- tests/test_pyrocky.py | 50 +++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/tests/test_pyrocky.py b/tests/test_pyrocky.py index d627a9b0..83ee2552 100644 --- a/tests/test_pyrocky.py +++ b/tests/test_pyrocky.py @@ -34,6 +34,35 @@ def rocky_session(): rocky.close() +def create_basic_project_with_results( + rocky_api, + project_filename, + simulation_duration: float = 2, + time_interval: float = 0.25, +): + """Helper to create a basic scenario. Returns the study proxy.""" + project = rocky_api.CreateProject() + assert project, "No project created" + + study = project.GetStudy() + particle = study.CreateParticle() + + inlet_surface = study.CreateCircularSurface() + study.CreateParticleInlet(entry_point=inlet_surface, particle=particle) + + domain = study.GetDomainSettings() + domain.DisableUseBoundaryLimits() + domain.SetCoordinateLimitsMaxValues((10, 1, 10)) + + solver = study.GetSolver() + solver.SetSimulationDuration(simulation_duration) + solver.SetTimeInterval(time_interval, "s") + + project.SaveProject(project_filename) + study.StartSimulation() + return study + + @pytest.mark.parametrize( "version, expected_version", [ @@ -56,24 +85,9 @@ def test_minimal_simulation(version, expected_version, tmp_path, request): global _ROCKY_VERSION assert _ROCKY_VERSION == expected_version - project = rocky.api.CreateProject() - assert project, "No project created" - - study = project.GetStudy() - particle = study.CreateParticle() - - inlet_surface = study.CreateCircularSurface() - study.CreateParticleInlet(entry_point=inlet_surface, particle=particle) - - domain = study.GetDomainSettings() - domain.DisableUseBoundaryLimits() - domain.SetCoordinateLimitsMaxValues((10, 1, 10)) - - solver = study.GetSolver() - solver.SetSimulationDuration(2) # Simulate for 2 sec. - - project.SaveProject(str(tmp_path / "rocky-testing.rocky")) - study.StartSimulation() + study = create_basic_project_with_results( + rocky.api, str(tmp_path / "rocky-testing.rocky") + ) seconds = study.GetTimeSet() assert seconds[-1] > 1.75