Skip to content

Commit e4f389a

Browse files
committed
Merge branch 'wheel-ctest' into 'master'
[ci] Run ctest with wheel config See merge request ogs/ogs!5386
2 parents 02bb5f6 + 719cd0e commit e4f389a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+442
-517
lines changed

Applications/ApplicationsLib/Simulation.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "Applications/ApplicationsLib/TestDefinition.h"
2020
#include "Applications/InSituLib/Adaptor.h"
2121
#include "BaseLib/ConfigTreeUtil.h"
22+
#include "BaseLib/DateTools.h"
2223
#include "BaseLib/FileTools.h"
2324
#include "BaseLib/PrjProcessing.h"
2425
#include "BaseLib/RunTime.h"
@@ -193,3 +194,35 @@ Simulation::~Simulation()
193194
controller->Finalize(1);
194195
#endif
195196
}
197+
198+
int Simulation::runTestDefinitions(
199+
std::optional<ApplicationsLib::TestDefinition>& test_definition)
200+
{
201+
if (!test_definition)
202+
{
203+
auto const end_time = std::chrono::system_clock::now();
204+
auto const time_str = BaseLib::formatDate(end_time);
205+
DBUG("No test definition was found. No tests will be executed.");
206+
INFO("OGS completed on {:s}.", time_str);
207+
return EXIT_SUCCESS;
208+
}
209+
210+
INFO("");
211+
INFO("##########################################");
212+
INFO("# Running tests #");
213+
INFO("##########################################");
214+
INFO("");
215+
auto status = test_definition->runTests();
216+
auto const end_time = std::chrono::system_clock::now();
217+
auto const time_str = BaseLib::formatDate(end_time);
218+
if (status)
219+
{
220+
INFO("OGS completed on {:s}.", time_str);
221+
}
222+
else
223+
{
224+
ERR("OGS terminated on {:s}. One of the tests failed.", time_str);
225+
return EXIT_FAILURE;
226+
}
227+
return EXIT_SUCCESS;
228+
}

Applications/ApplicationsLib/Simulation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ class Simulation final
5050

5151
OGS_EXPORT_SYMBOL ~Simulation();
5252

53+
OGS_EXPORT_SYMBOL static int runTestDefinitions(
54+
std::optional<ApplicationsLib::TestDefinition>& test_definition);
55+
5356
private:
5457
ApplicationsLib::LinearSolverLibrarySetup linear_solver_library_setup;
5558
#if defined(USE_PETSC)

Applications/CLI/ogs.cpp

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -203,32 +203,5 @@ int main(int argc, char* argv[])
203203
return EXIT_FAILURE;
204204
}
205205

206-
if (!test_definition)
207-
{
208-
auto const end_time = std::chrono::system_clock::now();
209-
auto const time_str = BaseLib::formatDate(end_time);
210-
DBUG("No test definition was found. No tests will be executed.");
211-
INFO("OGS completed on {:s}.", time_str);
212-
return ogs_status;
213-
}
214-
215-
INFO("");
216-
INFO("##########################################");
217-
INFO("# Running tests #");
218-
INFO("##########################################");
219-
INFO("");
220-
auto status = test_definition->runTests();
221-
auto const end_time = std::chrono::system_clock::now();
222-
auto const time_str = BaseLib::formatDate(end_time);
223-
if (status)
224-
{
225-
INFO("OGS completed on {:s}.", time_str);
226-
}
227-
else
228-
{
229-
ERR("OGS terminated on {:s}. One of the tests failed.", time_str);
230-
return EXIT_FAILURE;
231-
}
232-
233-
return EXIT_SUCCESS;
206+
return Simulation::runTestDefinitions(test_definition);
234207
}

Applications/Python/ogs.simulator/ogs_python_module.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ int initOGS(std::vector<std::string>& argv_str)
8484
time_str);
8585
}
8686

87-
std::optional<ApplicationsLib::TestDefinition> test_definition{
88-
std::nullopt};
8987
auto ogs_status = EXIT_SUCCESS;
9088

