Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache examples #373

Merged
merged 5 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

env:
# Following env vars when changed will "reset" the mentioned cache,
# by changing the cache file name. It is rendered as ...-v%RESET_XXX%-...
# You should go up in number, if you go down (or repeat a previous value)
# you might end up reusing a previous cache if it haven't been deleted already.
# It applies 7 days retention policy by default.
RESET_EXAMPLES_CACHE: 0

jobs:
stylecheck:
name: Style Check
Expand Down Expand Up @@ -129,6 +137,20 @@ jobs:
- name: Pull Fluent docker image
run: make docker-pull

- name: Retrieve PyFluent version
run: |
echo "::set-output name=PYFLUENT_VERSION::$(python -c "from ansys.fluent.core import __version__; print(__version__)")"
echo "PYFLUENT version is: $(python -c "from ansys.fluent.core import __version__; print(__version__)")"
id: version

- name: Cache examples
uses: actions/cache@v2
with:
path: doc/source/examples
key: Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ hashFiles('examples/**') }}-${{ github.sha }}
restore-keys: |
Examples-v${{ env.RESET_EXAMPLES_CACHE }}-${{ steps.version.outputs.PYFLUENT_VERSION }}-${{ hashFiles('examples/**') }}

- name: Build Documentation
run: |
pip install -r requirements_docs.txt
Expand Down
1 change: 0 additions & 1 deletion examples/00-fluent/mixing_elbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
###############################################################################
# First, download the geometry file and start Fluent as a service with
# Meshing Mode, Double Precision, Number of Processors 2
# Importing the graphics module - pyvista

import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples
Expand Down
3 changes: 2 additions & 1 deletion src/ansys/fluent/core/services/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class EventsService:
def __init__(self, channel: grpc.Channel, metadata):
self.__stub = EventsGrpcModule.EventsStub(channel)
self.__metadata = metadata
self.__streams = None

def begin_streaming(self):
"""Begin events streaming from Fluent.
Expand All @@ -32,5 +33,5 @@ def begin_streaming(self):
def end_streaming(self):
"""End events streaming from Fluent."""

if not self.__streams.cancelled():
if self.__streams and not self.__streams.cancelled():
self.__streams.cancel()
30 changes: 30 additions & 0 deletions tests/test_settings_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pytest
from util.solver_workflow import new_solver_session # noqa: F401

from ansys.fluent.core.examples import download_file


def test_setup_models_viscous_model_settings(new_solver_session) -> None:
root = new_solver_session.get_settings_root()
assert root.setup.models.viscous.model() == "laminar"
assert "inviscid" in root.setup.models.viscous.model.get_attr("allowed-values")
root.setup.models.viscous.model = "inviscid"
assert root.setup.models.viscous.model() == "inviscid"


@pytest.mark.skip(reason="failing if run with other tests")
def test_results_graphics_mesh_settings(new_solver_session) -> None:
case_path = download_file("Static_Mixer_main.cas.h5", "pyfluent/static_mixer")
root = new_solver_session.get_settings_root()
root.file.read(file_type="case", file_name=case_path)
assert "mesh-1" not in root.results.graphics.mesh.get_object_names()
root.results.graphics.mesh["mesh-1"] = {}
assert "mesh-1" in root.results.graphics.mesh.get_object_names()
assert not root.results.graphics.mesh["mesh-1"].options.nodes()
root.results.graphics.mesh["mesh-1"].options.nodes = True
assert root.results.graphics.mesh["mesh-1"].options.nodes()
root.results.graphics.mesh.rename("mesh-a", "mesh-1")
assert "mesh-a" in root.results.graphics.mesh.get_object_names()
assert "mesh-1" not in root.results.graphics.mesh.get_object_names()
del root.results.graphics.mesh["mesh-a"]
assert "mesh-a" not in root.results.graphics.mesh.get_object_names()
10 changes: 10 additions & 0 deletions tests/test_tui_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from util.solver_workflow import new_solver_session # noqa: F401


def test_report_system_proc_stats_tui(new_solver_session, capsys) -> None:
new_solver_session.start_transcript()
# Issue: Transcript missing for the first TUI command
new_solver_session.tui.solver.report.system.proc_stats()
new_solver_session.tui.solver.report.system.proc_stats()
captured = capsys.readouterr()
assert "Virtual Mem Usage" in captured.out
14 changes: 14 additions & 0 deletions tests/util/solver_workflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest

import ansys.fluent.core as pyfluent


def create_solver_session():
return pyfluent.launch_fluent()


@pytest.fixture
def new_solver_session(with_running_pytest):
solver = create_solver_session()
yield solver
solver.exit()