processforge 0.5.0__tar.gz → 0.6.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {processforge-0.5.0/src/processforge.egg-info → processforge-0.6.0}/PKG-INFO +1 -1
- {processforge-0.5.0 → processforge-0.6.0}/flowsheets/custom/crimson/simple_water_system.json +4 -2
- {processforge-0.5.0 → processforge-0.6.0}/pyproject.toml +1 -1
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/__init__.py +1 -3
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/apply.py +5 -3
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/display.py +3 -3
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/init.py +3 -3
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/persist.py +3 -6
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/run.py +2 -6
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/flowsheet.py +8 -1
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/flowsheet.py +9 -1
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/output_collector.py +25 -1
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/persistence/archive.py +34 -51
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/base.py +13 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/container_client.py +19 -17
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/manager.py +16 -1
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/result.py +0 -28
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/types.py +14 -0
- {processforge-0.5.0 → processforge-0.6.0/src/processforge.egg-info}/PKG-INFO +1 -1
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_cli.py +11 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_container_client.py +56 -1
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_providers.py +11 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_runs_command.py +49 -34
- {processforge-0.5.0 → processforge-0.6.0}/LICENSE +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/MANIFEST.in +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/README.md +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/flowsheets/closed-loop-chain.json +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/flowsheets/coupled/msre_coupled.json +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/flowsheets/custom/crimson/MUWS_HB.json +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/flowsheets/custom/simple_hyrdaulic_scheme.json +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/flowsheets/festim/hydrogen_transport_1d.json +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/flowsheets/festim/tds_tungsten.json +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/flowsheets/hydraulic-chain.json +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/flowsheets/openmc/msre_eigenvalue.json +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/setup.cfg +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/__main__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/_schema.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/analysis/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/analysis/dof.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/api/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/api/serve.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/common.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/diagram.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/export_fmu.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/export_modelica.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/plan.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/runs.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/cli/validate.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/compose.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/coupling.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/backends/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/backends/base.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/backends/casadi_backend.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/backends/pyomo_backend.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/backends/scipy_backend.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/jacobian.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/mixin.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/solver.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/stream_var.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/units/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/units/flash_eo.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/units/heater_eo.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/units/pipes_eo.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/units/pump_eo.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/units/strainer_eo.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/eo/units/valve_eo.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/fmu/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/fmu/_fmi_vars.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/fmu/builder.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/fmu/interface.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/fmu/slave_template.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/lock.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/modelica/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/modelica/mo_writer.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/modelica/omc_runner.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/modelica/transpiler.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/modelica/unit_equations.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/pathsim/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/pathsim/adapter.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/pcl/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/pcl/compiler.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/pcl/namespace.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/persistence/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/persistence/artifact_store.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/provenance.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/_sim_strategy.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/base_jacobian_mixin.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/base_simulation_provider.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/cantera_jacobian.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/cantera_provider.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/coolprop_provider.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/errors.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/festim/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/festim/build_helpers.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/festim/provider.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/festim/result_extraction.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/festim/strategies.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/jacobian_contributor.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/modelica_jacobian.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/modelica_provider.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/openmc/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/openmc/build_helpers.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/openmc/provider.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/openmc/result_extraction.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/openmc/strategies.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/reference_state_registry.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/providers/registry.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/quantity.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/result_schema.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/schemas/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/schemas/festim/festim_model.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/schemas/flowsheet_schema.json +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/schemas/openmc/openmc_model.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/simulate.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/solver.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/state.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/thermo.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/base.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/cstr.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/flash.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/heater.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/pfr.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/pipes.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/pump.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/registry.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/solver_unit.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/strainer.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/tank.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/units/valve.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/utils/__init__.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/utils/flowsheet_diagram.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/utils/mermaid_diagram.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/utils/s3_upload.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/utils/topology.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/utils/unit_consistency.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/utils/validate_flowsheet.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge/utils/validation.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge.egg-info/SOURCES.txt +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge.egg-info/dependency_links.txt +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge.egg-info/entry_points.txt +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge.egg-info/requires.txt +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/src/processforge.egg-info/top_level.txt +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_coupling.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_display.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_festim_provider.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_festim_schema.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_fmu_solverunit.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_init.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_openmc_provider.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_pathsim_adapter.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_persist.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_provider_errors.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_result_zarr.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_s3_upload.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_state.py +0 -0
- {processforge-0.5.0 → processforge-0.6.0}/tests/test_types.py +0 -0
{processforge-0.5.0 → processforge-0.6.0}/flowsheets/custom/crimson/simple_water_system.json
RENAMED
|
@@ -91,7 +91,8 @@
|
|
|
91
91
|
"p_start_open": 2059396.5,
|
|
92
92
|
"p_full_open": 2451662.5,
|
|
93
93
|
"flow_min": 2.7778e-05,
|
|
94
|
-
"flow_max": 0.0013889
|
|
94
|
+
"flow_max": 0.0013889,
|
|
95
|
+
"pressure_ratio": 0.5
|
|
95
96
|
},
|
|
96
97
|
"make_up_valve_1": {
|
|
97
98
|
"type": "Valve",
|
|
@@ -102,7 +103,8 @@
|
|
|
102
103
|
"p_start_open": 1863273.5,
|
|
103
104
|
"p_full_open": 1470997.5,
|
|
104
105
|
"flow_min": 5.5556e-05,
|
|
105
|
-
"flow_max": 0.0016667
|
|
106
|
+
"flow_max": 0.0016667,
|
|
107
|
+
"pressure_ratio": 0.5
|
|
106
108
|
},
|
|
107
109
|
"pipe_4": {
|
|
108
110
|
"type": "Pipes",
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "processforge"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.6.0"
|
|
8
8
|
description = "A Python-based process simulation framework for chemical engineering applications."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "BSD-3-Clause"
|
|
@@ -18,7 +18,6 @@ from .utils.validate_flowsheet import validate_flowsheet
|
|
|
18
18
|
from .result import (
|
|
19
19
|
plot_results,
|
|
20
20
|
plot_timeseries,
|
|
21
|
-
relink_latest_results,
|
|
22
21
|
save_results_zarr,
|
|
23
22
|
)
|
|
24
23
|
from .units.pump import Pump
|
|
@@ -30,7 +29,7 @@ from .units.flash import Flash
|
|
|
30
29
|
from .units.heater import Heater
|
|
31
30
|
from .eo import EOFlowsheet, EOSolver
|
|
32
31
|
|
|
33
|
-
__version__ = "0.
|
|
32
|
+
__version__ = "0.6.0"
|
|
34
33
|
|
|
35
34
|
__all__ = [
|
|
36
35
|
"Flowsheet",
|
|
@@ -42,7 +41,6 @@ __all__ = [
|
|
|
42
41
|
"plot_results",
|
|
43
42
|
"plot_timeseries",
|
|
44
43
|
"save_results_zarr",
|
|
45
|
-
"relink_latest_results",
|
|
46
44
|
"build_run_info",
|
|
47
45
|
"Pump",
|
|
48
46
|
"Valve",
|
|
@@ -9,7 +9,7 @@ from typing import Literal
|
|
|
9
9
|
import typer
|
|
10
10
|
from loguru import logger
|
|
11
11
|
|
|
12
|
-
from .persist import make_run_id, persist_run
|
|
12
|
+
from .persist import flowsheet_hash, make_run_id, persist_run
|
|
13
13
|
from ..eo import EOFlowsheet
|
|
14
14
|
from ..provenance import build_run_info
|
|
15
15
|
from .common import (
|
|
@@ -106,6 +106,8 @@ def apply(
|
|
|
106
106
|
fs.solver_max_iter = max_iter
|
|
107
107
|
|
|
108
108
|
logger.info("=== Running Apply (Steady-State EO) ===")
|
|
109
|
+
run_id = make_run_id()
|
|
110
|
+
fs.set_run_context(run_id, flowsheet_hash(config))
|
|
109
111
|
t0 = time.perf_counter()
|
|
110
112
|
results = fs.run()
|
|
111
113
|
elapsed = time.perf_counter() - t0
|
|
@@ -122,7 +124,6 @@ def apply(
|
|
|
122
124
|
label="converged state",
|
|
123
125
|
)
|
|
124
126
|
run_info = build_run_info(config, x0=fs.x0, var_names=fs.var_names)
|
|
125
|
-
run_id = make_run_id()
|
|
126
127
|
persist_run(sm, fs, run_id, results, run_info, config, base_name, snapshot_id)
|
|
127
128
|
logger.info("=== Apply Summary ===")
|
|
128
129
|
logger.info(" Status : CONVERGED")
|
|
@@ -142,7 +143,9 @@ def apply(
|
|
|
142
143
|
from ..providers.manager import teardown_providers
|
|
143
144
|
|
|
144
145
|
solver = EOSolver(backend=fs.backend, tol=tolerance, max_iter=max_iter)
|
|
146
|
+
run_id = make_run_id()
|
|
145
147
|
tmp_fs = _EO(config, backend=backend)
|
|
148
|
+
tmp_fs.set_run_context(run_id, flowsheet_hash(config))
|
|
146
149
|
manager = tmp_fs._build()
|
|
147
150
|
try:
|
|
148
151
|
homotopy_result = solve_with_homotopy(tmp_fs, manager, solver, state, drifted)
|
|
@@ -168,7 +171,6 @@ def apply(
|
|
|
168
171
|
label="homotopy solution",
|
|
169
172
|
)
|
|
170
173
|
run_info = build_run_info(config, x0=fs.x0, var_names=fs.var_names)
|
|
171
|
-
run_id = make_run_id()
|
|
172
174
|
persist_run(sm, tmp_fs, run_id, tmp_fs.results, run_info, config, base_name, snapshot_id)
|
|
173
175
|
logger.info("Homotopy apply succeeded. New snapshot saved.")
|
|
174
176
|
return
|
|
@@ -96,13 +96,13 @@ def print_provider_health(config: dict, strict: bool = False) -> list[str]:
|
|
|
96
96
|
logger.error(msg)
|
|
97
97
|
failures.append(f"Provider '{name}' unreachable at {url}: {info}")
|
|
98
98
|
else:
|
|
99
|
-
catalog = _PROVIDER_CATALOG.get(ptype
|
|
100
|
-
module = catalog.
|
|
99
|
+
catalog = _PROVIDER_CATALOG.get(ptype)
|
|
100
|
+
module = catalog.module if catalog else ""
|
|
101
101
|
try:
|
|
102
102
|
importlib.util.find_spec(module)
|
|
103
103
|
logger.info(f" [OK] {name} [{ptype}] (pip — importable)")
|
|
104
104
|
except (ModuleNotFoundError, ValueError):
|
|
105
|
-
dep = catalog.
|
|
105
|
+
dep = catalog.optional_dep if catalog else None
|
|
106
106
|
hint = f"pip install 'processforge[{dep}]'" if dep else "built-in"
|
|
107
107
|
logger.warning(f" [WARN] {name} [{ptype}] — not installed ({hint})")
|
|
108
108
|
if strict:
|
|
@@ -208,13 +208,13 @@ def init(
|
|
|
208
208
|
# Validate pip providers are importable
|
|
209
209
|
for name, info in pip_providers.items():
|
|
210
210
|
ptype = info["type"]
|
|
211
|
-
catalog = _PROVIDER_CATALOG.get(ptype
|
|
212
|
-
module = catalog.
|
|
211
|
+
catalog = _PROVIDER_CATALOG.get(ptype)
|
|
212
|
+
module = catalog.module if catalog else ""
|
|
213
213
|
try:
|
|
214
214
|
importlib.util.find_spec(module)
|
|
215
215
|
logger.info(f" {name} — importable")
|
|
216
216
|
except (ModuleNotFoundError, ValueError):
|
|
217
|
-
dep = catalog.
|
|
217
|
+
dep = catalog.optional_dep if catalog else None
|
|
218
218
|
hint = f"pip install 'processforge[{dep}]'" if dep else "built-in"
|
|
219
219
|
logger.warning(f" {name} — not installed. Install with: {hint}")
|
|
220
220
|
|
|
@@ -77,13 +77,11 @@ def persist_run(
|
|
|
77
77
|
if snapshot_id is not None:
|
|
78
78
|
manifest.snapshot_id = snapshot_id
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
archive.save_run(manifest, stream_results=stream_results)
|
|
80
|
+
archive.save_run(manifest)
|
|
82
81
|
|
|
83
|
-
#
|
|
84
|
-
# inside the archive, mirroring `pf run`.
|
|
82
|
+
# Persist Zarr store (single source of truth for stream timeseries).
|
|
85
83
|
try:
|
|
86
|
-
from ..result import
|
|
84
|
+
from ..result import save_results_zarr
|
|
87
85
|
|
|
88
86
|
run_results_dir = os.path.join(archive.path, "results", run_id)
|
|
89
87
|
save_results_zarr(
|
|
@@ -91,7 +89,6 @@ def persist_run(
|
|
|
91
89
|
os.path.join(run_results_dir, "results.zarr"),
|
|
92
90
|
run_info,
|
|
93
91
|
)
|
|
94
|
-
relink_latest_results(archive.path, run_id)
|
|
95
92
|
except Exception as e:
|
|
96
93
|
logger.warning(f"Failed to write results.zarr: {type(e).__name__}: {e}")
|
|
97
94
|
|
|
@@ -106,6 +106,7 @@ def run(
|
|
|
106
106
|
logger.debug("No .pfarchive found — starting dynamic run from flowsheet defaults.")
|
|
107
107
|
|
|
108
108
|
fs = Flowsheet(config)
|
|
109
|
+
fs.set_run_context(run_id, flowsheet_hash_value)
|
|
109
110
|
logger.info("=== Dynamic Results ===")
|
|
110
111
|
results = fs.run()
|
|
111
112
|
|
|
@@ -128,6 +129,7 @@ def run(
|
|
|
128
129
|
else:
|
|
129
130
|
# Pass None so EOFlowsheet resolves backend from config (with scipy default).
|
|
130
131
|
fs = EOFlowsheet(config, backend=None)
|
|
132
|
+
fs.set_run_context(run_id, flowsheet_hash_value)
|
|
131
133
|
logger.info("=== Steady-State EO Results ===")
|
|
132
134
|
results = fs.run()
|
|
133
135
|
|
|
@@ -144,12 +146,6 @@ def run(
|
|
|
144
146
|
snap_backend = getattr(fs, "backend", "scipy")
|
|
145
147
|
snap_ok = bool(getattr(fs, "converged", False))
|
|
146
148
|
|
|
147
|
-
# Propagate run context to any containerized providers so their S3 uploads
|
|
148
|
-
# are keyed by the same run_id/flowsheet_hash as this archive run.
|
|
149
|
-
for provider in getattr(fs, "_provider_map", {}).values():
|
|
150
|
-
if hasattr(provider, "set_run_context"):
|
|
151
|
-
provider.set_run_context(run_id, flowsheet_hash_value)
|
|
152
|
-
|
|
153
149
|
# Build + persist the standardized run manifest.
|
|
154
150
|
archive_path = os.path.join(outputs_dir, f"{base_name}.pfarchive")
|
|
155
151
|
archive = ProcessStateArchive(archive_path)
|
|
@@ -51,6 +51,12 @@ class EOFlowsheet:
|
|
|
51
51
|
self.solver_tol: float = 1e-6
|
|
52
52
|
self.solver_max_iter: int = 50
|
|
53
53
|
|
|
54
|
+
def set_run_context(self, run_id: str | None = None, flowsheet_hash: str | None = None) -> None:
|
|
55
|
+
"""Store run-level metadata so containerized providers can tag artifacts."""
|
|
56
|
+
from processforge.types import RunContext
|
|
57
|
+
|
|
58
|
+
self._run_context = RunContext(run_id=run_id, flowsheet_hash=flowsheet_hash)
|
|
59
|
+
|
|
54
60
|
# ------------------------------------------------------------------
|
|
55
61
|
# Public API
|
|
56
62
|
# ------------------------------------------------------------------
|
|
@@ -68,8 +74,9 @@ class EOFlowsheet:
|
|
|
68
74
|
Stream result dict in the same format as ``Flowsheet.run()``:
|
|
69
75
|
``{stream_name: {"T": ..., "P": ..., "flowrate": ..., "z": {...}}}``
|
|
70
76
|
"""
|
|
71
|
-
from processforge.providers.manager import teardown_providers
|
|
77
|
+
from processforge.providers.manager import apply_run_context, teardown_providers
|
|
72
78
|
manager = self._build()
|
|
79
|
+
apply_run_context(self._provider_map, getattr(self, "_run_context", None))
|
|
73
80
|
self.engine_outputs: dict = {}
|
|
74
81
|
try:
|
|
75
82
|
x0 = self._warm_start(manager)
|
|
@@ -9,7 +9,7 @@ from copy import deepcopy
|
|
|
9
9
|
if TYPE_CHECKING:
|
|
10
10
|
from .providers.manager import ProviderMap
|
|
11
11
|
|
|
12
|
-
from .providers.manager import build_provider_map, teardown_providers
|
|
12
|
+
from .providers.manager import apply_run_context, build_provider_map, teardown_providers
|
|
13
13
|
from .types import EngineOutput, FlowsheetConfig, MergedInletTimeseries, StreamTimeseries
|
|
14
14
|
from .solver import Solver
|
|
15
15
|
from .providers.manager import UnitProviderConfig
|
|
@@ -112,6 +112,12 @@ class Flowsheet:
|
|
|
112
112
|
self.tear_streams = set()
|
|
113
113
|
self.has_recycles = False
|
|
114
114
|
|
|
115
|
+
def set_run_context(self, run_id: str | None = None, flowsheet_hash: str | None = None) -> None:
|
|
116
|
+
"""Store run-level metadata so containerized providers can tag artifacts."""
|
|
117
|
+
from processforge.types import RunContext
|
|
118
|
+
|
|
119
|
+
self._run_context = RunContext(run_id=run_id, flowsheet_hash=flowsheet_hash)
|
|
120
|
+
|
|
115
121
|
def build_units(self, provider_map: ProviderMap | None = None):
|
|
116
122
|
logger.info("Building units")
|
|
117
123
|
_merge_provider_types(provider_map=provider_map)
|
|
@@ -228,6 +234,8 @@ class Flowsheet:
|
|
|
228
234
|
logger.info("Starting simulation")
|
|
229
235
|
flowsheet_cfg = FlowsheetConfig.from_dict(self.config)
|
|
230
236
|
provider_map = build_provider_map(providers_config=flowsheet_cfg.providers, flowsheet_config=flowsheet_cfg)
|
|
237
|
+
self._provider_map = provider_map
|
|
238
|
+
apply_run_context(provider_map, getattr(self, "_run_context", None))
|
|
231
239
|
self.engine_outputs: dict = {}
|
|
232
240
|
try:
|
|
233
241
|
self.build_units(provider_map=provider_map)
|
|
@@ -18,6 +18,7 @@ from datetime import datetime, timezone
|
|
|
18
18
|
from typing import Optional
|
|
19
19
|
|
|
20
20
|
import arrow
|
|
21
|
+
import numpy as np
|
|
21
22
|
from loguru import logger
|
|
22
23
|
|
|
23
24
|
from .types import (
|
|
@@ -30,6 +31,26 @@ from .types import (
|
|
|
30
31
|
)
|
|
31
32
|
|
|
32
33
|
|
|
34
|
+
def _to_scalar(value):
|
|
35
|
+
"""Return the last element of a sequence, or the scalar value itself.
|
|
36
|
+
|
|
37
|
+
Dynamic simulations store stream properties as timeseries lists. For
|
|
38
|
+
manifest-level thermo output we use the final timestep as the representative
|
|
39
|
+
scalar, matching the convention used by :func:`~processforge.result.plot_results`.
|
|
40
|
+
"""
|
|
41
|
+
if isinstance(value, (list, tuple, np.ndarray)):
|
|
42
|
+
arr = np.asarray(value)
|
|
43
|
+
if arr.size == 0:
|
|
44
|
+
raise ValueError("empty sequence")
|
|
45
|
+
candidate = arr[-1]
|
|
46
|
+
else:
|
|
47
|
+
candidate = value
|
|
48
|
+
try:
|
|
49
|
+
return float(candidate)
|
|
50
|
+
except (TypeError, ValueError) as exc:
|
|
51
|
+
raise ValueError(f"non-numeric value {candidate!r}") from exc
|
|
52
|
+
|
|
53
|
+
|
|
33
54
|
def collect_stream_outputs(provider, stream_results: dict) -> dict[str, StreamOutput]:
|
|
34
55
|
"""Build :class:`StreamOutput` for each stream using *provider*'s thermo."""
|
|
35
56
|
if provider is None:
|
|
@@ -44,7 +65,10 @@ def collect_stream_outputs(provider, stream_results: dict) -> dict[str, StreamOu
|
|
|
44
65
|
if not isinstance(z, dict) or T is None or P is None:
|
|
45
66
|
continue
|
|
46
67
|
try:
|
|
47
|
-
|
|
68
|
+
z_norm = {comp: _to_scalar(frac) for comp, frac in z.items()}
|
|
69
|
+
T_norm = _to_scalar(T)
|
|
70
|
+
P_norm = _to_scalar(P)
|
|
71
|
+
props = provider.get_thermo_properties({"z": z_norm, "T": T_norm, "P": P_norm})
|
|
48
72
|
except Exception as exc: # noqa: BLE001
|
|
49
73
|
logger.debug(f"thermo properties unavailable for stream '{name}': {exc}")
|
|
50
74
|
continue
|
|
@@ -8,28 +8,20 @@ A ``<base>.pfarchive`` directory holds, in one place:
|
|
|
8
8
|
* ``runs/<run_id>.json`` — a :class:`~processforge.types.RunManifest` capturing
|
|
9
9
|
every engine output (OpenMC, FESTIM, CoolProp, Cantera) for one ``pf run`` /
|
|
10
10
|
``pf apply``.
|
|
11
|
-
* ``
|
|
12
|
-
|
|
13
|
-
:class:`~processforge.types.OutputArtifact` (local + remote URIs).
|
|
14
|
-
* ``index.json`` — ``field_name -> [occurrences]`` for fast cross-run
|
|
15
|
-
queries.
|
|
11
|
+
* ``results/<run_id>/results.zarr`` — stream timeseries and engine outputs
|
|
12
|
+
in a compressed Zarr store (the single source of truth for time-series data).
|
|
16
13
|
* ``latest_run`` — pointer to the most recent run.
|
|
17
|
-
|
|
18
|
-
This replaces the old split of ``.pfstate`` (state only) + ``_results.zarr``
|
|
19
|
-
(stream results) + loose ``run_dir`` files.
|
|
20
14
|
"""
|
|
21
15
|
from __future__ import annotations
|
|
22
16
|
|
|
23
17
|
import json
|
|
24
18
|
import os
|
|
25
|
-
from datetime import datetime, timezone
|
|
26
19
|
from typing import Optional
|
|
27
20
|
|
|
28
|
-
import zarr
|
|
29
21
|
from loguru import logger
|
|
30
22
|
|
|
31
23
|
from ..state import StateManager
|
|
32
|
-
from ..types import
|
|
24
|
+
from ..types import RunManifest, SnapshotState
|
|
33
25
|
|
|
34
26
|
|
|
35
27
|
def _read_json(path: str, default):
|
|
@@ -51,7 +43,6 @@ class ProcessStateArchive:
|
|
|
51
43
|
def __init__(self, path: str) -> None:
|
|
52
44
|
self.path = path
|
|
53
45
|
os.makedirs(self.path, exist_ok=True)
|
|
54
|
-
# Snapshots live inside the same archive, via the proven StateManager.
|
|
55
46
|
self._state = StateManager(self.path)
|
|
56
47
|
|
|
57
48
|
# ==================================================================
|
|
@@ -90,44 +81,12 @@ class ProcessStateArchive:
|
|
|
90
81
|
def _runs_dir(self) -> str:
|
|
91
82
|
return os.path.join(self.path, "runs")
|
|
92
83
|
|
|
93
|
-
def
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
def save_run(self, manifest: RunManifest, stream_results: Optional[dict] = None) -> str:
|
|
97
|
-
"""Persist a :class:`RunManifest` (and optional stream timeseries)."""
|
|
84
|
+
def save_run(self, manifest: RunManifest) -> str:
|
|
85
|
+
"""Persist a :class:`RunManifest` to disk."""
|
|
98
86
|
os.makedirs(self._runs_dir(), exist_ok=True)
|
|
99
87
|
run_path = os.path.join(self._runs_dir(), f"{manifest.run_id}.json")
|
|
100
88
|
_write_json(run_path, json.loads(manifest.model_dump_json()))
|
|
101
89
|
|
|
102
|
-
# Stream timeseries (kept for plotting / downstream consumers).
|
|
103
|
-
if stream_results:
|
|
104
|
-
for name, data in stream_results.items():
|
|
105
|
-
if isinstance(data, dict):
|
|
106
|
-
_write_json(os.path.join(self._outputs_dir(), f"{name}.json"), data)
|
|
107
|
-
|
|
108
|
-
# Artifact registry (append-only, keyed by artifact_id).
|
|
109
|
-
registry = _read_json(os.path.join(self.path, "artifacts.json"), {})
|
|
110
|
-
for out in list(manifest.units.values()) + list(manifest.streams.values()):
|
|
111
|
-
for art in getattr(out, "artifacts", []):
|
|
112
|
-
registry[art.artifact_id] = art.model_dump()
|
|
113
|
-
_write_json(os.path.join(self.path, "artifacts.json"), registry)
|
|
114
|
-
|
|
115
|
-
# Field index for fast lookup.
|
|
116
|
-
index = _read_json(os.path.join(self.path, "index.json"), {})
|
|
117
|
-
for unit_name, out in manifest.units.items():
|
|
118
|
-
for f in out.fields:
|
|
119
|
-
index.setdefault(f.name, []).append({
|
|
120
|
-
"run_id": manifest.run_id, "scope": "unit", "name": unit_name,
|
|
121
|
-
"engine": out.engine, "units": f.quantity.unit,
|
|
122
|
-
})
|
|
123
|
-
for stream_name, out in manifest.streams.items():
|
|
124
|
-
for f in out.fields:
|
|
125
|
-
index.setdefault(f.name, []).append({
|
|
126
|
-
"run_id": manifest.run_id, "scope": "stream", "name": stream_name,
|
|
127
|
-
"engine": out.engine, "units": f.quantity.unit,
|
|
128
|
-
})
|
|
129
|
-
_write_json(os.path.join(self.path, "index.json"), index)
|
|
130
|
-
|
|
131
90
|
with open(os.path.join(self.path, "latest_run"), "w", encoding="utf-8") as f:
|
|
132
91
|
f.write(manifest.run_id)
|
|
133
92
|
|
|
@@ -159,8 +118,32 @@ class ProcessStateArchive:
|
|
|
159
118
|
)
|
|
160
119
|
|
|
161
120
|
def field_occurrences(self, field_name: str) -> list[dict]:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
121
|
+
"""Scan ``runs/*.json`` for fields matching *field_name*."""
|
|
122
|
+
results: list[dict] = []
|
|
123
|
+
runs_dir = self._runs_dir()
|
|
124
|
+
if not os.path.isdir(runs_dir):
|
|
125
|
+
return results
|
|
126
|
+
for fname in sorted(os.listdir(runs_dir)):
|
|
127
|
+
if not fname.endswith(".json"):
|
|
128
|
+
continue
|
|
129
|
+
run_id = fname.replace(".json", "")
|
|
130
|
+
manifest = self.load_run(run_id)
|
|
131
|
+
if manifest is None:
|
|
132
|
+
continue
|
|
133
|
+
for unit_name, out in manifest.units.items():
|
|
134
|
+
for f in out.fields:
|
|
135
|
+
if f.name == field_name:
|
|
136
|
+
results.append({
|
|
137
|
+
"run_id": run_id, "scope": "unit",
|
|
138
|
+
"name": unit_name, "engine": out.engine,
|
|
139
|
+
"units": f.quantity.unit,
|
|
140
|
+
})
|
|
141
|
+
for stream_name, out in manifest.streams.items():
|
|
142
|
+
for f in out.fields:
|
|
143
|
+
if f.name == field_name:
|
|
144
|
+
results.append({
|
|
145
|
+
"run_id": run_id, "scope": "stream",
|
|
146
|
+
"name": stream_name, "engine": out.engine,
|
|
147
|
+
"units": f.quantity.unit,
|
|
148
|
+
})
|
|
149
|
+
return results
|
|
@@ -10,6 +10,7 @@ if TYPE_CHECKING:
|
|
|
10
10
|
FlowsheetConfig,
|
|
11
11
|
MaterialDef,
|
|
12
12
|
ProviderConfig,
|
|
13
|
+
RunContext,
|
|
13
14
|
UnitConfig,
|
|
14
15
|
)
|
|
15
16
|
|
|
@@ -87,6 +88,18 @@ class AbstractProvider(ABC):
|
|
|
87
88
|
def teardown(self) -> None:
|
|
88
89
|
"""Release managed resources (FMU instances, Cantera solutions, etc.)."""
|
|
89
90
|
|
|
91
|
+
def set_run_context(self, context: "RunContext") -> None:
|
|
92
|
+
"""Attach run-level orchestration metadata to this provider instance.
|
|
93
|
+
|
|
94
|
+
Called by the framework before a flowsheet run begins. The default
|
|
95
|
+
implementation is a no-op; providers that produce run-scoped artifacts
|
|
96
|
+
(e.g. the containerized HTTP client) may override this to capture the
|
|
97
|
+
context and forward it as needed.
|
|
98
|
+
|
|
99
|
+
Args:
|
|
100
|
+
context: Run identity and related metadata for this execution.
|
|
101
|
+
"""
|
|
102
|
+
|
|
90
103
|
# ------------------------------------------------------------------
|
|
91
104
|
# Simulation provider interface (optional — override for FEM/neutronics)
|
|
92
105
|
# ------------------------------------------------------------------
|
|
@@ -33,6 +33,7 @@ if TYPE_CHECKING:
|
|
|
33
33
|
FlowsheetConfig,
|
|
34
34
|
MaterialDef,
|
|
35
35
|
ProviderConfig,
|
|
36
|
+
RunContext,
|
|
36
37
|
UnitConfig,
|
|
37
38
|
)
|
|
38
39
|
|
|
@@ -57,15 +58,13 @@ class ContainerProviderClient(AbstractProvider):
|
|
|
57
58
|
self._provider_config: Optional["ProviderConfig"] = None
|
|
58
59
|
self._materials: dict = {}
|
|
59
60
|
self._initialized: bool = False
|
|
60
|
-
# Run context, set by the
|
|
61
|
-
# the same run_id / flowsheet_hash as the on-host
|
|
62
|
-
self.
|
|
63
|
-
self._flowsheet_hash: str = ""
|
|
61
|
+
# Run context, set by the framework so container-side artifact uploads
|
|
62
|
+
# carry the same run_id / flowsheet_hash as the on-host archive.
|
|
63
|
+
self._run_context: Optional["RunContext"] = None
|
|
64
64
|
|
|
65
|
-
def set_run_context(self,
|
|
66
|
-
"""
|
|
67
|
-
self.
|
|
68
|
-
self._flowsheet_hash = flowsheet_hash
|
|
65
|
+
def set_run_context(self, context: "RunContext") -> None:
|
|
66
|
+
"""Store run-level metadata for subsequent /run calls."""
|
|
67
|
+
self._run_context = context
|
|
69
68
|
|
|
70
69
|
# ------------------------------------------------------------------
|
|
71
70
|
# Helpers
|
|
@@ -155,9 +154,13 @@ class ContainerProviderClient(AbstractProvider):
|
|
|
155
154
|
"""Release provider state."""
|
|
156
155
|
self._initialized = False
|
|
157
156
|
|
|
158
|
-
def run_simulation(self, unit_config: "UnitConfig", inlet: dict
|
|
157
|
+
def run_simulation(self, unit_config: "UnitConfig", inlet: dict) -> "EngineOutput":
|
|
159
158
|
"""Serialise the request, POST it to the container, return the result.
|
|
160
159
|
|
|
160
|
+
Run context (run_id / flowsheet_hash) is read from the context set by
|
|
161
|
+
``set_run_context`` and forwarded in the request body so the container's
|
|
162
|
+
artifact uploads are keyed consistently with the on-host archive.
|
|
163
|
+
|
|
161
164
|
The container returns a serialized :class:`EngineOutput`. Artifact
|
|
162
165
|
``local_path`` values point at files *inside* the container and are not
|
|
163
166
|
reachable from the CLI, so any artifact that carries ``remote_uris``
|
|
@@ -178,14 +181,13 @@ class ContainerProviderClient(AbstractProvider):
|
|
|
178
181
|
else {"type": unit_config.provider or self._ptype, "url": self._url}
|
|
179
182
|
)
|
|
180
183
|
|
|
181
|
-
#
|
|
182
|
-
#
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if
|
|
186
|
-
run_id = self.
|
|
187
|
-
|
|
188
|
-
flowsheet_hash = self._flowsheet_hash or None
|
|
184
|
+
# Read run context set by the framework. Empty strings are sent when no
|
|
185
|
+
# context is set so the container server can still log the run_id field.
|
|
186
|
+
run_id = ""
|
|
187
|
+
flowsheet_hash = ""
|
|
188
|
+
if self._run_context is not None:
|
|
189
|
+
run_id = self._run_context.run_id or ""
|
|
190
|
+
flowsheet_hash = self._run_context.flowsheet_hash or ""
|
|
189
191
|
|
|
190
192
|
body = {
|
|
191
193
|
"unit_config": self._serialize_unit_config(unit_config),
|
|
@@ -17,7 +17,7 @@ from typing import Optional
|
|
|
17
17
|
from loguru import logger
|
|
18
18
|
from pydantic import BaseModel, ConfigDict
|
|
19
19
|
|
|
20
|
-
from processforge.types import CoolPropProviderConfig, FlowsheetConfig, ProviderConfig
|
|
20
|
+
from processforge.types import CoolPropProviderConfig, FlowsheetConfig, ProviderConfig, RunContext
|
|
21
21
|
|
|
22
22
|
from .base import AbstractProvider
|
|
23
23
|
from .coolprop_provider import CoolPropProvider
|
|
@@ -181,6 +181,21 @@ def build_provider_map(
|
|
|
181
181
|
return ProviderMap(providers=providers, default=default)
|
|
182
182
|
|
|
183
183
|
|
|
184
|
+
def apply_run_context(
|
|
185
|
+
provider_map: ProviderMap | None,
|
|
186
|
+
context: RunContext | None,
|
|
187
|
+
) -> None:
|
|
188
|
+
"""Propagate run-level metadata to every provider in *provider_map*.
|
|
189
|
+
|
|
190
|
+
Providers that do not consume run context (e.g. CoolProp) inherit a no-op
|
|
191
|
+
implementation from ``AbstractProvider``.
|
|
192
|
+
"""
|
|
193
|
+
if provider_map is None or context is None:
|
|
194
|
+
return
|
|
195
|
+
for provider in provider_map.values():
|
|
196
|
+
provider.set_run_context(context)
|
|
197
|
+
|
|
198
|
+
|
|
184
199
|
def teardown_providers(provider_map: ProviderMap | None) -> None:
|
|
185
200
|
"""Call ``teardown()`` on every provider in the map.
|
|
186
201
|
|
|
@@ -291,34 +291,6 @@ def save_results_zarr(
|
|
|
291
291
|
return store_path
|
|
292
292
|
|
|
293
293
|
|
|
294
|
-
def relink_latest_results(archive_path: str, run_id: str) -> None:
|
|
295
|
-
"""Point ``<archive>/results.zarr`` at the latest per-run zarr.
|
|
296
|
-
|
|
297
|
-
Each run now writes its zarr to ``<archive>/results/<run_id>/results.zarr``
|
|
298
|
-
(see `save_results_zarr`). To keep backward compatibility with tooling that
|
|
299
|
-
reads a single ``results.zarr`` at the archive root, we make that path a
|
|
300
|
-
symlink to the newest run. Falls back to a copy on platforms/filesystems
|
|
301
|
-
without symlink support (or when the existing target is a real directory).
|
|
302
|
-
"""
|
|
303
|
-
latest = os.path.join(archive_path, "results", run_id, "results.zarr")
|
|
304
|
-
if not os.path.exists(latest):
|
|
305
|
-
return
|
|
306
|
-
link_path = os.path.join(archive_path, "results.zarr")
|
|
307
|
-
|
|
308
|
-
# Remove any existing target (real dir or stale/broken symlink) without
|
|
309
|
-
# following the link.
|
|
310
|
-
if os.path.islink(link_path):
|
|
311
|
-
os.unlink(link_path)
|
|
312
|
-
elif os.path.exists(link_path):
|
|
313
|
-
shutil.rmtree(link_path)
|
|
314
|
-
|
|
315
|
-
try:
|
|
316
|
-
os.symlink(latest, link_path)
|
|
317
|
-
except (OSError, NotImplementedError):
|
|
318
|
-
# Non-POSIX / restricted filesystem: keep a physical copy instead.
|
|
319
|
-
shutil.copytree(latest, link_path)
|
|
320
|
-
|
|
321
|
-
|
|
322
294
|
def save_results_zarr_s3(results, s3_uri: str, run_info: RunInfo | dict | None = None):
|
|
323
295
|
"""Write simulation results directly to an S3-backed Zarr store.
|
|
324
296
|
|
|
@@ -8,6 +8,7 @@ Adding a new provider never requires changes to these models.
|
|
|
8
8
|
"""
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
|
+
from dataclasses import dataclass
|
|
11
12
|
from typing import Optional, Union
|
|
12
13
|
|
|
13
14
|
import numpy as np
|
|
@@ -16,6 +17,19 @@ from pydantic import BaseModel, ConfigDict, Field
|
|
|
16
17
|
from .quantity import Quantity
|
|
17
18
|
|
|
18
19
|
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class RunContext:
|
|
22
|
+
"""Orchestration metadata for one flowsheet run.
|
|
23
|
+
|
|
24
|
+
Passed to providers via ``AbstractProvider.set_run_context`` so backends
|
|
25
|
+
can tag artifacts, logs, and provenance with the same run identity the
|
|
26
|
+
CLI archive uses.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
run_id: Optional[str] = None
|
|
30
|
+
flowsheet_hash: Optional[str] = None
|
|
31
|
+
|
|
32
|
+
|
|
19
33
|
class MaterialDef(BaseModel):
|
|
20
34
|
"""Framework-level representation of a material loaded from the flowsheet JSON.
|
|
21
35
|
|
|
@@ -322,6 +322,17 @@ class TestCmdInit:
|
|
|
322
322
|
assert any("non-empty" in m for m in log_output)
|
|
323
323
|
assert any("providers" in m for m in log_output)
|
|
324
324
|
|
|
325
|
+
def test_init_with_coolprop_provider(self, tmp_path, coolprop_flowsheet, log_output):
|
|
326
|
+
from processforge.cli.init import init
|
|
327
|
+
from processforge.lock import read_lock
|
|
328
|
+
|
|
329
|
+
init(flowsheet=str(coolprop_flowsheet), path=str(tmp_path))
|
|
330
|
+
assert (tmp_path / ".processforge" / "config.json").exists()
|
|
331
|
+
lock = read_lock(str(tmp_path / ".processforge"), str(coolprop_flowsheet))
|
|
332
|
+
assert lock is not None
|
|
333
|
+
assert "coolprop" in lock["providers"]
|
|
334
|
+
assert any("initialised successfully" in m for m in log_output)
|
|
335
|
+
|
|
325
336
|
|
|
326
337
|
# ---------------------------------------------------------------------------
|
|
327
338
|
# cli/validate.py
|