9189
try
@@ -121,13 +119,15 @@ int executeSimulation()
121119
}
122120

123121
auto ogs_status = EXIT_SUCCESS;
122+
std::optional<ApplicationsLib::TestDefinition> test_definition{
123+
std::nullopt};
124124

125125
try
126126
{
127127
run_time.start();
128128
bool solver_succeeded = simulation->executeSimulation();
129129
simulation->outputLastTimeStep();
130-
// TODO: test definition ?
130+
test_definition = simulation->getTestDefinition();
131131

132132
if (solver_succeeded)
133133
{
@@ -155,7 +155,7 @@ int executeSimulation()
155155
return EXIT_FAILURE;
156156
}
157157

158-
return ogs_status;
158+
return Simulation::runTestDefinitions(test_definition);
159159
}
160160

161161
int executeTimeStep()
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import importlib.util
22

3-
from ._internal.wrap_cli_tools import cli # noqa: F401
4-
53
# on wheel build config.py is not generated at the beginning of the build
6-
# but later after CMake has run
4+
# but later after CMake has run. Also cli works later when already build only.
75
config_spec = importlib.util.find_spec(".config", package="ogs")
86
if config_spec is not None:
7+
from ._internal.wrap_cli_tools import cli # noqa: F401
98
from .config import * # noqa: F403
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
binaries_list = [
2+
"addDataToRaster",
3+
"AddElementQuality",
4+
"AddFaultToVoxelGrid",
5+
"AddLayer",
6+
"appendLinesAlongPolyline",
7+
"AssignRasterDataToMesh",
8+
"checkMesh",
9+
"ComputeNodeAreasFromSurfaceMesh",
10+
"computeSurfaceNodeIDsInPolygonalRegion",
11+
"constructMeshesFromGeometry",
12+
"convertGEO",
13+
"convertToLinearMesh",
14+
"convertVtkDataArrayToVtkDataArray",
15+
"CreateAnchors",
16+
"CreateBoundaryConditionsAlongPolylines",
17+
"createIntermediateRasters",
18+
"createLayeredMeshFromRasters",
19+
"createMeshElemPropertiesFromASCRaster",
20+
"createNeumannBc",
21+
"createQuadraticMesh",
22+
"createRaster",
23+
"createTetgenSmeshFromRasters",
24+
"editMaterialID",
25+
"ExtractBoundary",
26+
"ExtractMaterials",
27+
"ExtractSurface",
28+
"generateGeometry",
29+
"generateMatPropsFromMatID",
30+
"generateStructuredMesh",
31+
"geometryToGmshGeo",
32+
"GMSH2OGS",
33+
"GocadSGridReader",
34+
"GocadTSurfaceReader",
35+
"identifySubdomains",
36+
"IntegrateBoreholesIntoMesh",
37+
"ipDataToPointCloud",
38+
"Layers2Grid",
39+
"MapGeometryToMeshSurface",
40+
"mergeMeshToBulkMesh",
41+
"Mesh2Raster",
42+
"MeshMapping",
43+
"MoveGeometry",
44+
"MoveMesh",
45+
"moveMeshNodes",
46+
"mpmetis",
47+
"NodeReordering",
48+
"ogs",
49+
"OGS2VTK",
50+
"partmesh",
51+
"postLIE",
52+
"PVD2XDMF",
53+
"pvtu2vtu",
54+
"queryMesh",
55+
"Raster2ASC",
56+
"Raster2Mesh",
57+
"RemoveGhostData",
58+
"removeMeshElements",
59+
"RemoveUnusedPoints",
60+
"ReorderMesh",
61+
"ResetPropertiesInPolygonalRegion",
62+
"reviseMesh",
63+
"scaleProperty",
64+
"swapNodeCoordinateAxes",
65+
"TecPlotTools",
66+
"TIN2VTK",
67+
"VTK2OGS",
68+
"VTK2TIN",
69+
"vtkdiff",
70+
"Vtu2Grid",
71+
"xdmfdiff",
72+
]
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import sysconfig
2+
from pathlib import Path
3+
4+
5+
def get_bin_dir():
6+
site_packages_path = sysconfig.get_paths()["purelib"]
7+
OGS_BIN_DIR = Path(site_packages_path) / "bin"
8+
9+
if not OGS_BIN_DIR.exists():
10+
# bin in regular cmake build-directory
11+
print(
12+
"Warning: OGS_BIN_DIR does not exist, falling back to possible "
13+
"build directory location."
14+
)
15+
OGS_BIN_DIR = Path(__file__).parent.parent.parent.parent / "bin"
16+
17+
return OGS_BIN_DIR

