process-bigraph 1.11.0__tar.gz → 1.11.2__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 (85) hide show
  1. {process_bigraph-1.11.0/process_bigraph.egg-info → process_bigraph-1.11.2}/PKG-INFO +3 -5
  2. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/__init__.py +0 -1
  3. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/composite.py +30 -35
  4. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/holes.py +8 -53
  5. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/scheduling.py +26 -4
  6. {process_bigraph-1.11.0 → process_bigraph-1.11.2/process_bigraph.egg-info}/PKG-INFO +3 -5
  7. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph.egg-info/SOURCES.txt +0 -4
  8. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph.egg-info/requires.txt +3 -4
  9. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/pyproject.toml +17 -5
  10. process_bigraph-1.11.0/process_bigraph/audit_contracts.py +0 -128
  11. process_bigraph-1.11.0/process_bigraph/composite_audit.py +0 -193
  12. process_bigraph-1.11.0/process_bigraph/contract_drift.py +0 -253
  13. process_bigraph-1.11.0/process_bigraph/contract_strict.py +0 -176
  14. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/AUTHORS.md +0 -0
  15. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/LICENSE +0 -0
  16. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/README.md +0 -0
  17. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/artifacts.py +0 -0
  18. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/bundle.py +0 -0
  19. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/composite_discovery.py +0 -0
  20. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/composite_generator.py +0 -0
  21. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/composite_spec.py +0 -0
  22. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/config_helpers.py +0 -0
  23. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/core_introspection.py +0 -0
  24. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/draft_process.py +0 -0
  25. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/emitter.py +0 -0
  26. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/events.py +0 -0
  27. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/experiments/__init__.py +0 -0
  28. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/experiments/minimal_gillespie.py +0 -0
  29. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/nextflow.py +0 -0
  30. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/nextflow_deploy.py +0 -0
  31. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/orchestration.py +0 -0
  32. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/plumbing.py +0 -0
  33. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/processes/__init__.py +0 -0
  34. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/processes/bigraphical_reactive_system.py +0 -0
  35. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/processes/cached.py +0 -0
  36. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/processes/dynamic_structure.py +0 -0
  37. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/processes/examples.py +0 -0
  38. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/processes/growth_division.py +0 -0
  39. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/processes/parameter_scan.py +0 -0
  40. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/processes/reaction.py +0 -0
  41. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/processes/simulation.py +0 -0
  42. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/__init__.py +0 -0
  43. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/_git_worker.py +0 -0
  44. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/clusters/__init__.py +0 -0
  45. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/clusters/ec2_ssm.py +0 -0
  46. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/git.py +0 -0
  47. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/parallel.py +0 -0
  48. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/pool.py +0 -0
  49. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/ray.py +0 -0
  50. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/rest.py +0 -0
  51. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/protocols/session.py +0 -0
  52. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/run_composite.py +0 -0
  53. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/run_step.py +0 -0
  54. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/server/__init__.py +0 -0
  55. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/server/rest.py +0 -0
  56. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/server/start.py +0 -0
  57. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/templates.py +0 -0
  58. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/types/__init__.py +0 -0
  59. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/types/process.py +0 -0
  60. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/visualization.py +0 -0
  61. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/visualizations/__init__.py +0 -0
  62. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/visualizations/distribution.py +0 -0
  63. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/visualizations/heatmap.py +0 -0
  64. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/visualizations/param_vs_observable.py +0 -0
  65. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/visualizations/phase_space.py +0 -0
  66. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/visualizations/time_series.py +0 -0
  67. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/visualizations/timeseries_from_observables.py +0 -0
  68. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/wiring_translator.py +0 -0
  69. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/workflow/__init__.py +0 -0
  70. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/workflow/backend.py +0 -0
  71. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/workflow/provision.py +0 -0
  72. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/workflow/recipe.py +0 -0
  73. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph/workflow/tasks.py +0 -0
  74. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph.egg-info/dependency_links.txt +0 -0
  75. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/process_bigraph.egg-info/top_level.txt +0 -0
  76. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/setup.cfg +0 -0
  77. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/tests/test_composite_generator_analyses.py +0 -0
  78. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/tests/test_global_time_precision_default.py +0 -0
  79. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/tests/test_heap_scheduler.py +0 -0
  80. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/tests/test_initial_state_precedence.py +0 -0
  81. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/tests/test_multirate_scheduling.py +0 -0
  82. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/tests/test_process_decorator.py +0 -0
  83. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/tests/test_reaction_step.py +0 -0
  84. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/tests/test_units.py +0 -0
  85. {process_bigraph-1.11.0 → process_bigraph-1.11.2}/tests/test_wire_step_layers_root_trigger.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: process-bigraph
