Skip to content
  •  
  •  
  •  
34 changes: 25 additions & 9 deletions .ci/code_generation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import sys

from ansys.dpf import core
import os
import glob
from pathlib import Path
import time
import shutil
import subprocess


if os.name == "posix":
LIB_TO_GENERATE = [
Expand All @@ -24,7 +28,6 @@
else:
LIB_TO_GENERATE = [
"Ans.Dpf.Native.dll",
"Ans.Dpf.Mechanical.dll",
"Ans.Dpf.FEMutils.dll",
"meshOperatorsCore.dll",
"mapdlOperatorsCore.dll",
Expand Down Expand Up @@ -58,17 +61,22 @@
os.remove(f)
except:
pass
core.start_local_server(config=core.AvailableServerConfigs.LegacyGrpcServer)
core.start_local_server(config=core.AvailableServerConfigs.GrpcServer)
code_gen = core.Operator("python_generator")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will only work for PREMIUM. Should we explicitly add it as context?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafacanton, sure, we can add it explicitely at the beginning of the script.
Also, sorry about the confusion Rafael, the problems with the constructors of the operators is that there is a second step in the operator generation, which I now added to the script.

code_gen.connect(1, TARGET_PATH)
for lib in LIB_TO_GENERATE:
code_gen.connect(0, lib)
if lib != LIB_TO_GENERATE[0]:
code_gen.connect(2, False)
else:
code_gen.connect(2, True)
code_gen.run()
time.sleep(0.1)
try:
code_gen.connect(0, lib)
if lib != LIB_TO_GENERATE[0]:
code_gen.connect(2, False)
else:
code_gen.connect(2, True)
print(f"Generating {lib} operators for server {core.SERVER.version}...")
code_gen.run()
time.sleep(0.1)
except Exception as e:
print(f"Could not generate operators for library {lib}:\n{str(e)}")
raise e

for lib in LIB_OPTIONAL_TO_GENERATE:
try:
Expand All @@ -77,7 +85,15 @@
code_gen.connect(2, False)
else:
code_gen.connect(2, True)
print(f"Generating optional {lib} operators for server {core.SERVER.version}...")
code_gen.run()
time.sleep(0.1)
except Exception as e:
print(f"Could not generate operators for optional library {lib}:\n{str(e)}")

# Call the dpf/core/operators/build.py script
# Requires to have pip installed requirements_build.txt
path_to_script = r"../ansys/dpf/core/operators/build.py"
print("Re-generating operators according to operator.mustache file...")
out = subprocess.check_output([sys.executable, path_to_script])
print(out.decode(encoding="utf-8"))
8 changes: 4 additions & 4 deletions ansys/dpf/core/operators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from . import math
from . import result
from . import utility
from . import min_max
from . import result
from . import scoping
from . import filter
from . import logic
from . import metadata
from . import serialization
from . import min_max
from . import mesh
from . import geo
from . import serialization
from . import averaging
from . import geo
from . import invariant
from . import mapping
22 changes: 11 additions & 11 deletions ansys/dpf/core/operators/averaging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
from .elemental_difference import elemental_difference
from .elemental_nodal_to_nodal import elemental_nodal_to_nodal
from .elemental_nodal_to_nodal_fc import elemental_nodal_to_nodal_fc
from .elemental_to_nodal import elemental_to_nodal
from .elemental_to_nodal_fc import elemental_to_nodal_fc
from .elemental_to_elemental_nodal import elemental_to_elemental_nodal
from .nodal_difference import nodal_difference
from .elemental_to_elemental_nodal_fc import elemental_to_elemental_nodal_fc
from .nodal_difference_fc import nodal_difference_fc
from .elemental_difference_fc import elemental_difference_fc
from .nodal_fraction_fc import nodal_fraction_fc
from .elemental_nodal_to_nodal_elemental_fc import elemental_nodal_to_nodal_elemental_fc
from .elemental_fraction_fc import elemental_fraction_fc
from .to_nodal import to_nodal
from .nodal_difference import nodal_difference
from .elemental_to_elemental_nodal import elemental_to_elemental_nodal
from .to_nodal_fc import to_nodal_fc
from .nodal_extend_to_mid_nodes import nodal_extend_to_mid_nodes
from .nodal_difference_fc import nodal_difference_fc
from .elemental_to_elemental_nodal_fc import elemental_to_elemental_nodal_fc
from .elemental_nodal_to_nodal_elemental import elemental_nodal_to_nodal_elemental
from .extend_to_mid_nodes import extend_to_mid_nodes
from .extend_to_mid_nodes_fc import extend_to_mid_nodes_fc
from .nodal_fraction_fc import nodal_fraction_fc
from .elemental_nodal_to_nodal_elemental_fc import elemental_nodal_to_nodal_elemental_fc
from .elemental_mean import elemental_mean
from .elemental_mean_fc import elemental_mean_fc
from .to_elemental_fc import to_elemental_fc
from .gauss_to_node_fc import gauss_to_node_fc
from .nodal_to_elemental import nodal_to_elemental
from .nodal_to_elemental_fc import nodal_to_elemental_fc
from .to_elemental_nodal_fc import to_elemental_nodal_fc
from .elemental_fraction_fc import elemental_fraction_fc
from .elemental_difference import elemental_difference
from .elemental_difference_fc import elemental_difference_fc
from .extend_to_mid_nodes_fc import extend_to_mid_nodes_fc
from .extend_to_mid_nodes import extend_to_mid_nodes
Loading