Applications/Python/ogs/_internal/provide_ogs_cli_tools_via_wheel.py

Lines changed: 24 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -2,89 +2,14 @@
22
import platform
33
import subprocess
44
import sys
5-
from pathlib import Path
65

76
from . import OGS_USE_PATH
7+
from .binaries_list import binaries_list
8+
from .get_bin_dir import get_bin_dir
89

9-
binaries_list = [
10-
"addDataToRaster",
11-
"AddElementQuality",
12-
"AddFaultToVoxelGrid",
13-
"AddLayer",
14-
"appendLinesAlongPolyline",
15-
"AssignRasterDataToMesh",
16-
"checkMesh",
17-
"ComputeNodeAreasFromSurfaceMesh",
18-
"computeSurfaceNodeIDsInPolygonalRegion",
19-
"constructMeshesFromGeometry",
20-
"convertGEO",
21-
"convertToLinearMesh",
22-
"convertVtkDataArrayToVtkDataArray",
23-
"CreateAnchors",
24-
"CreateBoundaryConditionsAlongPolylines",
25-
"createIntermediateRasters",
26-
"createLayeredMeshFromRasters",
27-
"createMeshElemPropertiesFromASCRaster",
28-
"createNeumannBc",
29-
"createQuadraticMesh",
30-
"createRaster",
31-
"createTetgenSmeshFromRasters",
32-
"editMaterialID",
33-
"ExtractBoundary",
34-
"ExtractMaterials",
35-
"ExtractSurface",
36-
"generateGeometry",
37-
"generateMatPropsFromMatID",
38-
"generateStructuredMesh",
39-
"geometryToGmshGeo",
40-
"GMSH2OGS",
41-
"GocadSGridReader",
42-
"GocadTSurfaceReader",
43-
"identifySubdomains",
44-
"IntegrateBoreholesIntoMesh",
45-
"ipDataToPointCloud",
46-
"Layers2Grid",
47-
"MapGeometryToMeshSurface",
48-
"mergeMeshToBulkMesh",
49-
"Mesh2Raster",
50-
"MeshMapping",
51-
"MoveGeometry",
52-
"MoveMesh",
53-
"moveMeshNodes",
54-
"mpmetis",
55-
"NodeReordering",
56-
"ogs",
57-
"OGS2VTK",
58-
"partmesh",
59-
"postLIE",
60-
"PVD2XDMF",
61-
"pvtu2vtu",
62-
"queryMesh",
63-
"Raster2ASC",
64-
"Raster2Mesh",
65-
"RemoveGhostData",
66-
"removeMeshElements",
67-
"RemoveUnusedPoints",
68-
"ReorderMesh",
69-
"ResetPropertiesInPolygonalRegion",
70-
"reviseMesh",
71-
"scaleProperty",
72-
"swapNodeCoordinateAxes",
73-
"TecPlotTools",
74-
"TIN2VTK",
75-
"VTK2OGS",
76-
"VTK2TIN",
77-
"vtkdiff",
78-
"Vtu2Grid",
79-
"xdmfdiff",
80-
]
81-
82-
83-
def pyproject_get_binaries():
84-
return {
85-
binary: f"ogs._internal.provide_ogs_cli_tools_via_wheel:{binary}"
86-
for binary in binaries_list
87-
}
10+
OGS_BIN_DIR = get_bin_dir()
11+
if platform.system() == "Windows":
12+
os.add_dll_directory(OGS_BIN_DIR)
8813