3
- Version: 1.11.0
3
+ Version: 1.11.2
4
4
  Summary: protocol and execution for compositional systems biology
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -8,11 +8,9 @@ License-File: LICENSE
8
8
  License-File: AUTHORS.md
9
9
  Requires-Dist: bigraph-schema>=1.8.1
10
10
  Requires-Dist: requests>=2.31
11
- Requires-Dist: matplotlib
12
11
  Requires-Dist: pint>=0.24.4
13
- Requires-Dist: scipy>=1.8
14
- Requires-Dist: pandas
15
- Requires-Dist: sympy
12
+ Provides-Extra: viz
13
+ Requires-Dist: matplotlib; extra == "viz"
16
14
  Provides-Extra: ray
17
15
  Requires-Dist: ray>=2.10; extra == "ray"
18
16
  Provides-Extra: server-rest
@@ -79,7 +79,6 @@ from process_bigraph.holes import UnfilledHoleError # noqa: F401
79
79
  from process_bigraph.templates import ( # noqa: F401
80
80
  open_sites, required_open_sites, is_ground_document, fill_template, template_document,
81
81
  )
82
- from bigraph_schema.matching import find_candidates # noqa: F401
83
82
  from process_bigraph.emitter import Emitter, gather_emitter_results, generate_emitter_state # noqa: F401
84
83
  from process_bigraph.types import StepLink, ProcessLink, CompositeLink # noqa: F401
85
84
  from process_bigraph import core_introspection # noqa: F401
@@ -15,6 +15,7 @@ Used as part of the Vivarium 2.0 ecosystem for modular biological modeling.
15
15
  import os
16
16
  import json
17
17
  import math
18
+ import warnings
18
19
  import heapq
19
20
  import inspect
20
21
  import time as _time
@@ -1255,17 +1256,6 @@ def _project_process_update(update_results: Any, args: Tuple[Any, str, Any]) ->
1255
1256
  to the previous per-call closure.
