processforge 0.6.0__tar.gz → 0.6.3__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.
Files changed (165) hide show
  1. {processforge-0.6.0/src/processforge.egg-info → processforge-0.6.3}/PKG-INFO +19 -2
  2. {processforge-0.6.0 → processforge-0.6.3}/README.md +17 -0
  3. {processforge-0.6.0 → processforge-0.6.3}/pyproject.toml +2 -2
  4. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/__init__.py +42 -24
  5. processforge-0.6.3/src/processforge/cli/apply.py +55 -0
  6. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/init.py +0 -24
  7. processforge-0.6.3/src/processforge/cli/run.py +30 -0
  8. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/runs.py +16 -0
  9. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/output_collector.py +1 -1
  10. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/persistence/artifact_store.py +94 -6
  11. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/provenance.py +1 -1
  12. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/result.py +85 -48
  13. processforge-0.6.3/src/processforge/runner.py +790 -0
  14. {processforge-0.6.0 → processforge-0.6.3/src/processforge.egg-info}/PKG-INFO +19 -2
  15. {processforge-0.6.0 → processforge-0.6.3}/src/processforge.egg-info/SOURCES.txt +3 -0
  16. {processforge-0.6.0 → processforge-0.6.3}/src/processforge.egg-info/requires.txt +1 -1
  17. processforge-0.6.3/tests/test_artifact_store.py +84 -0
  18. {processforge-0.6.0 → processforge-0.6.3}/tests/test_cli.py +44 -157
  19. processforge-0.6.3/tests/test_runner.py +141 -0
  20. processforge-0.6.0/src/processforge/cli/apply.py +0 -209
  21. processforge-0.6.0/src/processforge/cli/run.py +0 -221
  22. {processforge-0.6.0 → processforge-0.6.3}/LICENSE +0 -0
  23. {processforge-0.6.0 → processforge-0.6.3}/MANIFEST.in +0 -0
  24. {processforge-0.6.0 → processforge-0.6.3}/flowsheets/closed-loop-chain.json +0 -0
  25. {processforge-0.6.0 → processforge-0.6.3}/flowsheets/coupled/msre_coupled.json +0 -0
  26. {processforge-0.6.0 → processforge-0.6.3}/flowsheets/custom/crimson/MUWS_HB.json +0 -0
  27. {processforge-0.6.0 → processforge-0.6.3}/flowsheets/custom/crimson/simple_water_system.json +0 -0
  28. {processforge-0.6.0 → processforge-0.6.3}/flowsheets/custom/simple_hyrdaulic_scheme.json +0 -0
  29. {processforge-0.6.0 → processforge-0.6.3}/flowsheets/festim/hydrogen_transport_1d.json +0 -0
  30. {processforge-0.6.0 → processforge-0.6.3}/flowsheets/festim/tds_tungsten.json +0 -0
  31. {processforge-0.6.0 → processforge-0.6.3}/flowsheets/hydraulic-chain.json +0 -0
  32. {processforge-0.6.0 → processforge-0.6.3}/flowsheets/openmc/msre_eigenvalue.json +0 -0
  33. {processforge-0.6.0 → processforge-0.6.3}/setup.cfg +0 -0
  34. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/__main__.py +0 -0
  35. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/_schema.py +0 -0
  36. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/analysis/__init__.py +0 -0
  37. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/analysis/dof.py +0 -0
  38. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/api/__init__.py +0 -0
  39. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/api/serve.py +0 -0
  40. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/__init__.py +0 -0
  41. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/common.py +0 -0
  42. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/diagram.py +0 -0
  43. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/display.py +0 -0
  44. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/export_fmu.py +0 -0
  45. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/export_modelica.py +0 -0
  46. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/persist.py +0 -0
  47. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/plan.py +0 -0
  48. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/cli/validate.py +0 -0
  49. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/compose.py +0 -0
  50. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/coupling.py +0 -0
  51. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/__init__.py +0 -0
  52. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/backends/__init__.py +0 -0
  53. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/backends/base.py +0 -0
  54. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/backends/casadi_backend.py +0 -0
  55. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/backends/pyomo_backend.py +0 -0
  56. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/backends/scipy_backend.py +0 -0
  57. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/flowsheet.py +0 -0
  58. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/jacobian.py +0 -0
  59. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/mixin.py +0 -0
  60. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/solver.py +0 -0
  61. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/stream_var.py +0 -0
  62. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/units/__init__.py +0 -0
  63. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/units/flash_eo.py +0 -0
  64. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/units/heater_eo.py +0 -0
  65. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/units/pipes_eo.py +0 -0
  66. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/units/pump_eo.py +0 -0
  67. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/units/strainer_eo.py +0 -0
  68. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/eo/units/valve_eo.py +0 -0
  69. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/flowsheet.py +0 -0
  70. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/fmu/__init__.py +0 -0
  71. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/fmu/_fmi_vars.py +0 -0
  72. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/fmu/builder.py +0 -0
  73. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/fmu/interface.py +0 -0
  74. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/fmu/slave_template.py +0 -0
  75. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/lock.py +0 -0
  76. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/modelica/__init__.py +0 -0
  77. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/modelica/mo_writer.py +0 -0
  78. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/modelica/omc_runner.py +0 -0
  79. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/modelica/transpiler.py +0 -0
  80. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/modelica/unit_equations.py +0 -0
  81. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/pathsim/__init__.py +0 -0
  82. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/pathsim/adapter.py +0 -0
  83. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/pcl/__init__.py +0 -0
  84. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/pcl/compiler.py +0 -0
  85. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/pcl/namespace.py +0 -0
  86. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/persistence/__init__.py +0 -0
  87. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/persistence/archive.py +0 -0
  88. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/__init__.py +0 -0
  89. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/_sim_strategy.py +0 -0
  90. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/base.py +0 -0
  91. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/base_jacobian_mixin.py +0 -0
  92. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/base_simulation_provider.py +0 -0
  93. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/cantera_jacobian.py +0 -0
  94. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/cantera_provider.py +0 -0
  95. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/container_client.py +0 -0
  96. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/coolprop_provider.py +0 -0
  97. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/errors.py +0 -0
  98. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/festim/__init__.py +0 -0
  99. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/festim/build_helpers.py +0 -0
  100. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/festim/provider.py +0 -0
  101. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/festim/result_extraction.py +0 -0
  102. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/festim/strategies.py +0 -0
  103. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/jacobian_contributor.py +0 -0
  104. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/manager.py +0 -0
  105. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/modelica_jacobian.py +0 -0
  106. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/modelica_provider.py +0 -0
  107. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/openmc/__init__.py +0 -0
  108. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/openmc/build_helpers.py +0 -0
  109. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/openmc/provider.py +0 -0
  110. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/openmc/result_extraction.py +0 -0
  111. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/openmc/strategies.py +0 -0
  112. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/reference_state_registry.py +0 -0
  113. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/providers/registry.py +0 -0
  114. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/quantity.py +0 -0
  115. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/result_schema.py +0 -0
  116. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/schemas/__init__.py +0 -0
  117. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/schemas/festim/festim_model.py +0 -0
  118. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/schemas/flowsheet_schema.json +0 -0
  119. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/schemas/openmc/openmc_model.py +0 -0
  120. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/simulate.py +0 -0
  121. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/solver.py +0 -0
  122. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/state.py +0 -0
  123. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/thermo.py +0 -0
  124. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/types.py +0 -0
  125. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/__init__.py +0 -0
  126. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/base.py +0 -0
  127. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/cstr.py +0 -0
  128. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/flash.py +0 -0
  129. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/heater.py +0 -0
  130. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/pfr.py +0 -0
  131. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/pipes.py +0 -0
  132. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/pump.py +0 -0
  133. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/registry.py +0 -0
  134. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/solver_unit.py +0 -0
  135. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/strainer.py +0 -0
  136. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/tank.py +0 -0
  137. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/units/valve.py +0 -0
  138. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/utils/__init__.py +0 -0
  139. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/utils/flowsheet_diagram.py +0 -0
  140. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/utils/mermaid_diagram.py +0 -0
  141. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/utils/s3_upload.py +0 -0
  142. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/utils/topology.py +0 -0
  143. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/utils/unit_consistency.py +0 -0
  144. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/utils/validate_flowsheet.py +0 -0
  145. {processforge-0.6.0 → processforge-0.6.3}/src/processforge/utils/validation.py +0 -0
  146. {processforge-0.6.0 → processforge-0.6.3}/src/processforge.egg-info/dependency_links.txt +0 -0
  147. {processforge-0.6.0 → processforge-0.6.3}/src/processforge.egg-info/entry_points.txt +0 -0
  148. {processforge-0.6.0 → processforge-0.6.3}/src/processforge.egg-info/top_level.txt +0 -0
  149. {processforge-0.6.0 → processforge-0.6.3}/tests/test_container_client.py +0 -0
  150. {processforge-0.6.0 → processforge-0.6.3}/tests/test_coupling.py +0 -0
  151. {processforge-0.6.0 → processforge-0.6.3}/tests/test_display.py +0 -0
  152. {processforge-0.6.0 → processforge-0.6.3}/tests/test_festim_provider.py +0 -0
  153. {processforge-0.6.0 → processforge-0.6.3}/tests/test_festim_schema.py +0 -0
  154. {processforge-0.6.0 → processforge-0.6.3}/tests/test_fmu_solverunit.py +0 -0
  155. {processforge-0.6.0 → processforge-0.6.3}/tests/test_init.py +0 -0
  156. {processforge-0.6.0 → processforge-0.6.3}/tests/test_openmc_provider.py +0 -0
  157. {processforge-0.6.0 → processforge-0.6.3}/tests/test_pathsim_adapter.py +0 -0
  158. {processforge-0.6.0 → processforge-0.6.3}/tests/test_persist.py +0 -0
  159. {processforge-0.6.0 → processforge-0.6.3}/tests/test_provider_errors.py +0 -0
  160. {processforge-0.6.0 → processforge-0.6.3}/tests/test_providers.py +0 -0
  161. {processforge-0.6.0 → processforge-0.6.3}/tests/test_result_zarr.py +0 -0
  162. {processforge-0.6.0 → processforge-0.6.3}/tests/test_runs_command.py +0 -0
  163. {processforge-0.6.0 → processforge-0.6.3}/tests/test_s3_upload.py +0 -0
  164. {processforge-0.6.0 → processforge-0.6.3}/tests/test_state.py +0 -0
  165. {processforge-0.6.0 → processforge-0.6.3}/tests/test_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: processforge