8914

9015
# Not used when OGS_USE_PATH is true!
@@ -114,31 +39,22 @@ def ogs_with_args(argv):
11439
return return_code
11540

11641

117-
if "PEP517_BUILD_BACKEND" not in os.environ:
118-
# Here, we assume that this script is installed, e.g., in a virtual environment
119-
# alongside a "bin" directory.
120-
OGS_BIN_DIR = Path(__file__).parent.parent.parent / "bin" # installed wheel
121-
if not OGS_BIN_DIR.exists():
122-
OGS_BIN_DIR = OGS_BIN_DIR.parent # build directory
123-
124-
if platform.system() == "Windows":
125-
os.add_dll_directory(OGS_BIN_DIR)
126-
127-
def _program(name, args):
128-
exe = OGS_BIN_DIR / name
129-
env = None # by default use unmodified environment
130-
if OGS_USE_PATH:
131-
exe = name
132-
env = os.environ.copy()
133-
# prevent infinite recursion if OGS in PATH happens to be this very
134-
# script
135-
env["OGS_USE_PATH"] = "0"
136-
print(f"OGS_USE_PATH is true: {name} from $PATH is used!")
137-
return subprocess.run([exe] + args, env=env).returncode # noqa: PLW1510
138-
139-
FUNC_TEMPLATE = """def {0}(): raise SystemExit(_program("{0}", sys.argv[1:]))"""
140-
for f in binaries_list:
141-
if f == "ogs" and not OGS_USE_PATH:
142-
continue # provided by separate function
143-
# When OGS_USE_PATH is true then ogs()-function above is not used!
144-
exec(FUNC_TEMPLATE.format(f))
42+
def _program(name, args):
43+
exe = OGS_BIN_DIR / name
44+
env = None # by default use unmodified environment
45+
if OGS_USE_PATH:
46+
exe = name
47+
env = os.environ.copy()
48+
# prevent infinite recursion if OGS in PATH happens to be this very
49+
# script
50+
env["OGS_USE_PATH"] = "0"
51+
print(f"OGS_USE_PATH is true: {name} from $PATH is used!")
52+
return subprocess.run([exe] + args, env=env).returncode # noqa: PLW1510
53+
54+
55+
FUNC_TEMPLATE = """def {0}(): raise SystemExit(_program("{0}", sys.argv[1:]))"""
56+
for f in binaries_list:
57+
if f == "ogs" and not OGS_USE_PATH:
58+
continue # provided by separate function
59+
# When OGS_USE_PATH is true then ogs()-function above is not used!
60+
exec(FUNC_TEMPLATE.format(f))

Applications/Python/ogs/_internal/wrap_cli_tools.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
import subprocess
2-
from pathlib import Path
32

43
from . import OGS_USE_PATH
5-
from .provide_ogs_cli_tools_via_wheel import binaries_list, ogs_with_args
6-
7-
# Here, we assume that this script is installed, e.g., in a virtual environment
8-
# alongside a "bin" directory.
9-
OGS_BIN_DIR = Path(__file__).parent.parent.parent / "bin" # installed wheel
10-
if not OGS_BIN_DIR.exists():
11-
OGS_BIN_DIR = OGS_BIN_DIR.parent # build directory
4+
from .binaries_list import binaries_list
5+
from .get_bin_dir import get_bin_dir
6+
from .provide_ogs_cli_tools_via_wheel import ogs_with_args
127

138

149
class CLI:
@@ -83,7 +78,7 @@ def _get_cmdline(cmd, *args, **kwargs):
8378
@staticmethod
8479
def _get_run_cmd(attr):
8580
def run_cmd(*args, **kwargs):
86-
cmd = OGS_BIN_DIR / attr
81+
cmd = get_bin_dir() / attr
8782
if OGS_USE_PATH:
8883
cmd = attr
8984
cmdline = CLI._get_cmdline(cmd, *args, **kwargs)

0 commit comments

Comments
 (0)