process-bigraph 1.7.1__tar.gz → 1.8.1__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.
- {process_bigraph-1.7.1/process_bigraph.egg-info → process_bigraph-1.8.1}/PKG-INFO +1 -1
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/__init__.py +8 -0
- process_bigraph-1.8.1/process_bigraph/composite_discovery.py +135 -0
- process_bigraph-1.8.1/process_bigraph/composite_generator.py +616 -0
- process_bigraph-1.8.1/process_bigraph/config_helpers.py +98 -0
- process_bigraph-1.8.1/process_bigraph/core_introspection.py +44 -0
- process_bigraph-1.8.1/process_bigraph/visualization.py +393 -0
- process_bigraph-1.8.1/process_bigraph/visualizations/__init__.py +30 -0
- process_bigraph-1.8.1/process_bigraph/visualizations/distribution.py +44 -0
- process_bigraph-1.8.1/process_bigraph/visualizations/heatmap.py +44 -0
- process_bigraph-1.8.1/process_bigraph/visualizations/param_vs_observable.py +51 -0
- process_bigraph-1.8.1/process_bigraph/visualizations/phase_space.py +40 -0
- process_bigraph-1.8.1/process_bigraph/visualizations/time_series.py +91 -0
- process_bigraph-1.8.1/process_bigraph/visualizations/timeseries_from_observables.py +349 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1/process_bigraph.egg-info}/PKG-INFO +1 -1
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph.egg-info/SOURCES.txt +13 -1
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/pyproject.toml +2 -1
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/AUTHORS.md +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/LICENSE +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/README.md +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/artifacts.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/bundle.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/composite.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/composite_spec.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/emitter.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/experiments/__init__.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/experiments/minimal_gillespie.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/nextflow.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/plumbing.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/processes/__init__.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/processes/bigraphical_reactive_system.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/processes/cached.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/processes/dynamic_structure.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/processes/examples.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/processes/growth_division.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/processes/parameter_scan.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/processes/reaction.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/processes/simulation.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/__init__.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/_git_worker.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/clusters/__init__.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/clusters/ec2_ssm.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/git.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/parallel.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/pool.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/ray.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/rest.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/protocols/session.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/run.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/run_step.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/scheduling.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/server/__init__.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/server/rest.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/server/start.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/templates.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/types/__init__.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph/types/process.py +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph.egg-info/dependency_links.txt +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph.egg-info/requires.txt +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/process_bigraph.egg-info/top_level.txt +0 -0
- {process_bigraph-1.7.1 → process_bigraph-1.8.1}/setup.cfg +0 -0
|
@@ -26,6 +26,14 @@ from process_bigraph.composite_spec import ( # noqa: F401
|
|
|
26
26
|
from process_bigraph.bundle import load_bundle # noqa: F401
|
|
27
27
|
from process_bigraph.emitter import Emitter, gather_emitter_results, generate_emitter_state # noqa: F401
|
|
28
28
|
from process_bigraph.types import StepLink, ProcessLink, CompositeLink # noqa: F401
|
|
29
|
+
from process_bigraph import core_introspection # noqa: F401
|
|
30
|
+
from process_bigraph.composite_generator import ( # noqa: F401
|
|
31
|
+
composite_generator, discover_generators, build_generator,
|
|
32
|
+
install_default_emitters, emitter_defaults,
|
|
33
|
+
)
|
|
34
|
+
from process_bigraph.composite_discovery import discover_all # noqa: F401
|
|
35
|
+
from process_bigraph.config_helpers import normalize_config_list # noqa: F401
|
|
36
|
+
from process_bigraph.visualization import Visualization, as_visualization, render_results # noqa: F401
|
|
29
37
|
|
|
30
38
|
|
|
31
39
|
import pprint
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""Discover composite specs across installed bigraph-schema-dependent packages.
|
|
2
|
+
|
|
3
|
+
A composite spec is any file matching *.composite.yaml or *.composite.json inside
|
|
4
|
+
an installed package whose distribution declares bigraph-schema as a requirement.
|
|
5
|
+
"""
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
import importlib
|
|
8
|
+
import importlib.metadata
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from process_bigraph.composite_spec import CompositeSpec
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
_GLOB_PATTERNS = ("*.composite.yaml", "*.composite.yml", "*.composite.json")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _is_bigraph_schema_lib(dist) -> bool:
|
|
19
|
+
if dist.metadata["Name"] == "bigraph-schema":
|
|
20
|
+
return True
|
|
21
|
+
reqs = dist.requires or []
|
|
22
|
+
return any("bigraph-schema" in r for r in reqs)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def discover_composites(extra_search_paths: list[Path] | None = None) -> dict[str, dict]:
|
|
26
|
+
"""Walk installed bigraph-schema-dependent packages + optional extra dirs.
|
|
27
|
+
|
|
28
|
+
Returns {composite_id: spec_dict}, where composite_id is a stable identifier
|
|
29
|
+
of the form '<package>.<file-stem>' or '<package>.<sub.path>.<file-stem>'.
|
|
30
|
+
|
|
31
|
+
extra_search_paths: additional directories to scan (e.g. workspace-local
|
|
32
|
+
composites/ dirs).
|
|
33
|
+
"""
|
|
34
|
+
specs: dict[str, dict] = {}
|
|
35
|
+
|
|
36
|
+
# 1. Installed packages.
|
|
37
|
+
for dist in importlib.metadata.distributions():
|
|
38
|
+
if not _is_bigraph_schema_lib(dist):
|
|
39
|
+
continue
|
|
40
|
+
# Find every importable package this distribution declares.
|
|
41
|
+
top_level = dist.read_text("top_level.txt") or ""
|
|
42
|
+
for pkg_name in top_level.strip().splitlines():
|
|
43
|
+
if not pkg_name:
|
|
44
|
+
continue
|
|
45
|
+
try:
|
|
46
|
+
mod = importlib.import_module(pkg_name)
|
|
47
|
+
except ImportError:
|
|
48
|
+
continue
|
|
49
|
+
if not getattr(mod, "__file__", None):
|
|
50
|
+
continue
|
|
51
|
+
pkg_root = Path(mod.__file__).parent
|
|
52
|
+
for pattern in _GLOB_PATTERNS:
|
|
53
|
+
for path in pkg_root.rglob(pattern):
|
|
54
|
+
spec_id = _make_spec_id(pkg_name, pkg_root, path)
|
|
55
|
+
try:
|
|
56
|
+
# Delegate parsing + validation to the unified engine;
|
|
57
|
+
# to_dict() serialises to a plain dict for downstream.
|
|
58
|
+
specs[spec_id] = CompositeSpec.from_file(path).to_dict()
|
|
59
|
+
except Exception as e:
|
|
60
|
+
# Skip malformed specs; log to stderr
|
|
61
|
+
print(f"warning: skipping {path}: {e}", file=sys.stderr)
|
|
62
|
+
|
|
63
|
+
# 2. Extra paths (e.g. workspace-local).
|
|
64
|
+
for extra in (extra_search_paths or []):
|
|
65
|
+
if not extra.is_dir():
|
|
66
|
+
continue
|
|
67
|
+
for pattern in _GLOB_PATTERNS:
|
|
68
|
+
for path in extra.rglob(pattern):
|
|
69
|
+
spec_id = _make_spec_id("local", extra, path)
|
|
70
|
+
try:
|
|
71
|
+
specs[spec_id] = CompositeSpec.from_file(path).to_dict()
|
|
72
|
+
except Exception as e:
|
|
73
|
+
print(f"warning: skipping {path}: {e}", file=sys.stderr)
|
|
74
|
+
|
|
75
|
+
return specs
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def discover_all(
|
|
79
|
+
extra_search_paths: list[Path] | None = None,
|
|
80
|
+
extra_packages: list[str] | None = None,
|
|
81
|
+
) -> dict[str, dict]:
|
|
82
|
+
"""Return both static specs and composite generators, tagged with ``kind``.
|
|
83
|
+
|
|
84
|
+
Spec entries get ``kind: spec`` and pass through the existing spec
|
|
85
|
+
payload. Generator entries get ``kind: generator`` and a compact dict
|
|
86
|
+
{name, description, parameters, module} so dashboards can render them
|
|
87
|
+
without holding a reference to the live function object.
|
|
88
|
+
|
|
89
|
+
Discovery imports the host packages of every generator (see
|
|
90
|
+
:func:`process_bigraph.composite_generator.discover_generators`). If
|
|
91
|
+
you need the no-import safety property, call ``discover_composites``
|
|
92
|
+
directly.
|
|
93
|
+
"""
|
|
94
|
+
# Deferred: discover_generators triggers package imports as a
|
|
95
|
+
# side-effect. Keeping it local ensures that cost is paid only when
|
|
96
|
+
# discover_all is explicitly called.
|
|
97
|
+
from process_bigraph.composite_generator import discover_generators
|
|
98
|
+
|
|
99
|
+
specs = discover_composites(extra_search_paths=extra_search_paths)
|
|
100
|
+
out: dict[str, dict] = {
|
|
101
|
+
sid: {"kind": "spec", **s} for sid, s in specs.items()
|
|
102
|
+
}
|
|
103
|
+
for gid, entry in discover_generators(
|
|
104
|
+
extra_packages=extra_packages).items():
|
|
105
|
+
if gid in out:
|
|
106
|
+
import warnings
|
|
107
|
+
warnings.warn(
|
|
108
|
+
f"discover_all: generator {gid!r} collides with a spec of "
|
|
109
|
+
"the same id; generator wins. Rename one to avoid ambiguity.",
|
|
110
|
+
stacklevel=2,
|
|
111
|
+
)
|
|
112
|
+
out[gid] = {
|
|
113
|
+
"kind": "generator",
|
|
114
|
+
"name": entry.name,
|
|
115
|
+
"description": entry.description,
|
|
116
|
+
"parameters": entry.parameters,
|
|
117
|
+
"visualizations": list(entry.visualizations),
|
|
118
|
+
"emitters": list(entry.emitters),
|
|
119
|
+
"module": entry.module,
|
|
120
|
+
"default_n_steps": entry.default_n_steps,
|
|
121
|
+
}
|
|
122
|
+
return out
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _make_spec_id(pkg_name: str, pkg_root: Path, file_path: Path) -> str:
|
|
126
|
+
"""Stable identifier for a composite spec: 'pkg.subdir.subdir.stem'."""
|
|
127
|
+
rel = file_path.relative_to(pkg_root)
|
|
128
|
+
# file_path stem strips both .yaml/.json AND the .composite part if .composite.yaml
|
|
129
|
+
stem = file_path.name
|
|
130
|
+
for suffix in (".composite.yaml", ".composite.yml", ".composite.json"):
|
|
131
|
+
if stem.endswith(suffix):
|
|
132
|
+
stem = stem[:-len(suffix)]
|
|
133
|
+
break
|
|
134
|
+
parts = [pkg_name] + list(rel.parts[:-1]) + [stem]
|
|
135
|
+
return ".".join(parts)
|