Skip to content

Commit

Permalink
Remove interactive widgets (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkrull-ansys committed May 1, 2024
1 parent bf31eaf commit 9791e30
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 1,676 deletions.
85 changes: 12 additions & 73 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ jobs:
runs-on: ${{ matrix.runner }}
needs: [doc-style]
steps:
# Remove when https://github.com/readthedocs/sphinx-autoapi/pull/399 gets merged
# and auto-api is updated.
- name: "Install requirements"
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y texlive-latex-extra latexmk pandoc
- name: "Login into the GitHub registry container"
uses: docker/login-action@v3
with:
Expand Down Expand Up @@ -141,81 +133,28 @@ jobs:
- name: "Checkout code"
uses: actions/checkout@v4

# Remove when auto-api is updated
- name: Set up Python
uses: actions/setup-python@v5
- name: "Build documentation with short examples"
if: github.event_name != 'push'
uses: ansys/actions/doc-build@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

# Remove when auto-api is updated
- name: Create Python venv
run: |
python -m venv .venv
./.venv/bin/activate
python -m pip install --upgrade pip
pip install --upgrade build wheel pandoc
pip install .[doc]
pip uninstall --yes sphinx-autoapi
pip install "sphinx-autoapi @ git+https://github.com/ansys/sphinx-autoapi@feat/single-page-stable"
# Remove when auto-api is updated
- name: Build the documentation (HTML)
run: |
./.venv/bin/activate
make -C doc html SPHINXOPTS="-j auto"
make -C doc pdf
checkout: false
sphinxopts: "-j auto"
dependencies: "pandoc"
env:
GENERATING_DOCS: 1
ANSYS_ADDITIVE_ADDRESS: "localhost:50052"
BUILD_EXAMPLES_LONG: false

# Remove when auto-api is updated
- name: Build the long examples
- name: "Build documentation with long examples"
if: github.event_name == 'push'
run: |
./.venv/bin/activate
make -C doc html SPHINXOPTS="-j auto"
make -C doc pdf
uses: ansys/actions/doc-build@v6
with:
checkout: false
sphinxopts: "-j auto"
dependencies: "pandoc"
env:
GENERATING_DOCS: 1
ANSYS_ADDITIVE_ADDRESS: "localhost:50052"
BUILD_EXAMPLES_LONG: true

- name: Upload HTML documentation
uses: actions/upload-artifact@v4
with:
name: documentation-html
path: doc/_build/html
retention-days: 7

- name: Upload PDF documentation
uses: actions/upload-artifact@v4
with:
name: documentation-pdf
path: doc/_build/latex/*.pdf
retention-days: 7

# Restore when auto-api is updated
# - name: "Build documentation with short examples"
# uses: ansys/actions/doc-build@v4
# with:
# checkout: false
# sphinxopts: "-j auto"
# dependencies: "pandoc"
# env:
# GENERATING_DOCS: 1
# ANSYS_ADDITIVE_ADDRESS: "localhost:50052"
# BUILD_EXAMPLES_LONG: false

# - name: "Build documentation with long examples"
# if: github.event_name == 'push'
# uses: ansys/actions/doc-build@v4
# with:
# checkout: false
# sphinxopts: "-j auto"
# env:
# GENERATING_DOCS: 1
# ANSYS_ADDITIVE_ADDRESS: "localhost:50052"

- name: "Collect logs and shutdown server"
if: ${{ always() }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Breaking Changes
* Removed the `save_file_name` parameter from `ParametricStudy.load()`. [#302](https://github.com/ansys/pyadditive/pull/302)
* Removed the `display` module from `ansys.additive.core.parametric_study` as part of [#194](https://github.com/ansys/pyadditive/issues/194)

### New Features
* Added ability to import a csv file containing a parametric study [#118](https://github.com/ansys/pyadditive/issues/118)
Expand Down
7 changes: 5 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"matplotlib": ("https://matplotlib.org/stable", None),
"numpy": ("https://numpy.org/doc/stable", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
"pyvista": ("https://docs.pyvista.org/", None),
"pyvista": ("https://docs.pyvista.org/version/stable", None),
"pypim": ("https://pypim.docs.pyansys.com/version/stable", None),
"panel": ("https://panel.holoviz.org/", None),
}
Expand All @@ -150,11 +150,11 @@

# Consider enabling numpydoc validation. See:
# https://numpydoc.readthedocs.io/en/latest/validation.html#
# TODO: Replace this with ruff pre-commit hook
numpydoc_validate = True
numpydoc_validation_checks = {
"GL06", # Found unknown section
"GL07", # Sections are in the wrong order.
# TODO: GL08 should be reactivated since it detects undocumented members
# "GL08", # The object does not have a docstring
"GL09", # Deprecation warning should precede extended summary
"GL10", # reST directives {directives} must be followed by two colons
Expand Down Expand Up @@ -284,8 +284,11 @@
linkcheck_ignore = [
r"https://ansyshelp.ansys.com/.*",
r"https://ansysproducthelpqa.win.ansys.com/.*",
r"https://www.ansys.com/.*",
]

linkcheck_retries = 3


def prepare_jinja_env(jinja_env) -> None:
"""Customize the jinja env.
Expand Down
69 changes: 42 additions & 27 deletions examples/11_advanced_parametric_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,24 @@
You perform a parametric study if you want to optimize additive machine parameters
to achieve a specific result. Here, the :class:`ParametricStudy` class is used to
conduct a parametric study. While not essential, the :class:`ParametricStudy`
class provides data management and visualization features that make the work easier.
class provides data management features that make the work easier. Also, the
``ansys.additive.widgets`` package can be used to create interactive visualizations
for of parametric study results. An example is available at
`Parametric Study Example
<https://widgets.additive.docs.pyansys.com/version/stable/examples/gallery_examples>`_.
Units are SI (m, kg, s, K) unless otherwise noted.
"""
###############################################################################
# Perform required imports and create a study
# -------------------------------------------
# Perform the required import and create a :class:`ParametricStudy` instance.
import numpy as np
import pandas as pd

from ansys.additive.core import Additive, SimulationStatus, SimulationType
from ansys.additive.core.parametric_study import ColumnNames, ParametricStudy
import ansys.additive.core.parametric_study.display as display

study = ParametricStudy("demo-study")

Expand Down Expand Up @@ -72,7 +79,6 @@ class provides data management and visualization features that make the work eas
# specify a range of machine parameters and filter them by energy density. Not all
# the parameters shown are required. Optional parameters that are not specified
# use default values defined in the :class:`MachineConstants` class.
import numpy as np

# Specify a range of laser powers. Valid values are 50 to 700 W.
initial_powers = np.linspace(50, 700, 7)
Expand Down Expand Up @@ -106,10 +112,13 @@ class provides data management and visualization features that make the work eas
###############################################################################
# Show the simulations as a table
# -------------------------------
# You can use the :obj:`display <ansys.additive.core.parametric_study.display>`
# package to list the simulations as a table.
# The :meth:`~ParametricStudy.data_frame` method returns a :class:`~pandas.DataFrame`
# object that can be used to display the simulations as a table. Here, the
# :meth:`~pandas.DataFrame.head` method is used to display all the rows of the table.

display.show_table(study)
df = study.data_frame()
pd.set_option("display.max_columns", None) # show all columns
df.head(len(df))

###############################################################################
# Skip some simulations
Expand All @@ -128,7 +137,7 @@ class provides data management and visualization features that make the work eas
ColumnNames.ID,
].tolist()
study.set_status(ids, SimulationStatus.SKIP)
display.show_table(study)
print(study.data_frame()[[ColumnNames.ID, ColumnNames.TYPE, ColumnNames.STATUS]])

###############################################################################
# Run single bead simulations
Expand All @@ -138,6 +147,16 @@ class provides data management and visualization features that make the work eas

study.run_simulations(additive)

###############################################################################
# View single bead results
# ------------------------
# The single bead simulation results are shown in the ``Melt Pool Width (m)``, ``Melt Pool Depth (m)``,
# ``Melt Pool Length (m)``, ``Melt Pool Length/Width``, ``Melt Pool Ref Width (m)``,
# ``Melt Pool Ref Depth (m)``, and ``Melt Pool Ref Depth/Width`` columns of the data frame.
# For explanations of these columns, see :class:`ColumnNames`.

study.data_frame().head(len(study.data_frame()))

###############################################################################
# Save the study to a CSV file
# ----------------------------
Expand All @@ -157,7 +176,7 @@ class provides data management and visualization features that make the work eas

study2 = ParametricStudy("demo-csv-study.ps")
errors = study2.import_csv_study("demo-study.csv")
display.show_table(study2)
study2.data_frame().head()

###############################################################################
# Load a previously saved study
Expand All @@ -166,15 +185,7 @@ class provides data management and visualization features that make the work eas
# :meth:`ParameticStudy.load() <ParametricStudy.load>` method.

study3 = ParametricStudy.load("demo-study.ps")
display.show_table(study3)

###############################################################################
# Plot single bead results
# ------------------------
# Plot the single bead results using the
# :func:`~ansys.additive.core.parametric_study.display.single_bead_eval_plot` method.

display.single_bead_eval_plot(study)
study3.data_frame().head()

###############################################################################
# Create a porosity evaluation
Expand Down Expand Up @@ -221,12 +232,14 @@ class provides data management and visualization features that make the work eas
study.run_simulations(additive)

###############################################################################
# Plot porosity results
# View porosity results
# ---------------------
# Plot the porosity simulation results using the
# :func:`~ansys.additive.core.parametric_study.display.porosity_contour_plot` method.
# Porosity simulation results are shown in the ``Relative Density`` column of
# the data frame.
df = study.data_frame()
df = df[df[ColumnNames.TYPE] == SimulationType.POROSITY]
df.head(len(df))

display.porosity_contour_plot(study)

###############################################################################
# Create a microstructure evaluation
Expand All @@ -239,7 +252,7 @@ class provides data management and visualization features that make the work eas
# microstructure simulations to the study.

df = study.data_frame()
df = df[(df[ColumnNames.TYPE] == SimulationType.POROSITY)]
df = df[df[ColumnNames.TYPE] == SimulationType.POROSITY]

study.generate_microstructure_permutations(
material_name=material,
Expand All @@ -266,10 +279,12 @@ class provides data management and visualization features that make the work eas
study.run_simulations(additive)

###############################################################################
# Plot microstructure results
# View microstructure results
# ---------------------------
# Plot and compare the average grain sizes from the microstructure simulations
# using the :func:`~ansys.additive.core.parametric_study.display.ave_grain_size_plot`
# method.
# Microstructure simulation results are shown in the ``XY Average Grain Size (microns)``,
# ``XZ Average Grain Size (microns)``, and ``YZ Average Grain Size (microns)`` columns of
# the data frame. For explanations of these columns, see :class:`ColumnNames`.

display.ave_grain_size_plot(study)
df = study.data_frame()
df = df[df[ColumnNames.TYPE] == SimulationType.MICROSTRUCTURE]
df.head(len(df))
13 changes: 2 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
[project]
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
name = "ansys-additive-core"
version = "0.18.dev16"
version = "0.18.dev17"
description = "A Python client for the Ansys Additive service"
readme = "README.rst"
requires-python = ">=3.9,<4"
Expand Down Expand Up @@ -35,9 +35,7 @@ dependencies = [
"importlib-metadata>=4.0",
"numpy>=1.20.3",
"pandas>=1.3.2",
"panel>=1.2.1",
"platformdirs>=3.8.0",
"plotly>=5.16.1",
"protobuf>=3.20.2,<5",
"six>=1.16.0",
"tqdm>=4.45.0",
Expand All @@ -54,9 +52,7 @@ tests = [
"grpcio-health-checking==1.48.2",
"numpy==1.26.4",
"pandas==2.2.2",
"panel==1.4.2",
"platformdirs==4.2.1",
"plotly==5.21.0",
"protobuf==4.25.3",
"six==1.16.0",
"tqdm==4.66.2",
Expand All @@ -66,19 +62,15 @@ tests = [
]

doc = [
"ansys-sphinx-theme==0.15.2",
"ansys-sphinx-theme[autoapi]==0.15.2",
"enum-tools==0.12.0",
"jupyter_sphinx==0.5.3",
"matplotlib==3.8.4",
"numpydoc==1.7.0",
"panel==1.4.2",
"phantomjs==1.4.1",
"pypandoc==1.13",
"pyvista==0.43.6",
"selenium==4.20.0",
"sphinx==7.3.7",
"sphinx-autoapi==3.0.0",
#"sphinx-autoapi @ git+https://github.com/ansys/sphinx-autoapi@feat/single-page-stable",
"sphinx-autodoc-typehints==2.1.0",
"sphinx-copybutton==0.5.2",
"sphinx-design==0.5.0",
Expand Down Expand Up @@ -111,7 +103,6 @@ src_paths = ["doc", "src", "tests"]

[tool.coverage.run]
source = ["ansys.additive.core"]
omit = ["*/parametric_study/display/*"] # TODO: Remove this once unit tests are added for these files

[tool.coverage.report]
show_missing = true
Expand Down

0 comments on commit 9791e30

Please sign in to comment.