process-bigraph 1.8.4__tar.gz → 1.9.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.
Files changed (81) hide show
  1. {process_bigraph-1.8.4/process_bigraph.egg-info → process_bigraph-1.9.0}/PKG-INFO +7 -4
  2. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/README.md +4 -2
  3. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/__init__.py +17 -1
  4. process_bigraph-1.9.0/process_bigraph/audit_contracts.py +128 -0
  5. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/composite.py +341 -83
  6. process_bigraph-1.9.0/process_bigraph/composite_audit.py +193 -0
  7. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/composite_generator.py +15 -0
  8. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/composite_spec.py +77 -0
  9. process_bigraph-1.9.0/process_bigraph/contract_drift.py +253 -0
  10. process_bigraph-1.9.0/process_bigraph/contract_strict.py +176 -0
  11. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/emitter.py +10 -0
  12. process_bigraph-1.9.0/process_bigraph/events.py +859 -0
  13. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/nextflow.py +23 -1
  14. process_bigraph-1.9.0/process_bigraph/nextflow_deploy.py +430 -0
  15. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/ray.py +24 -3
  16. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/run_composite.py +74 -3
  17. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/run_step.py +57 -1
  18. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/scheduling.py +85 -0
  19. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/types/process.py +32 -4
  20. {process_bigraph-1.8.4 → process_bigraph-1.9.0/process_bigraph.egg-info}/PKG-INFO +7 -4
  21. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph.egg-info/SOURCES.txt +7 -0
  22. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph.egg-info/requires.txt +2 -1
  23. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/pyproject.toml +8 -2
  24. process_bigraph-1.9.0/tests/test_composite_generator_analyses.py +14 -0
  25. process_bigraph-1.9.0/tests/test_multirate_scheduling.py +70 -0
  26. process_bigraph-1.8.4/process_bigraph/nextflow_deploy.py +0 -140
  27. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/AUTHORS.md +0 -0
  28. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/LICENSE +0 -0
  29. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/artifacts.py +0 -0
  30. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/bundle.py +0 -0
  31. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/composite_discovery.py +0 -0
  32. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/config_helpers.py +0 -0
  33. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/core_introspection.py +0 -0
  34. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/draft_process.py +0 -0
  35. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/experiments/__init__.py +0 -0
  36. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/experiments/minimal_gillespie.py +0 -0
  37. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/plumbing.py +0 -0
  38. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/processes/__init__.py +0 -0
  39. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/processes/bigraphical_reactive_system.py +0 -0
  40. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/processes/cached.py +0 -0
  41. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/processes/dynamic_structure.py +0 -0
  42. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/processes/examples.py +0 -0
  43. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/processes/growth_division.py +0 -0
  44. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/processes/parameter_scan.py +0 -0
  45. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/processes/reaction.py +0 -0
  46. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/processes/simulation.py +0 -0
  47. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/__init__.py +0 -0
  48. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/_git_worker.py +0 -0
  49. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/clusters/__init__.py +0 -0
  50. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/clusters/ec2_ssm.py +0 -0
  51. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/git.py +0 -0
  52. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/parallel.py +0 -0
  53. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/pool.py +0 -0
  54. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/rest.py +0 -0
  55. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/protocols/session.py +0 -0
  56. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/run.py +0 -0
  57. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/server/__init__.py +0 -0
  58. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/server/rest.py +0 -0
  59. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/server/start.py +0 -0
  60. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/templates.py +0 -0
  61. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/types/__init__.py +0 -0
  62. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/visualization.py +0 -0
  63. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/visualizations/__init__.py +0 -0
  64. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/visualizations/distribution.py +0 -0
  65. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/visualizations/heatmap.py +0 -0
  66. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/visualizations/param_vs_observable.py +0 -0
  67. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/visualizations/phase_space.py +0 -0
  68. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/visualizations/time_series.py +0 -0
  69. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/visualizations/timeseries_from_observables.py +0 -0
  70. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/wiring_translator.py +0 -0
  71. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/workflow/__init__.py +0 -0
  72. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/workflow/backend.py +0 -0
  73. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/workflow/provision.py +0 -0
  74. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/workflow/recipe.py +0 -0
  75. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph/workflow/tasks.py +0 -0
  76. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph.egg-info/dependency_links.txt +0 -0
  77. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/process_bigraph.egg-info/top_level.txt +0 -0
  78. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/setup.cfg +0 -0
  79. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/tests/test_process_decorator.py +0 -0
  80. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/tests/test_reaction_step.py +0 -0
  81. {process_bigraph-1.8.4 → process_bigraph-1.9.0}/tests/test_units.py +0 -0
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: process-bigraph
3
- Version: 1.8.4
3
+ Version: 1.9.0
4
4
  Summary: protocol and execution for compositional systems biology
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
7
7
  License-File: LICENSE
8
8
  License-File: AUTHORS.md