3
- Version: 0.6.0
3
+ Version: 0.6.3
4
4
  Summary: A Python-based process simulation framework for chemical engineering applications.
5
5
  Author-email: Processforge Team <team@processforge.dev>
6
6
  License-Expression: BSD-3-Clause
@@ -22,8 +22,8 @@ License-File: LICENSE
22
22
  Requires-Dist: numpy>=2.0
23
23
  Requires-Dist: pydantic>=2.0
24
24
  Requires-Dist: scipy>=1.14
25
- Requires-Dist: matplotlib>=3.9
26
25
  Requires-Dist: loguru>=0.7
26
+ Requires-Dist: plotext>=5.2
27
27
  Requires-Dist: jsonschema>=4.20
28
28
  Requires-Dist: graphviz>=0.20
29
29
  Requires-Dist: pandas>=2.2
@@ -134,13 +134,30 @@ uv tool install "processforge[modelica]"
134
134
 
135
135
  ## Python API
136
136
 
137
+ ### Low-level API
138
+
137
139
  ```python
138
140
  from processforge import EOFlowsheet, validate_flowsheet
141
+
139
142
  config = validate_flowsheet("flowsheets/hydraulic-chain.json")
140
143
  fs = EOFlowsheet(config, backend="scipy")
141
144
  results = fs.run()
142
145
  ```