1256
1257
  """
1257
1258
  composite, ports_key, process_path = args
1258
- strict = getattr(composite, '_contract_strict', 'off')
1259
- if strict != 'off':
1260
- # v1: only a dict delta is post-checked; list-form (multi-update) is left unchecked.
1261
- compiled = composite._compiled_contracts.get(process_path)
1262
- if compiled is not None and isinstance(update_results, dict):
1263
- from process_bigraph.contract_strict import check_post, handle_violations
1264
- inputs = composite._cached_view(process_path)
1265
- fails = check_post(compiled, inputs, update_results)
1266
- handle_violations(fails, mode=strict, phase='post', path=process_path,
1267
- cls='process', emitter=composite._em,
1268
- global_time=composite.state.get('global_time', 0.0) if isinstance(composite.state, dict) else 0.0)
1269
1259
  if not isinstance(update_results, list):
1270
1260
  update_results = [update_results]
1271
1261
  return [
@@ -1324,6 +1314,14 @@ class Composite(Process):
1324
1314
  },
1325
1315
  'global_time_precision': 'maybe[float]',
1326
1316
  'run_steps_on_init': 'boolean{false}',
1317
+ # Non-deterministic step-cycle policy (issue #30): 'raise' (default) |
1318
+ # 'warn'. A zero-time step cycle whose members share a priority has no
1319
+ # priority-fixed order, so building rejects it by default (issue #233).
1320
+ # 'warn' opts into a warning and builds anyway, for a document whose
1321
+ # wiring forms such a cycle and whose author accepts the scheduler's
1322
+ # fallback ordering. Unset here, the PROCESS_BIGRAPH_CYCLE_POLICY env
1323
+ # var is consulted; otherwise 'raise'.
1324
+ 'cycle_policy': 'maybe[string]',
1327
1325
  # Inner-layer parallelism: when True, run_steps fans out the
1328
1326
  # steps in each layer across a ThreadPoolExecutor. Threads
1329
1327
  # share memory and don't trigger the daemon-process restriction,
@@ -1333,8 +1331,6 @@ class Composite(Process):
1333
1331
  # step hot path releases the GIL (numpy / scipy / numba / C
1334
1332
  # extensions: yes; pure-Python loops: no).
1335
1333
  'parallel_steps': 'boolean{false}',
1336
- # Runtime contract checking: off (default, zero-cost) | record | raise.
1337
- 'contract_strict': 'string{off}',
1338
1334
  'orchestration': 'string{temporal}',
1339
1335
  # Time-scheduled processes: when True, the per-tick `run` loop
1340
1336
  # fans out invocations across a thread pool. Right tool when
@@ -1603,8 +1599,6 @@ class Composite(Process):
1603
1599
  # field in interface_schema for the rationale (threading vs.
1604
1600
  # multiprocessing for inner parallelism).
1605
1601
  self._parallel_steps = bool(self.config.get('parallel_steps', False))
1606
- self._contract_strict = self.config.get('contract_strict') or getattr(self.core, 'contract_strict', 'off')
1607
- self._compiled_contracts = {}
1608
1602
  self._parallel_processes = bool(self.config.get('parallel_processes', False))
1609
1603
  self._parallel_workers = self.config.get('parallel_workers')
1610
1604
  self._step_executor = None # lazy: created on first run_steps need
@@ -2106,27 +2100,16 @@ class Composite(Process):
2106
2100
  path for any path not present.
2107
2101
  """
2108
2102
  self._compiled_links = {}
2109
- self._compiled_contracts = {}
2110
2103
 
2111
2104
  for path in list(self.process_paths) + list(self.step_paths):
2112
2105
  compiled = self.core.precompile_link(
2113
2106
  self.schema, self.state, path)
2114
2107
  if compiled is not None:
2115
2108
  self._compiled_links[path] = compiled
2116
- if self._contract_strict != 'off':
2117
- try:
2118
- from process_bigraph.contract_strict import compile_contract
2119
- node = self.state
2120
- for key in path:
2121
- node = node[key]
2122
- self._compiled_contracts[path] = compile_contract(node['instance'].describe_contract())
2123
- except Exception: # noqa: BLE001 - a process without a readable contract is simply unchecked
2124
- self._compiled_contracts[path] = None
2125
2109
 
2126
2110
  def _invalidate_caches(self) -> None:
2127
2111
  """Invalidate precompiled link caches, forcing rebuild on next use."""
2128
2112
  self._compiled_links = {}
2129
- self._compiled_contracts = {}
2130
2113
  self._runtime_partition_cache = None
2131
2114
 
2132
2115
  def _cached_view(self, path: Tuple[str, ...]) -> Dict[str, Any]:
@@ -2530,7 +2513,7 @@ class Composite(Process):
2530
2513
  return '/'.join(str(part) for part in step_key)
2531
2514
  return str(step_key)
2532
2515
  rendered = ' -> '.join(_name(step_key) for step_key in cycle)