9
- Requires-Dist: bigraph-schema>=1.6.0
9
+ Requires-Dist: bigraph-schema>=1.8.1
10
+ Requires-Dist: requests>=2.31
10
11
  Requires-Dist: matplotlib
11
12
  Requires-Dist: pint>=0.24.4
12
13
  Requires-Dist: scipy>=1.8
@@ -118,7 +119,8 @@ core.register_link('Grow', Grow) # register it in the local
118
119
  composite = Composite({'state': {
119
120
  'level': 1.0, # a shared store
120
121
  'grow': {'_type': 'process', 'address': 'local:Grow', 'config': {'rate': 0.5},
121
- 'interval': 1.0, 'inputs': {'level': ['level']}, 'outputs': {'level': ['level']}},
122
+ 'interval': 1.0, # seconds; a unit string like '1 min' also works
123
+ 'inputs': {'level': ['level']}, 'outputs': {'level': ['level']}},
122
124
  'emitter': emitter_from_wires({'level': ['level'], 'time': ['global_time']}),
123
125
  }}, core=core)
124
126
  composite.run(5.0)
@@ -233,7 +235,8 @@ rendered to HTML and published automatically on GitHub Pages.
233
235
 
234
236
  - **Tutorial 3 — Declarative Math**
235
237
  *Defining mathematical relationships, signal pipelines, and events using `MathExpressionStep`*
236
- https://vivarium-collective.github.io/process-bigraph/notebooks/tutorial_3.html
238
+ https://vivarium-collective.github.io/process-bigraph/notebooks/tutorial_3.html
239
+ Requires the companion package [`viva-basic-processes`](https://github.com/vivarium-collective/viva-basic-processes), published to PyPI as `pbg-basic-processes` (`pip install "pbg-basic-processes[plotting]>=0.3.0"`), which provides `MathExpressionStep`, the `Tick` process, and the plotting helpers.
237
240
 
238
241
  - **Tutorial 4 — Composing a Biological Model**
239
242
  *The central dogma from four small processes: composition over shared molecular state, biological units in the port types, and adding regulation by adding a wire*
@@ -92,7 +92,8 @@ core.register_link('Grow', Grow) # register it in the local
92
92
  composite = Composite({'state': {
93
93
  'level': 1.0, # a shared store
94
94
  'grow': {'_type': 'process', 'address': 'local:Grow', 'config': {'rate': 0.5},
95
- 'interval': 1.0, 'inputs': {'level': ['level']}, 'outputs': {'level': ['level']}},
95
+ 'interval': 1.0, # seconds; a unit string like '1 min' also works
96
+ 'inputs': {'level': ['level']}, 'outputs': {'level': ['level']}},
96
97
  'emitter': emitter_from_wires({'level': ['level'], 'time': ['global_time']}),
97
98
  }}, core=core)
98
99
  composite.run(5.0)
@@ -207,7 +208,8 @@ rendered to HTML and published automatically on GitHub Pages.
207
208
 
208
209
  - **Tutorial 3 — Declarative Math**
209
210
  *Defining mathematical relationships, signal pipelines, and events using `MathExpressionStep`*
210
- https://vivarium-collective.github.io/process-bigraph/notebooks/tutorial_3.html
211
+ https://vivarium-collective.github.io/process-bigraph/notebooks/tutorial_3.html
212
+ Requires the companion package [`viva-basic-processes`](https://github.com/vivarium-collective/viva-basic-processes), published to PyPI as `pbg-basic-processes` (`pip install "pbg-basic-processes[plotting]>=0.3.0"`), which provides `MathExpressionStep`, the `Tick` process, and the plotting helpers.
211
213
 
212
214
  - **Tutorial 4 — Composing a Biological Model**
213
215
  *The central dogma from four small processes: composition over shared molecular state, biological units in the port types, and adding regulation by adding a wire*
@@ -1,4 +1,20 @@
1
- from bigraph_schema import allocate_core # noqa: F401
1
+ from bigraph_schema import allocate_core as _allocate_core
2
+
3
+
4
+ def allocate_core(*args, strict=False, **kwargs):
5
+ """Allocate a core (see :func:`bigraph_schema.allocate_core`).
6
+
7
+ Adds process-bigraph's opt-in strict-config mode (issue #232): with
8
+ ``strict=True`` the returned core carries ``strict_config = True``, so
9
+ instantiating a Process/Step with a config key that is not declared in
10
+ its ``config_schema`` raises a clear error instead of silently ignoring
11
+ the key. The default (``strict=False``) preserves existing behavior
12
+ exactly. You can also toggle it on an existing core with
13
+ ``core.strict_config = True``.
14
+ """
15
+ core = _allocate_core(*args, **kwargs)
16
+ core.strict_config = bool(strict)
17
+ return core
2
18
 
3
19
  # The installed distribution's version, exposed so a run manifest can record
4
20
  # *which* engine produced an artifact. Read from installed metadata rather
@@ -0,0 +1,128 @@
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())