143
146
 
147
+ ### High-level runner (web-app friendly)
148
+
149
+ ```python
150
+ from processforge import run_flowsheet
151
+
152
+ result = run_flowsheet("flowsheets/hydraulic-chain.json")
153
+ print(result.run_id, result.status, result.remote_uris)
154
+ ```
155
+
156
+ `run_flowsheet` and `apply_flowsheet` perform the full CLI lifecycle
157
+ (validate, health-check, solve, persist, and upload the pfarchive to S3) and
158
+ return structured results instead of calling `SystemExit`. See
159
+ [docs/usage.md](docs/usage.md) for a FastAPI + S3/Railway example.
160
+
144
161
  ## Usage
145
162
  See the [usage guide](docs/usage.md) for CLI commands and workflows.
146
163
 
@@ -67,13 +67,30 @@ uv tool install "processforge[modelica]"
67
67
 
68
68
  ## Python API
69
69
 
70
+ ### Low-level API
71
+
70
72
  ```python
71
73
  from processforge import EOFlowsheet, validate_flowsheet
74
+
72
75
  config = validate_flowsheet("flowsheets/hydraulic-chain.json")
73
76
  fs = EOFlowsheet(config, backend="scipy")
74
77
  results = fs.run()
75
78
  ```
76
79
 
80
+ ### High-level runner (web-app friendly)
81
+
82
+ ```python
83
+ from processforge import run_flowsheet
84
+
85
+ result = run_flowsheet("flowsheets/hydraulic-chain.json")
86
+ print(result.run_id, result.status, result.remote_uris)
87
+ ```
88
+
89
+ `run_flowsheet` and `apply_flowsheet` perform the full CLI lifecycle
90
+ (validate, health-check, solve, persist, and upload the pfarchive to S3) and
91
+ return structured results instead of calling `SystemExit`. See
92
+ [docs/usage.md](docs/usage.md) for a FastAPI + S3/Railway example.
93
+
77
94
  ## Usage
