Skip to content

Include ADO's 25R2/sp01 changes #1077

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

Open
wants to merge 5 commits into
base: release/0.9.0
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
docs:
name: Documentation
if: github.event.action != 'closed'
runs-on: ubuntu-latest
runs-on: public-ubuntu-latest-16-cores
needs: [docs-style]
steps:
- name: Login in Github Container registry
Expand All @@ -126,6 +126,7 @@ jobs:
needs-quarto: true
sphinxopts: "-j auto --keep-going"
env:
PYVISTA_BUILDING_GALLERY: 'True'
PYPRIMEMESH_LAUNCH_CONTAINER: 1
PYPRIMEMESH_SPHINX_BUILD: 1
PYPRIMEMESH_IMAGE_TAG: ${{ env.DOCKER_IMAGE_TAG }}
Expand Down
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ repos:
- id: check-merge-conflict
- id: debug-statements

# this validates our github workflow files
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.20.0
hooks:
- id: check-github-workflows

# To be activated after quick dev cycles
#
- repo: https://github.com/pycqa/pydocstyle
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/1053.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update ci_cd.yml
1 change: 1 addition & 0 deletions doc/changelog.d/1054.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc: parallel gallery
1 change: 1 addition & 0 deletions doc/changelog.d/1057.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: unique container name
1 change: 1 addition & 0 deletions doc/changelog.d/1058.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Doc/parallel gallery
1 change: 1 addition & 0 deletions doc/changelog.d/1059.maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feature: enable parallel execution of example scripts before sphinx build
1 change: 1 addition & 0 deletions doc/changelog.d/1073.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Build(deps): bump ansys-tools-visualization-interface from 0.9.2 to 0.10.0 in the general-dependencies group
1 change: 1 addition & 0 deletions doc/changelog.d/1075.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix: wrong param in primeplotter
1 change: 1 addition & 0 deletions doc/changelog.d/1077.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Include ado's 25r2/sp01 changes
67 changes: 64 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
"""Sphinx documentation configuration file."""
import glob
import os
import subprocess
import sys
from datetime import datetime

# os.environ['PYVISTA_BUILDING_GALLERY'] = 'True'
os.environ["SPHINX_GALLERY_CONF_FORCE_FRESH"] = "0"

import ansys.tools.visualization_interface as viz_interface
import pyvista
from ansys_sphinx_theme import ansys_favicon, get_version_match, pyansys_logo_black
from joblib import Parallel, delayed
from pyvista.plotting.utilities.sphinx_gallery import DynamicScraper
from sphinx_gallery.sorting import FileNameSortKey

Expand Down Expand Up @@ -161,9 +168,9 @@
# path where to save gallery generated examples
"gallery_dirs": ["examples/gallery_examples"],
# Pattern to search for example files
"filename_pattern": r"\.py",
"filename_pattern": r"^(?!examples/other/).*\.py$",
# ignore mixing elbow and example template
"ignore_pattern": "examples/other_examples",
"ignore_pattern": r"examples/other/|flycheck*",
# Remove the "Download all examples" button from the top level gallery
"download_all_examples": False,
# Sort gallery example by file name instead of number of lines (default)
Expand All @@ -174,8 +181,62 @@
"doc_module": ("ansys.meshing.prime"),
"exclude_implicit_doc": {"ansys\\.meshing\\.prime\\._.*"}, # ignore private submodules
"image_scrapers": (DynamicScraper(), "matplotlib"),
"ignore_pattern": "flycheck*",
"thumbnail_size": (350, 350),
"parallel": True,
"run_stale_examples": False,
}


def run_example(script_path):
"""Run a Python script and return its exit code.

Parameters
----------
script_path : str
The path to the Python script to execute.

Returns
-------
int
The exit code of the script execution. 0 indicates success.
"""
print(f"Running {script_path} ...")
result = subprocess.run([sys.executable, script_path], capture_output=True)
if result.returncode != 0:
print(f"Error in {script_path}:\n{result.stderr.decode()}")
return result.returncode