2533
- raise ValueError(
2516
+ message = (
2534
2517
  f'non-deterministic step dependency cycle detected: '
2535
2518
  f'{rendered}. These steps form a zero-time feedback cycle AND '
2536
2519
  f'share a priority, so their evaluation order would depend on '
@@ -2541,6 +2524,26 @@ class Composite(Process):
2541
2524
  f'deterministically), removing one of the mutual input/output '
2542
2525
  f'wirings, or modelling the feedback as a Process with a '
2543
2526
  f'non-zero time interval.')
2527
+ # Issue #30: an author who accepts such a cycle can opt into a
2528
+ # warning instead of the raise. Resolution: the Composite's own
2529
+ # ``config['cycle_policy']`` wins; otherwise the
2530
+ # ``PROCESS_BIGRAPH_CYCLE_POLICY`` env var; otherwise ``'raise'``.
2531
+ # Anything but an explicit ``'warn'`` fails CLOSED (raises), so a
2532
+ # typo never silently drops the guard. In warn mode the cycle is
2533
+ # ordered by ``determine_steps``' priority/``repr`` fallback, which
2534
+ # is deterministic across processes (#284) but arbitrary — distinct
2535
+ # priorities still give a meaningful order.
2536
+ policy = (self.config.get('cycle_policy')
2537
+ or os.environ.get('PROCESS_BIGRAPH_CYCLE_POLICY')
2538
+ or 'raise')
2539
+ if str(policy).strip().lower() == 'warn':
2540
+ warnings.warn(
2541
+ message + ' Proceeding because cycle_policy="warn": the '
2542
+ 'scheduler orders this cycle deterministically but '
2543
+ 'arbitrarily.',
2544
+ stacklevel=2)
2545
+ else:
2546
+ raise ValueError(message)
2544
2547
 
2545
2548
  # Initialize trigger fulfillment state and steps remaining
2546
2549
  self.reset_step_state(self.step_paths)
@@ -3583,14 +3586,6 @@ class Composite(Process):
3583
3586
  # summary of the state it was handed (process_bigraph.events), then
3584
3587
  # re-raise the ORIGINAL exception unchanged -- callers may classify
3585
3588
  # control-flow exceptions by type, so the type must propagate as is.
3586
- if self._contract_strict != 'off':
3587
- compiled = self._compiled_contracts.get(path)
3588
- if compiled is not None:
3589
- from process_bigraph.contract_strict import check_pre, handle_violations
3590
- fails = check_pre(compiled, clean_state)
3591
- handle_violations(fails, mode=self._contract_strict, phase='pre', path=path,
3592
- cls=type(process['instance']).__name__, emitter=self._em,
3593
- global_time=self.state.get('global_time', 0.0) if isinstance(self.state, dict) else 0.0)
3594
3589
  t0 = _time.monotonic()
3595
3590
  try:
3596
3591
  update = process['instance'].invoke(clean_state, interval)
@@ -4,32 +4,23 @@ A *draft* in this framework is a process-slot left as an open **hole** — a
4
4
  ``Site`` whose ``_sort`` is a :class:`~bigraph_schema.contract.ProcessContract`.
5
5
  ``Composite`` refuses to build while a required hole is open; instead of the
6
6
  opaque ``KeyError: 'data'`` an unfilled address site used to raise, it raises an
7
- :class:`UnfilledHoleError` that names, per hole, its path, the contract it
8
- requires (typed face + conditions), and the registered processes that would fill
9
- it (:func:`~bigraph_schema.matching.find_candidates`).
10
-
11
- The report is best-effort on candidates: ``find_candidates`` reads a process's
12
- contract by instantiating it with empty config and skips any that need real
13
- config, so the candidate list may be empty — the guaranteed content is the hole
14
- path and its required contract. A candidate-finder failure never masks the
15
- primary "not ground" error.
7
+ :class:`UnfilledHoleError` that names, per hole, its path and the contract it
8
+ requires (typed face + conditions).
16
9
  """
17
10
  from __future__ import annotations
18
11
 
19
- from dataclasses import dataclass, field
12
+ from dataclasses import dataclass
20
13
  from typing import Any, List, Optional, Sequence, Tuple
21
14
 
22
15
  from bigraph_schema.assembly import contract_of
23
- from bigraph_schema.matching import find_candidates
24
16
 
25
17
 
26
18
  @dataclass
27
19
  class HoleReport:
28
- """One unfilled hole: where it is, what it requires, and what fills it."""
20
+ """One unfilled hole: where it is and what contract it requires."""
29
21
 
30
22
  path: Tuple[str, ...]
31
23
  contract: Optional[Any] = None # ProcessContract | None
32
- candidates: List[Any] = field(default_factory=list) # [CandidateMatch]
33
24
 
34
25
 
35
26
  class UnfilledHoleError(ValueError):
@@ -58,7 +49,6 @@ class UnfilledHoleError(ValueError):
58
49
  lines.append("")
59
50
  lines.append(f" • {'/'.join(hole.path)}")
60
51
  lines.extend(_render_requires(hole.contract, self._core))
61
- lines.extend(_render_candidates(hole.candidates))
62
52
  return "\n".join(lines)
63
53
 
64
54
 
@@ -67,16 +57,14 @@ def build_unfilled_hole_error(
67
57
  ) -> UnfilledHoleError:
68
58
  """Build an :class:`UnfilledHoleError` from ``(path, site)`` pairs.
69
59
 
70
- For each hole, resolve the contract it requires (``contract_of``) and the
71
- admissible candidates (``find_candidates``). Both are wrapped so a failure in
72
- either never masks the primary "not ground" report; an unsorted hole simply
73
- reports no contract and no candidates.
60
+ For each hole, resolve the contract it requires (``contract_of``), wrapped so
61
+ a failure never masks the primary "not ground" report; an unsorted hole simply
62
+ reports no contract.
74
63
  """
75
64
  reports = []
76
65
  for path, site in unfilled_sites:
77
66
  contract = _safe_contract_of(core, site)
78
- candidates = _safe_candidates(core, site) if contract is not None else []
79
- reports.append(HoleReport(tuple(path), contract, candidates))
67
+ reports.append(HoleReport(tuple(path), contract))
80
68
  return UnfilledHoleError(reports, core=core)
81
69
 
82
70
 
@@ -87,13 +75,6 @@ def _safe_contract_of(core, site):
87
75
  return None
88
76
 
89
77
 
90
- def _safe_candidates(core, site):
91
- try:
92
- return list(find_candidates(core, site) or [])
93
- except Exception: # noqa: BLE001 - candidate-finding never masks the primary error
94
- return []
95
-
96
-
97
78
  def _render_requires(contract, core=None) -> List[str]:
98
79
  if contract is None:
99
80
  return [" requires: no contract declared (unsorted hole)"]
@@ -140,29 +121,3 @@ def _fmt_port(schema, core=None) -> str:
140
121
  except Exception: # noqa: BLE001 - fall back to the class name, never a repr
141
122
  pass
142
123
  return type(schema).__name__.lower()
143
-
144
-
145
- def _render_candidates(candidates) -> List[str]:
146
- if not candidates:
147
- return [" candidates: (no admissible registered process found)"]
148
- lines = [" candidates:"]
149
- for candidate in candidates:
150
- if getattr(candidate, "match", None) == "full":
151
- lines.append(f" ✓ {candidate.address} (full match)")
152
- else:
153
- why = _fmt_fails(getattr(candidate, "fails", []) or [])
154
- lines.append(f" ~ {candidate.address} (partial: {why})")
155
- return lines
156
-
157
-
158
- def _fmt_fails(fails) -> str:
159
- """The failing conditions of a near-miss, by name — never a raw dict dump."""
160
- if not fails:
161
- return "near-miss"
162
- parts = []
163
- for fail in fails:
164
- if isinstance(fail, dict):
165
- parts.append(str(fail.get("condition", fail.get("detail", fail))))
166
- else:
167
- parts.append(str(fail))
168
- return "; ".join(parts)
@@ -905,10 +905,17 @@ def determine_steps(steps, remaining, fulfilled):
905
905
  # All remaining steps are in cycles — pick the highest priority one.
906
906
  # This avoids expensive cycle detection for densely connected graphs.
907
907
  if remaining:
908
- priority = max(
909
- remaining,
910
- key=lambda path: steps[path]['priority'])
911
- to_run = [priority]
908
+ # #284: break an equal-priority tie DETERMINISTICALLY (highest
909
+ # priority, then the repr-smallest path) rather than letting ``max``
910
+ # return whichever the set happened to iterate first — that tie fell
911
+ # to Python's hash seed and let an acyclic network run in a different
912
+ # order per process. Matches ``find_step_cycle``'s own ``key=repr``
913
+ # stable ordering.
914
+ best = max(steps[path]['priority'] for path in remaining)
915
+ chosen = min(
916
+ (path for path in remaining if steps[path]['priority'] == best),
917
+ key=repr)
918
+ to_run = [chosen]
912
919
  else:
913
920
  return to_run, remaining, fulfilled
914
921
 
@@ -922,5 +929,20 @@ def determine_steps(steps, remaining, fulfilled):
922
929
  for explode in exploded_path:
923
930
  if step_path in fulfilled.get(explode, set()):
924
931
  fulfilled[explode].remove(step_path)
932
+ # #284: a whole-container write (a map / node written whole)
933
+ # produces the data leaves beneath it, so release this step from
934
+ # every trigger path AT OR BELOW the output too — not only the
935
+ # prefixes ``explode_path`` walks. ``build_step_network``'s second
936
+ # pass added this step as a producer of those descendant leaves
937
+ # (``nodes[leaf]['before']``); without clearing them a Step that
938
+ # reads one key stays blocked after the writer has run, and the
939
+ # stuck readers fall through to the (now deterministic, but still
940
+ # arbitrary) cycle fallback instead of running in dependency order.
941
+ out_t = tuple(output)
942
+ n = len(out_t)
943
+ for key in list(fulfilled):
944
+ if (len(key) > n and tuple(key[:n]) == out_t
945
+ and step_path in fulfilled[key]):
946
+ fulfilled[key].remove(step_path)
925
947
 
926
948
  return to_run, remaining, fulfilled
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: process-bigraph
3
- Version: 1.11.0
3
+ Version: 1.11.2
4
4
  Summary: protocol and execution for compositional systems biology
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -8,11 +8,9 @@ License-File: LICENSE
8
8
  License-File: AUTHORS.md
9
9
  Requires-Dist: bigraph-schema>=1.8.1
10
10
  Requires-Dist: requests>=2.31
11
- Requires-Dist: matplotlib
12
11
  Requires-Dist: pint>=0.24.4
13
- Requires-Dist: scipy>=1.8
14
- Requires-Dist: pandas
15
- Requires-Dist: sympy
12
+ Provides-Extra: viz
13
+ Requires-Dist: matplotlib; extra == "viz"
16
14
  Provides-Extra: ray
17
15
  Requires-Dist: ray>=2.10; extra == "ray"
18
16
  Provides-Extra: server-rest
@@ -4,16 +4,12 @@ README.md
4
4
  pyproject.toml
5
5
  process_bigraph/__init__.py
6
6
  process_bigraph/artifacts.py
7
- process_bigraph/audit_contracts.py
8
7
  process_bigraph/bundle.py
9
8
  process_bigraph/composite.py
10
- process_bigraph/composite_audit.py
11
9
  process_bigraph/composite_discovery.py
12
10
  process_bigraph/composite_generator.py
13
11
  process_bigraph/composite_spec.py
14
12
  process_bigraph/config_helpers.py
15
- process_bigraph/contract_drift.py
16
- process_bigraph/contract_strict.py
17
13
  process_bigraph/core_introspection.py
18
14
  process_bigraph/draft_process.py
19
15
  process_bigraph/emitter.py
@@ -1,10 +1,6 @@
1
1
  bigraph-schema>=1.8.1
2
2
  requests>=2.31
3
- matplotlib
4
3
  pint>=0.24.4
5
- scipy>=1.8
6
- pandas
7
- sympy
8
4
 
9
5
  [ec2-ssm]
10
6
  boto3>=1.28
@@ -18,3 +14,6 @@ fastapi-utils>=0.8.0
18
14
  uvicorn>=0.35.0
19
15
  fire
20
16
  typing-inspect>=0.9.0
17
+
18
+ [viz]
19
+ matplotlib
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "process-bigraph"
7
- version = "1.11.0"
7
+ version = "1.11.2"
8
8
  description = "protocol and execution for compositional systems biology"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -22,14 +22,25 @@ dependencies = [
22
22
  # caller needs it, not only REST users. Undeclared, it was found missing
23
23
  # in a bare `pip install process-bigraph` image (viva-api, 2026-09-26).
24
24
  "requests>=2.31",
25
- "matplotlib",
26
25
  "pint>=0.24.4",
27
- "scipy>=1.8",
28
- "pandas",
29
- "sympy",
26
+ # matplotlib / scipy / pandas / sympy were previously hard runtime deps but
27
+ # are not imported by the package: scipy/pandas/sympy are unused entirely,
28
+ # and matplotlib is imported lazily only inside process_bigraph.visualization
29
+ # (render time). matplotlib now lives in the [viz] extra; the other three are
30
+ # dropped. This trims ~190 MB off a bare `pip install process-bigraph` and
31
+ # cascades to every downstream (the dashboard stack still gets scipy via
32
+ # discovery-engine and pandas via xarray; render needs process-bigraph[viz]).
30
33
  ]
31
34
 
32
35
  [project.optional-dependencies]
36
+ # Rendering/plotting for process_bigraph.visualization (Visualization step,
37
+ # render_results). matplotlib is imported lazily, so the package imports fine
38
+ # without it; only rendering needs this extra.
39
+ # Install with: pip install process-bigraph[viz]
40
+ viz = [
41
+ "matplotlib",
42
+ ]
43
+
33
44
  # Distributed Ray actor backend for processes (RayProcess + actor pool).
34
45
  # Install with: pip install process-bigraph[ray]
35
46
  ray = [
@@ -72,6 +83,7 @@ dev = [
72
83
  "pytest-cov",
73
84
  "httpx",
74
85
  # Test the optional extras without forcing them on everyone.
86
+ "matplotlib",
75
87
  "ray>=2.10",
76
88
  "fastapi>=0.116.1",
77
89
  "fastapi-utils>=0.8.0",
@@ -1,128 +0,0 @@
1
- """CI audit gate for declared process contracts (spec section 5).
2
-
3
- Audits every registered process's DECLARED contract (static — no instantiation)
4
- and fails (exit 1) on any error-severity finding, or on a declared-coverage
5
- floor. Read the class `.contract` directly (contract_of drops amendments). In
6
- process-bigraph's own CI few processes declare contracts, so the error-gate is
7
- largely a regression guard; the real value is downstream workspaces running
8
- `python -m process_bigraph.audit_contracts` against their registries, and the
9
- --require-declared floor makes coverage visible.
10
- """
11
- import argparse
12
- import json as _json
13
- import sys
14
-
15
- try:
16
- from bigraph_schema.contract_audit import audit_contract, completeness
17
- from bigraph_schema.assembly import contract_of
18
- from bigraph_schema.contract import resolve_contract
19
- AUDIT_AVAILABLE = True
20
- except Exception: # noqa: BLE001
21
- AUDIT_AVAILABLE = False
22
-
23
- from process_bigraph import allocate_core
24
-
25
- _INCOMPLETE_BELOW = 0.5
26
-
27
-
28
- def _class_key(cls):
29
- return f'{getattr(cls, "__module__", "?")}.{getattr(cls, "__qualname__", getattr(cls, "__name__", "?"))}'
30
-
31
-
32
- def _contract_for(core, address, cls):
33
- """Declared contract of a class, amendments preserved. Reads the class
34
- `.contract` first (contract_of drops amendments), then falls back."""
35
- declared = getattr(cls, 'contract', None)
36
- if declared is not None:
37
- try:
38
- return resolve_contract(cls) # normalizes ProcessContract/dict; never raises
39
- except Exception: # noqa: BLE001
40
- pass
41
- try:
42
- return contract_of(core, address)
43
- except Exception: # noqa: BLE001
44
- return None
45
-
46
-
47
- def audit_all(core, *, require_declared=0, strict_resolve=False):
48
- from process_bigraph.core_introspection import list_processes
49
- reports = {}
50
- for address in list_processes(core):
51
- try:
52
- cls = core.link_registry.get(address)
53
- except Exception: # noqa: BLE001 - per-entry import failure
54
- cls = None
55
- if cls is None:
56
- reports.setdefault(f'unresolvable:{address}',
57
- {'address': address, 'cls': address, 'status': 'unresolvable',
58
- 'grade': None, 'findings': [], 'declared': False})
59
- continue
60
- key = _class_key(cls)
61
- if key in reports:
62
- continue # alias dedup
63
- contract = _contract_for(core, address, cls)
64
- if contract is None:
65
- reports[key] = {'address': address, 'cls': key, 'status': 'not-declared', 'grade': None, 'findings': [], 'declared': False}
66
- continue
67
- try:
68
- report = audit_contract(core, contract)
69
- grade = completeness(contract)
70
- findings = [{'severity': f.severity, 'code': f.code, 'where': f.where, 'message': f.message}
71
- for f in report.findings]
72
- except Exception as error: # noqa: BLE001
73
- reports[key] = {'address': address, 'cls': key, 'status': 'unresolvable', 'grade': None,
74
- 'findings': [{'severity': 'error', 'code': 'audit_raised', 'where': key, 'message': str(error)}], 'declared': False}
75
- continue
76
- has_contract_attr = getattr(cls, 'contract', None) is not None
77
- is_declared = has_contract_attr or bool(contract.conditions())
78
- if any(f['severity'] == 'error' for f in findings):
79
- status = 'fail'
80
- elif not is_declared:
81
- status = 'not-declared'
82
- elif grade < _INCOMPLETE_BELOW:
83
- status = 'incomplete'
84
- else:
85
- status = 'pass'
86
- reports[key] = {'address': address, 'cls': key, 'status': status, 'grade': round(grade, 3), 'findings': findings, 'declared': is_declared}
87
-
88
- rows = list(reports.values())
89
- errors = sum(1 for r in rows for f in r['findings'] if f['severity'] == 'error')
90
- if strict_resolve:
91
- errors += sum(1 for r in rows if r['status'] == 'unresolvable')
92
- declared_count = sum(1 for r in rows if r.get('declared'))
93
- exit_code = 1 if (errors > 0 or (require_declared > 0 and declared_count < require_declared)) else 0
94
- return {'reports': rows, 'declared': declared_count, 'errors': errors, 'exit_code': exit_code}
95
-
96
-
97
- def _build_parser():
98
- p = argparse.ArgumentParser(prog='python -m process_bigraph.audit_contracts',
99
- description='Audit registered process contracts; exit 1 on any error finding.')
100
- p.add_argument('--require-declared', type=int, default=0, metavar='N',
101
- help='fail if fewer than N processes declare a real contract (default 0 = off).')
102
- p.add_argument('--strict-resolve', action='store_true', help='treat unresolvable processes as failures.')
103
- p.add_argument('--json', action='store_true', help='emit the full report as JSON.')
104
- return p
105
-
106
-
107
- def main(argv=None):
108
- args = _build_parser().parse_args(argv)
109
- if not AUDIT_AVAILABLE:
110
- print('contract audit unavailable: bigraph-schema >= 1.7.0 required', file=sys.stderr)
111
- return 2
112
- core = allocate_core()
113
- result = audit_all(core, require_declared=args.require_declared, strict_resolve=args.strict_resolve)
114
- if args.json:
115
- print(_json.dumps(result, indent=2))
116
- return result['exit_code']
117
- for r in sorted(result['reports'], key=lambda x: (x['status'] != 'fail', x['cls'])):
118
- grade = '' if r['grade'] is None else f" {int(r['grade'] * 100)}%"
119
- print(f"{r['status']:13} {r['cls']}{grade}")
120
- for f in r['findings']:
121
- print(f" {f['severity']} {f['code']} {f['where']}: {f['message']}")
122
- print(f"\n{result['declared']} declared, {result['errors']} error finding(s) "
123
- f"-> {'FAIL' if result['exit_code'] else 'OK'}")
124
- return result['exit_code']
125
-
126
-
127
- if __name__ == '__main__':
128
- sys.exit(main())