78
95
  See the [usage guide](docs/usage.md) for CLI commands and workflows.
79
96
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "processforge"
7
- version = "0.6.0"
7
+ version = "0.6.3"
8
8
  description = "A Python-based process simulation framework for chemical engineering applications."
9
9
  readme = "README.md"
10
10
  license = "BSD-3-Clause"
@@ -28,8 +28,8 @@ dependencies = [
28
28
  "numpy>=2.0",
29
29
  "pydantic>=2.0",
30
30
  "scipy>=1.14",
31
- "matplotlib>=3.9",
32
31
  "loguru>=0.7",
32
+ "plotext>=5.2",
33
33
  "jsonschema>=4.20",
34
34
  "graphviz>=0.20",
35
35
  "pandas>=2.2",
@@ -10,44 +10,62 @@ Provides steady-state and dynamic process simulation capabilities including:
10
10
  - Equation-oriented (EO) steady-state solver via EOFlowsheet
11
11
  """
12
12
 
13
+ __version__ = "0.6.3"
14
+
15
+ from .eo import EOFlowsheet, EOSolver
13
16
  from .flowsheet import Flowsheet
14
17
  from .provenance import build_run_info
15
- from .solver import Solver
16
- from .thermo import rachford_rice
17
- from .utils.validate_flowsheet import validate_flowsheet
18
18
  from .result import (
19
- plot_results,
20
- plot_timeseries,
21
19
  save_results_zarr,
22
20
  )
21
+ from .runner import (
22
+ ApplyResult,
23
+ ConvergenceError,
24
+ FlowsheetValidationError,
25
+ ProcessforgeRunError,
26
+ ProviderRunError,
27
+ ProviderUnavailableError,
28
+ RunResult,
29
+ StatePersistenceError,
30
+ apply_flowsheet,
31
+ run_flowsheet,
32
+ )
33
+ from .solver import Solver
34
+ from .thermo import rachford_rice
35
+ from .units.flash import Flash
36
+ from .units.heater import Heater
37
+ from .units.pipes import Pipes
23
38
  from .units.pump import Pump
24
- from .units.valve import Valve
25
39
  from .units.strainer import Strainer
26
40
  from .units.tank import Tank
27
- from .units.pipes import Pipes
28
- from .units.flash import Flash
29
- from .units.heater import Heater
30
- from .eo import EOFlowsheet, EOSolver
31
-
32
- __version__ = "0.6.0"
41
+ from .units.valve import Valve
42
+ from .utils.validate_flowsheet import validate_flowsheet
33
43
 
34
44
  __all__ = [
35
- "Flowsheet",
45
+ "ApplyResult",
46
+ "ConvergenceError",
36
47
  "EOFlowsheet",
37
48
  "EOSolver",
38
- "Solver",
39
- "rachford_rice",
40
- "validate_flowsheet",
41
- "plot_results",
42
- "plot_timeseries",
43
- "save_results_zarr",
44
- "build_run_info",
49
+ "Flash",
50
+ "Flowsheet",
51
+ "FlowsheetValidationError",
52
+ "Heater",
53
+ "Pipes",
54
+ "ProcessforgeRunError",
55
+ "ProviderRunError",
56
+ "ProviderUnavailableError",
45
57
  "Pump",
46
- "Valve",
58
+ "RunResult",
59
+ "Solver",
60
+ "StatePersistenceError",
47
61
  "Strainer",
48
62
  "Tank",
49
- "Pipes",
50
- "Flash",
51
- "Heater",
63
+ "Valve",
52
64
  "__version__",
65
+ "apply_flowsheet",
66
+ "build_run_info",
67
+ "rachford_rice",
68
+ "run_flowsheet",
69
+ "save_results_zarr",
70
+ "validate_flowsheet",
53
71
  ]
@@ -0,0 +1,55 @@
1
+ """``pf apply`` — state-based warm start with homotopy fallback."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Literal
6
+
7
+ import typer
8
+ from loguru import logger
9
+
10
+ from ..runner import ProcessforgeRunError, apply_flowsheet
11
+
12
+
13
+ def apply(
14
+ flowsheet: str = typer.Argument(help="Path to the flowsheet JSON file"),
15
+ backend: Literal["scipy", "pyomo", "casadi"] | None = typer.Option(
16
+ None,
17
+ "--backend",
18
+ help="Override the flowsheet's simulation.backend",
19
+ ),
20
+ tolerance: float = typer.Option(
21
+ 1e-6,
22
+ "--tolerance",
23
+ help="Newton solver convergence tolerance (default: 1e-6)",
24
+ ),
25
+ max_iter: int = typer.Option(
26
+ 50,
27
+ "--max-iter",
28
+ help="Max Newton iterations (default: 50)",
29
+ ),
30
+ skip_homotopy: bool = typer.Option(
31
+ False,
32
+ "--skip-homotopy",
33
+ help="Disable homotopy fallback; cold-start only",
34
+ ),
35
+ ) -> None:
36
+ """Apply flowsheet: drift detection, warm-start, homotopy fallback, convergence guardrails."""
37
+ try:
38
+ result = apply_flowsheet(
39
+ flowsheet,
40
+ backend=backend,
41
+ tolerance=tolerance,
42
+ max_iter=max_iter,
43
+ skip_homotopy=skip_homotopy,
44
+ )
45
+ except ProcessforgeRunError as exc:
46
+ logger.error(str(exc))
47
+ raise SystemExit(1) from exc
48
+
49
+ logger.info("=== Apply Summary ===")
50
+ logger.info(f" Status : {result.status}")
51
+ logger.info(f" Run ID : {result.run_id}")
52
+ logger.info(f" Snapshot ID : {result.snapshot_id}")
53
+ logger.info(f" Archive : {result.archive_path}")
54
+ if result.remote_uris:
55
+ logger.info(f" Remote URIs : {len(result.remote_uris)} object(s) in S3")
@@ -3,7 +3,6 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import importlib.util
6
- import json
7
6
  import os
8
7
  import shutil
9
8
  import subprocess
@@ -116,29 +115,6 @@ def init(
116
115
  # dir so existing repos aren't silently broken by the new structure.
117
116
  _migrate_legacy_env(pf_dir)
118
117
 
119
- # Write config.json (always)
120
- config_path = os.path.join(pf_dir, "config.json")
121
- if not os.path.exists(config_path):
122
- default_config = {
123
- "version": 1,
124
- "default_backend": "scipy",
125
- "outputs_dir": "outputs",
126
- }
127
- with open(config_path, "w", encoding="utf-8") as f:
128
- json.dump(default_config, f, indent=2)
129
- logger.info(f"Created {config_path}")
130
- else:
131
- logger.info(f"{config_path} already exists — skipped.")
132
-
133
- # Honour a configured outputs_dir for the rest of init.
134
- outputs_dir_name = "outputs"
135
- try:
136
- with open(config_path, encoding="utf-8") as f:
137
- outputs_dir_name = json.load(f).get("outputs_dir", "outputs")
138
- except Exception:
139
- pass
140
- outputs_dir = os.path.join(root, outputs_dir_name)
141
-
142
118
  # Remove stale .pfstate snapshot directories from outputs/
143
119
  stale_count = 0
144
120
  for entry in os.listdir(outputs_dir):
@@ -0,0 +1,30 @@
1
+ """``pf run`` — run a process simulation from a flowsheet JSON file."""
2
+ from __future__ import annotations
3
+
4
+ import typer
5
+ from loguru import logger
6
+
7
+ from ..runner import ProcessforgeRunError, run_flowsheet
8
+
9
+
10
+ def run(
11
+ flowsheet: str = typer.Argument(help="Path to the flowsheet JSON file"),
12
+ no_plot: bool = typer.Option(
13
+ False,
14
+ "--no-plot",
15
+ help="Skip terminal plots for simulation outputs",
16
+ ),
17
+ ) -> None:
18
+ """Run a process simulation from a flowsheet JSON file."""
19
+ try:
20
+ result = run_flowsheet(flowsheet, no_plot=no_plot)
21
+ except ProcessforgeRunError as exc:
22
+ logger.error(str(exc))
23
+ raise SystemExit(1) from exc
24
+
25
+ logger.info("=== Run Summary ===")
26
+ logger.info(f" Status : {result.status}")
27
+ logger.info(f" Run ID : {result.run_id}")
28
+ logger.info(f" Archive : {result.archive_path}")
29
+ if result.remote_uris:
30
+ logger.info(f" Remote URIs : {len(result.remote_uris)} object(s) in S3")
@@ -15,6 +15,7 @@ from ..result import (
15
15
  _fmt_scientific,
16
16
  _one_line_summary,
17
17
  _scalar_from_sequence,
18
+ plot_zarr_summary_terminal,
18
19
  summarize_zarr_store,
19
20
  )
20
21
 
@@ -157,6 +158,11 @@ def runs(
157
158
  "--schema",
158
159
  help="Print the result schema JSON instead of the summary.",
159
160
  ),
161
+ no_plot: bool = typer.Option(
162
+ False,
163
+ "--no-plot",
164
+ help="Skip terminal plots for the run summary.",
165
+ ),
160
166
  ):
161
167
  """List runs for a flowsheet, or inspect one run's Zarr result summary."""
162
168
  base = flowsheet_basename(flowsheet)
@@ -197,6 +203,16 @@ def runs(
197
203
  manifest = archive.load_run(resolved_id)
198
204
  summary = summarize_zarr_store(zarr_path)
199
205
  summary["_zarr_path"] = zarr_path
206
+
207
+ if not no_plot:
208
+ plot_title = f"{base} / {resolved_id}"
209
+ try:
210
+ plot_zarr_summary_terminal(summary, title=plot_title)
211
+ except Exception as exc: # noqa: BLE001
212
+ logger.warning(
213
+ f"Failed to render terminal plots: {type(exc).__name__}: {exc}"
214
+ )
215
+
200
216
  typer.echo(_format_run_compact(manifest, summary))
201
217
  return
202
218
 
@@ -36,7 +36,7 @@ def _to_scalar(value):
36
36
 
37
37
  Dynamic simulations store stream properties as timeseries lists. For
38
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`.
39
+ scalar, matching the convention used by terminal result plots.
40
40
  """
41
41
  if isinstance(value, (list, tuple, np.ndarray)):
42
42
  arr = np.asarray(value)
@@ -10,8 +10,6 @@ from __future__ import annotations
10
10
 
11
11
  import hashlib
12
12
  import os
13
- from datetime import datetime, timezone
14
- from typing import Optional
15
13
 
16
14
  from loguru import logger
17
15
 
@@ -44,9 +42,9 @@ def _artifact_kind(path: str) -> str:
44
42
  class ArtifactStore:
45
43
  """Register and upload simulation artifact files to object storage."""
46
44
 
47
- def __init__(self, bucket: Optional[str] = None, prefix: str = "processforge"):
45
+ def __init__(self, bucket: str | None = None, prefix: str | None = None):
48
46
  self.bucket = bucket or os.environ.get("S3_BUCKET")
49
- self.prefix = prefix
47
+ self.prefix = prefix or os.environ.get("S3_PREFIX", "processforge")
50
48
 
51
49
  # ------------------------------------------------------------------
52
50
  # Registration
@@ -55,8 +53,8 @@ class ArtifactStore:
55
53
  self,
56
54
  path: str,
57
55
  *,
58
- name: Optional[str] = None,
59
- kind: Optional[str] = None,
56
+ name: str | None = None,
57
+ kind: str | None = None,
60
58
  run_id: str = "",
61
59
  flowsheet_hash: str = "",
62
60
  unit: str = "",
@@ -115,6 +113,96 @@ class ArtifactStore:
115
113
  logger.warning(f"S3 upload of '{artifact.name}' failed: {exc}")
116
114
  return artifact
117
115
 
116
+ # ------------------------------------------------------------------
117
+ # Host-side archive upload
118
+ # ------------------------------------------------------------------
119
+ def upload_file(
120
+ self,
121
+ path: str,
122
+ *,
123
+ remote_key: str,
124
+ ) -> str | None:
125
+ """Upload a single local file to a specific S3 key.
126
+
127
+ Returns the S3 URI on success, or ``None`` when S3 is not configured or
128
+ the upload failed.
129
+ """
130
+ if not self.bucket or not os.path.exists(path):
131
+ return None
132
+ try:
133
+ import s3fs
134
+
135
+ uri = f"s3://{self.bucket}/{remote_key}"
136
+ fs = s3fs.S3FileSystem(**s3_storage_options())
137
+ fs.put(path, uri)
138
+ logger.info(f"Uploaded file '{os.path.basename(path)}' to {uri}")
139
+ return uri
140
+ except Exception as exc: # noqa: BLE001
141
+ logger.warning(f"S3 upload of '{path}' failed: {exc}")
142
+ return None
143
+
144
+ def upload_directory(
145
+ self,
146
+ local_dir: str,
147
+ *,
148
+ key_prefix: str,
149
+ run_id: str = "",
150
+ flowsheet_hash: str = "",
151
+ ) -> list[str]:
152
+ """Recursively upload a local directory to S3 under *key_prefix*.
153
+
154
+ Relative paths inside *local_dir* are preserved in the S3 keys. Returns
155
+ the list of URIs that were uploaded (or an empty list when S3 is
156
+ disabled).
157
+ """
158
+ if not self.bucket or not os.path.isdir(local_dir):
159
+ return []
160
+
161
+ base_key = "/".join(p for p in [self.prefix, flowsheet_hash, run_id, key_prefix] if p)
162
+ try:
163
+ import s3fs
164
+
165
+ fs = s3fs.S3FileSystem(**s3_storage_options())
166
+ except Exception as exc: # noqa: BLE001
167
+ logger.warning(f"S3 upload of directory '{local_dir}' failed: {exc}")
168
+ return []
169
+
170
+ uris: list[str] = []
171
+ for root, _dirs, files in os.walk(local_dir):
172
+ for name in files:
173
+ local_path = os.path.join(root, name)
174
+ rel = os.path.relpath(local_path, local_dir)
175
+ key = f"{base_key}/{rel}"
176
+ uri = f"s3://{self.bucket}/{key}"
177
+ try:
178
+ fs.put(local_path, uri)
179
+ uris.append(uri)
180
+ except Exception as exc: # noqa: BLE001
181
+ logger.warning(f"S3 upload of '{rel}' failed: {exc}")
182
+ logger.info(f"Uploaded directory '{local_dir}' to {len(uris)} S3 object(s)")
183
+ return uris
184
+
185
+ def persist_archive(
186
+ self,
187
+ archive_path: str,
188
+ *,
189
+ run_id: str = "",
190
+ flowsheet_hash: str = "",
191
+ ) -> list[str]:
192
+ """Upload an entire processforge pfarchive directory to S3.
193
+
194
+ Keys are laid out as ``<prefix>/<flowsheet_hash>/<run_id>/archive/<relpath>``.
195
+ This uploads the run manifest, Zarr results, snapshots, and registry
196
+ files from the host process so they are durable even when the host's
197
+ local disk is ephemeral.
198
+ """
199
+ return self.upload_directory(
200
+ archive_path,
201
+ key_prefix="archive",
202
+ run_id=run_id,
203
+ flowsheet_hash=flowsheet_hash,
204
+ )
205
+
118
206
  # ------------------------------------------------------------------
119
207
  # Container-side convenience: persist all artifacts in engine outputs
120
208
  # ------------------------------------------------------------------
@@ -18,7 +18,7 @@ _KEY_PACKAGES = [
18
18
  "loguru",
19
19
  "pandas",
20
20
  "openpyxl",
21
- "matplotlib",
21
+ "plotext",
22
22
  "jsonschema",
23
23
  "graphviz",
24
24
  ]
@@ -5,7 +5,7 @@ from datetime import datetime, timezone
5
5
 
6
6
  import numpy as np
7
7
  import pandas as pd
8
- import matplotlib.pyplot as plt
8
+ import plotext as plt
9
9
  import zarr
10
10
  from loguru import logger
11
11
 
@@ -355,44 +355,54 @@ def save_results_zarr_s3(results, s3_uri: str, run_info: RunInfo | dict | None =
355
355
  logger.info(f"Saved Zarr results to {s3_uri}")
356
356
 
357
357
 
358
- def plot_results(results, fname="results.png"):
359
- os.makedirs("outputs", exist_ok=True)
360
- streams = list(results.keys())
358
+ def _plotext_figure():
359
+ """Return a fresh plotext figure with a sensible terminal size."""
360
+ fig = plt.figure
361
+ fig.clear()
362
+ fig.plot_size(80, 18)
363
+ return fig
364
+
365
+
366
+ def plot_results_terminal(results, title=""):
367
+ """Render steady-state stream results as terminal bar charts."""
368
+ streams = [k for k, v in results.items() if isinstance(v, dict) and "T" in v]
369
+ if not streams:
370
+ return
371
+
361
372
  temp_values = [_scalar_from_sequence(results[s].get("T")) or 0.0 for s in streams]
362
373
 
363
- plt.figure(figsize=(8, 4))
364
- plt.bar(streams, temp_values, color="skyblue")
365
- plt.ylabel("Temperature [K]")
366
- plt.title("Stream Temperatures (Steady State)")
367
- plt.tight_layout()
368
- plt.savefig(os.path.join("outputs", "temps_" + fname))
369
- plt.close()
374
+ fig = _plotext_figure()
375
+ fig.draw(fig.bar(streams, temp_values, orientation="vertical"))
376
+ fig.title(title or "Stream Temperatures (Steady State)")
377
+ fig.show()
378
+ fig.clear()
370
379
 
371
380
  comps = set()
372
- for s in results.values():
373
- comps.update(s.get("z", {}).keys())
381
+ for s in streams:
382
+ z = results[s].get("z")
383
+ if isinstance(z, dict):
384
+ comps.update(z.keys())
374
385
  comps = sorted(comps)
386
+ if not comps:
387
+ return
375
388
 
376
- bottom = [0.0] * len(streams)
377
- plt.figure(figsize=(8, 4))
389
+ values = []
378
390
  for comp in comps:
379
- vals = [
391
+ values.append([
380
392
  _scalar_from_sequence(results[s].get("z", {}).get(comp, 0.0)) or 0.0
381
393
  for s in streams
382
- ]
383
- plt.bar(streams, vals, bottom=bottom, label=comp)
384
- bottom = [bottom[i] + vals[i] for i in range(len(vals))]
385
- plt.ylabel("Mole Fraction")
386
- plt.title("Stream Compositions (Steady State)")
387
- plt.legend()
388
- plt.tight_layout()
389
- plt.savefig(os.path.join("outputs", "comps_" + fname))
390
- plt.close()
391
-
392
-
393
- def plot_timeseries(results, fname="timeseries.png"):
394
- os.makedirs("outputs", exist_ok=True)
395
- streams = sorted(results.keys())
394
+ ])
395
+
396
+ fig = _plotext_figure()
397
+ fig.draw(fig.bar(streams, values, orientation="vertical", stacked=True))
398
+ fig.title(title or "Stream Compositions (Steady State)")
399
+ fig.show()
400
+ fig.clear()
401
+
402
+
403
+ def plot_timeseries_terminal(results, title=""):
404
+ """Render dynamic stream results as terminal line plots."""
405
+ streams = sorted(k for k, v in results.items() if isinstance(v, dict))
396
406
  if not streams:
397
407
  return
398
408
 
@@ -400,17 +410,13 @@ def plot_timeseries(results, fname="timeseries.png"):
400
410
  if not times:
401
411
  return
402
412
 
403
- plt.figure(figsize=(8, 5))
413
+ fig = _plotext_figure()
404
414
  for s_name in streams:
405
415
  if "T" in results[s_name]:
406
- plt.plot(times, results[s_name]["T"], label=s_name)
407
- plt.xlabel("Time [s]")
408
- plt.ylabel("Temperature [K]")
409
- plt.title("Stream Temperatures vs Time")
410
- plt.legend()
411
- plt.tight_layout()
412
- plt.savefig(os.path.join("outputs", "temps_" + fname))
413
- plt.close()
416
+ fig.draw(fig.signal(times, results[s_name]["T"]).label(s_name))
417
+ fig.title(title or "Stream Temperatures vs Time")
418
+ fig.show()
419
+ fig.clear()
414
420
 
415
421
  comps = set()
416
422
  for s_data in results.values():
@@ -421,17 +427,48 @@ def plot_timeseries(results, fname="timeseries.png"):
421
427
  for s_name in streams:
422
428
  if "z" not in results[s_name]:
423
429
  continue
424
- plt.figure(figsize=(8, 5))
430
+ fig = _plotext_figure()
425
431
  for comp in comps:
426
432
  if comp in results[s_name]["z"]:
427
- plt.plot(times, results[s_name]["z"][comp], label=comp)
428
- plt.xlabel("Time [s]")
429
- plt.ylabel("Mole Fraction")
430
- plt.title(f"Compositions vs Time ({s_name})")
431
- plt.legend()
432
- plt.tight_layout()
433
- plt.savefig(os.path.join("outputs", f"comps_{s_name}_" + fname))
434
- plt.close()
433
+ fig.draw(fig.signal(times, results[s_name]["z"][comp]).label(comp))
434
+ fig.title(f"Compositions vs Time ({s_name})")
435
+ fig.show()
436
+ fig.clear()
437
+
438
+
439
+ def plot_zarr_summary_terminal(summary: dict, title: str = "") -> None:
440
+ """Render a terminal visualization from a Zarr summary dict."""
441
+ if not summary.get("present"):
442
+ return
443
+
444
+ mode = summary.get("mode", "steady")
445
+ streams = summary.get("streams", {})
446
+
447
+ if mode == "dynamic":
448
+ # Reconstruct a results-like dict from Zarr summary for plotting.
449
+ results: dict = {}
450
+ for s_name, sdata in streams.items():
451
+ fields = sdata.get("fields", {})
452
+ results[s_name] = {k: v.get("value") for k, v in fields.items()}
453
+ plot_timeseries_terminal(results, title=title)
454
+ else:
455
+ # Steady: show final timestep values.
456
+ results = {}
457
+ for s_name, sdata in streams.items():
458
+ fields = sdata.get("fields", {})
459
+ results[s_name] = {
460
+ k: _scalar_from_sequence(v.get("value"))
461
+ for k, v in fields.items()
462
+ }
463
+ plot_results_terminal(results, title=title)
464
+
465
+
466
+ def plot_results_to_terminal(results, title: str = "", mode: str = "steady") -> None:
467
+ """Dispatch to the appropriate terminal plotter for run results."""
468
+ if mode == "dynamic":
469
+ plot_timeseries_terminal(results, title=title)
470
+ else:
471
+ plot_results_terminal(results, title=title)
435
472
 
436
473
 
437
474
  def _convert_value(value):