Skip to content

Commit

Permalink
Merge branch 'master' into example/rescope
Browse files Browse the repository at this point in the history
  • Loading branch information
PProfizi authored Oct 13, 2023
2 parents 6c48ea9 + 5ee39a2 commit 0a58a9a
Show file tree
Hide file tree
Showing 526 changed files with 43,290 additions and 3,058 deletions.
21 changes: 11 additions & 10 deletions .ci/build_doc.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ call sphinx-apidoc -o ../docs/source/api ../src/ansys ../src/ansys/dpf/core/log.
../src/ansys/dpf/core/field_base.py ../src/ansys/dpf/core/cache.py ../src/ansys/dpf/core/misc.py ^
../src/ansys/dpf/core/check_version.py ../src/ansys/dpf/core/operators/build.py ../src/ansys/dpf/core/operators/specification.py ^
../src/ansys/dpf/core/vtk_helper.py ../src/ansys/dpf/core/label_space.py ../src/ansys/dpf/core/examples/python_plugins/* ^
../src/ansys/dpf/core/examples/examples.py ../src/ansys/dpf/core/property_fields_container.py ^
../src/ansys/dpf/core/examples/examples.py ../src/ansys/dpf/gate/* ../src/ansys/dpf/gatebin/* ../src/ansys/grpc/dpf/* ^
../src/ansys/dpf/core/property_fields_container.py ^
-f --implicit-namespaces --separate --no-headings
pushd .
cd ../docs/
Expand All @@ -15,14 +16,14 @@ dir

rem Patch pyVista issue with elemental plots

xcopy source\examples\04-advanced\02-volume_averaged_stress\sphx_glr_02-volume_averaged_stress_001.png build\html\_images\sphx_glr_02-volume_averaged_stress_001.png /y
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_001.png build\html\_images\sphx_glr_02-fluids_results_001.png /y
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_002.png build\html\_images\sphx_glr_02-fluids_results_002.png /y
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_003.png build\html\_images\sphx_glr_02-fluids_results_003.png /y
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_004.png build\html\_images\sphx_glr_02-fluids_results_004.png /y
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_005.png build\html\_images\sphx_glr_02-fluids_results_005.png /y
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_006.png build\html\_images\sphx_glr_02-fluids_results_006.png /y
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_007.png build\html\_images\sphx_glr_02-fluids_results_007.png /y
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_thumb.png build\html\_images\sphx_glr_02-fluids_results_thumb.png /y
xcopy source\examples\04-advanced\02-volume_averaged_stress\sphx_glr_02-volume_averaged_stress_001.png build\html\_images /y /f /i
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_001.png build\html\_images /y /f /i
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_002.png build\html\_images /y /f /i
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_003.png build\html\_images /y /f /i
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_004.png build\html\_images /y /f /i
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_005.png build\html\_images /y /f /i
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_006.png build\html\_images /y /f /i
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_007.png build\html\_images /y /f /i
xcopy source\examples\12-fluids\02-fluids_results\sphx_glr_02-fluids_results_thumb.png build\html\_images /y /f /i

popd
94 changes: 94 additions & 0 deletions .ci/build_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# This script generates the different versions of the ansys-dpf-core wheels based on a given input.
# Input can be one of ["any", "win", "manylinux1", "manylinux_2_17"]

import argparse
import pathlib
import subprocess
import os
import sys
import shutil
import tempfile


supported_platforms = {
"any": "any",
"win": "win_amd64",
"manylinux1": "manylinux1_x86_64",
"manylinux_2_17": "manylinux_2_17_x86_64"
}

argParser = argparse.ArgumentParser()
argParser.add_argument("-p", "--platform", help="platform")
argParser.add_argument("-w", "--wheelhouse", help="platform", action='store_true')

args = argParser.parse_args()

if args.platform not in supported_platforms:
raise ValueError(f"Platform {args.platform} is not supported. "
f"Supported platforms are: {list(supported_platforms.keys())}")
else:
requested_platform = supported_platforms[args.platform]
print(requested_platform)

# Move binaries out of the source depending on platform requested
# any: move all binaries out before building
# win: move .so binaries out before building
# lin: move .dll binaries out before building
with tempfile.TemporaryDirectory() as tmpdirname:
print('Created temporary directory: ', tmpdirname)

# Create the temporary build-opts.cfg
build_opts_path = os.path.join(tmpdirname, "build-opts.cfg")
with open(build_opts_path, "w") as build_opts_file:
build_opts_file.write(f"[bdist_wheel]\nplat-name={requested_platform}")
os.environ["DIST_EXTRA_CONFIG"] = build_opts_path

# Move the binaries
gatebin_folder_path = os.path.join(
os.path.curdir,
os.path.join("src", "ansys", "dpf", "gatebin")
)
binaries_to_move = []
moved = []
if "win" in requested_platform or "any" == requested_platform:
# Move linux binaries
binaries_to_move.extend(["libAns.Dpf.GrpcClient.so", "libDPFClientAPI.so"])
if "linux" in requested_platform or "any" == requested_platform:
# Move windows binaries
binaries_to_move.extend(["Ans.Dpf.GrpcClient.dll", "DPFClientAPI.dll"])
if "any" == requested_platform:
binaries_to_move.extend(["_version.py"])

for binary_name in binaries_to_move:
src = os.path.join(gatebin_folder_path, binary_name)
dst = os.path.join(tmpdirname, binary_name)
print(f"Moving {src} to {dst}")
shutil.move(src=src, dst=dst)
moved.append([dst, src])

if "any" == requested_platform:
# Also remove the gatebin folder
os.rmdir(gatebin_folder_path)

# Call the build
if not args.wheelhouse:
cmd = [sys.executable, "-m", "build", "--wheel"]
else:
cmd = [sys.executable, "-m", "pip", "wheel", "-w", "dist", "."]
try:
subprocess.run(cmd, capture_output=False, text=True)
print("Done building the wheel.")
except Exception as e:
print(f"Build failed with error: {e}")

if "any" == requested_platform:
# Recreate the gatebin folder
os.mkdir(gatebin_folder_path)

# Move binaries back
for move_back in moved:
print(f"Moving back {move_back[0]} to {move_back[1]}")
shutil.move(src=move_back[0], dst=move_back[1])
print("Binaries moved back.")

print(f"Done building {requested_platform} wheel for ansys-dpf-core!")
7 changes: 0 additions & 7 deletions .ci/display_test.py

This file was deleted.

2 changes: 0 additions & 2 deletions .ci/requirements_test_xvfb.txt

This file was deleted.

82 changes: 82 additions & 0 deletions .ci/update_dpf_dependencies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
"""Script to update ansys-dpf-gate, ansys-dpf-gatebin and ansys-grpc-dpf based on repositories
This script should only be used to quickly test changes to any of these dependencies.
Actual commit of updated code should not occur.
The GitHub pipelines take care of the actual update in ansys-dpf-core.
Define environment variables to know where to get the code from:
- "DPFDV_ROOT" defines the DPF repo where ansys-grpc-dpf resides.
Will unzip the latest wheel built in DPF/proto/dist/.
- "ANSYSDPFPYGATE_ROOT" defines where the ansys-dpf-pygate repository resides.
It will update the current repo
or the repo defined by the environment variable "ANSYSDPFCORE_ROOT" if it exists.
"""
import os
import glob
import pathlib
import platform
import shutil
import zipfile


grpc_path_key = "DPFDV_ROOT"
gate_path_key = "ANSYSDPFPYGATE_ROOT"
core_path = pathlib.Path(__file__).parent.parent.resolve()
if "ANSYSDPFCORE_ROOT" in os.environ:
core_path = os.environ["ANSYSDPFCORE_ROOT"]

grpc_path = os.getenv(grpc_path_key, None)
gate_path = os.getenv(gate_path_key, None)

if grpc_path is not None:
# Update ansys-grpc-dpf with latest in proto/dist
print("Updating ansys.grpc.dpf")
dist_path = os.path.join(grpc_path, "proto", "dist", "*")
print(f"from {dist_path}")
destination = os.path.join(core_path, "src")
print(f"into {destination}")
latest_wheel = max(glob.glob(dist_path), key=os.path.getctime)
with zipfile.ZipFile(latest_wheel, 'r') as wheel:
for file in wheel.namelist():
# print(file)
if file.startswith('ansys/'):
wheel.extract(
file,
path=destination,
)
print("Done updating ansys-grpc-dpf")
else:
print(f"{grpc_path_key} environment variable is not defined. "
"Cannot update ansys-grpc-dpf.")

if gate_path is not None:
# Update ansys-dpf-gate
print("Updating ansys.dpf.gate")
dist_path = os.path.join(gate_path, "ansys-dpf-gate", "ansys")
print(f"from {dist_path}")
destination = os.path.join(core_path, "src", "ansys")
print(f"into {destination}")
shutil.copytree(
src=dist_path,
dst=destination,
dirs_exist_ok=True,
ignore=lambda directory, contents: ["__pycache__"] if directory[-5:] == "gate" else [],
)
print("Done updating ansys-dpf-gate")

# Update ansys-dpf-gatebin
print("Updating ansys.dpf.gatebin")
dist_path = os.path.join(gate_path, "ansys-dpf-gatebin", "ansys")
print(f"from {dist_path}")
destination = os.path.join(core_path, "src", "ansys")
print(f"into {destination}")
shutil.copytree(
src=dist_path,
dst=destination,
dirs_exist_ok=True,
)
print(f"Done updating ansys-dpf-gatebin for {platform.system()}")
else:
print(f"{gate_path_key} environment variable is not defined. "
"Cannot update ansys-dpf-gate or ansys-dpf-gatebin.")
5 changes: 3 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[flake8]
exclude = venv, src/ansys/dpf/core/operators, __init__.py, docs/build, .venv
exclude = venv, src/ansys/dpf/core/operators, __init__.py, docs/build, .venv, src/ansys/dpf/gate, src/ansys/dpf/gatebin, src/ansys/grpc/dpf
select = W191, W391, E115, E117, E122, E124, E125, E301, W291, W293, E225, E231, E303, E501, F401, F403
per-file-ignores = __init__.py:F401,F403
per-file-ignores =
__init__.py:F401,F403
count = True
max-complexity = 10
max-line-length = 100
Expand Down
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ updates:
insecure-external-code-execution: allow
schedule:
interval: "daily"
# Allow up to 10 open pull requests for pip dependencies
open-pull-requests-limit: 10
labels:
- "maintenance"
- "dependencies"
Expand Down
Loading

0 comments on commit 0a58a9a

Please sign in to comment.