def run_all_examples_in_parallel():
"""Find and run all example Python scripts in parallel, excluding certain patterns.

This function searches for all `.py` files under the `../../examples` directory,
excluding any scripts in 'examples/other' and any files containing 'flycheck' in their name.
All found scripts are executed in parallel using all available CPU cores.
"""
example_scripts = glob.glob(
os.path.join(
os.path.dirname(__file__),
"../../examples/**/*.py",
),
recursive=True,
)
# Exclude any scripts in 'examples/other'
example_scripts = [f for f in example_scripts if "examples/other" not in f.replace("\\", "/")]
# Exclude flycheck files if needed
example_scripts = [f for f in example_scripts if "flycheck" not in f]
Parallel(n_jobs=-1)(delayed(run_example)(script) for script in example_scripts)


def setup(app):
"""Sphinx setup function to run all example scripts in parallel before building the docs.

Parameters
----------
app : sphinx.application.Sphinx
The Sphinx application object.
"""
app.connect("builder-inited", lambda app: run_all_examples_in_parallel())


supress_warnings = ["docutils"]
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ graphics = [
"ansys-tools-visualization-interface>=0.4.7,<1",
]
tests = [
"ansys-tools-visualization-interface==0.9.2",
"ansys-tools-visualization-interface==0.11.0",
"pytest==8.4.1",
"pytest-cov==6.2.1",
"pytest-pyvista==0.1.9",
Expand All @@ -43,7 +43,8 @@ tests = [
]
doc = [
"ansys-sphinx-theme[autoapi]==1.5.2",
"ansys-tools-visualization-interface==0.9.2",
"ansys-tools-visualization-interface==0.11.0",
"joblib==1.5.1",
"jupyter-sphinx==0.5.3",
"numpydoc==1.8.0",
"sphinx==8.2.3",
Expand Down
8 changes: 5 additions & 3 deletions src/ansys/meshing/prime/core/mapdlcdbexportutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,12 +889,14 @@ def _process_hyperfoam_data(self, property_dict, material, mat_id):
hyperfoam_data = self._hyperfoam_with_test_data(n, uniaxial_test_data, poisson, mat_id)
else:
hyperfoam_data = self._hyperfoam_with_coeffs(n, data, mat_id)
self._logger.warning(f"{property_dict}")
self._logger.warning(f"{self._raw_materials_data[material]['UNIAXIAL TEST DATA']}")
return hyperfoam_data

def _hyperfoam_with_coeffs(self, n, data, mat_id):
hyperfoam_coeff_data = ''
data = {
k: [float(x) for x in v if x is not None] if v is not None else None
for k, v in data.items()
}
u1 = data['u1']
a1 = data['a1']
v1 = [0.0] * len(u1)
Expand Down Expand Up @@ -957,7 +959,7 @@ def _hyperfoam_with_coeffs(self, n, data, mat_id):
if n > 4:
u5a = 2 * u5[i] / a5[i]
a5a = a5[i]
hyperfoam_coeff_data += f", {u5a}, {a6a}"
hyperfoam_coeff_data += f", {u5a}, {a5a}"
if n > 5:
u6a = 2 * u6[i] / a6[i]
a6a = a6[i]
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/meshing/prime/graphics/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def show(
if plottable_object is not None:
self.plot(plottable_object, name_filter=name_filter, scope=scope, **plotting_options)
self._backend.show(
object=plottable_object,
plottable_object=plottable_object,
screenshot=screenshot,
name_filter=name_filter,
**plotting_options,
Expand Down
1 change: 0 additions & 1 deletion src/ansys/meshing/prime/internals/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def launch_prime(
client = Client(port=port, timeout=timeout)
client.container_name = container_name
print('using server from docker : The container name ', container_name)
logging.getLogger('PyPrimeMesh').info('uses server from container : ', container_name)
return client

server = launch_server_process(
Expand Down
6 changes: 2 additions & 4 deletions src/ansys/meshing/prime/internals/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
import os
import shutil
import subprocess
import uuid
from contextlib import contextmanager
from typing import List, Optional

import ansys.meshing.prime.internals.config as config
import ansys.meshing.prime.internals.defaults as defaults

_LOCAL_PORTS = []
_PRIME_CONTAINER_COUNT = 0


def make_unique_container_name(name: str):
Expand All @@ -47,9 +47,7 @@ def make_unique_container_name(name: str):
str
Unique name with a numeric integer added as suffix.
"""
global _PRIME_CONTAINER_COUNT
_PRIME_CONTAINER_COUNT = _PRIME_CONTAINER_COUNT + 1
return f'{name}-{_PRIME_CONTAINER_COUNT}'
return f'{name}-' + str(uuid.uuid4())


def to_camel_case(snake_str):
Expand Down
Loading