diff --git a/builder/builder_api.py b/builder/builder_api.py index 1864282..cdf8f01 100644 --- a/builder/builder_api.py +++ b/builder/builder_api.py @@ -7,12 +7,36 @@ """ import os import json -from pprint import pformat as pf import warnings from process_bigraph import Process, Step, Edge, Composite, ProcessTypes from bigraph_schema.protocols import local_lookup_module -from bigraph_viz import plot_bigraph +from bigraph_viz.diagram import plot_bigraph + +def custom_pf(d, indent=0): + """Custom dictionary formatter to achieve specific indentation styles.""" + items = [] + for k, v in d.items(): + key_str = f"{repr(k)}: " + if isinstance(v, dict): + if v: # Check if the dictionary is not empty + value_str = custom_pf(v, indent + 3) + else: + value_str = "{}" + else: + value_str = repr(v) + items.append(f"{' ' * indent}{key_str}{value_str}") + + # Use f-string for final formatting, incorporating items_str + items_str = ',\n'.join(items) + if indent > 0: + return f"{{\n{items_str}\n{' ' * (indent - 4)}}}" + else: + return f"{{\n{items_str}\n}}" + + + +# Examp EDGE_KEYS = ['process', 'step', 'edge'] # todo -- replace this with core.check() or similar @@ -93,7 +117,7 @@ def register_process(self, process_name, address=None): def decorator(cls): if not issubclass(cls, Edge): raise TypeError(f"The class {cls.__name__} must be a subclass of Edge") - self.core.process_registry.register(process_name, cls) + self.core.process_registry.register(process_name, cls, force=True) return cls return decorator @@ -106,12 +130,12 @@ def decorator(cls): if addr.startswith('!'): process_class = local_lookup_module(addr[1:]) - self.core.process_registry.register(process_name, process_class) + self.core.process_registry.register(process_name, process_class, force=True) else: raise ValueError('Only local addresses starting with "!" are supported') # Check if address is a class object elif issubclass(address, Edge): - self.core.process_registry.register(process_name, address) + self.core.process_registry.register(process_name, address, force=True) else: raise TypeError(f"Unsupported address type for {process_name}: {type(address)}. Registration failed.") @@ -123,7 +147,8 @@ def top(self): return self def __repr__(self): - return f"Builder({pf(self.tree)})" + return custom_pf(dict_from_builder_tree(self.tree)) + # return f"Builder(\n{pf(self.tree)})" def __setitem__(self, keys, value): # Convert single key to tuple @@ -237,7 +262,9 @@ def compile(self): self.schema, dict_from_builder_tree(self.tree) ) - self.compiled_composite = Composite({'state': tree, 'composition': self.schema}) + self.compiled_composite = Composite( + {'state': tree, 'composition': self.schema}, + core=self.core) # reset the builder tree self.update_tree(self.compiled_composite.composition, self.compiled_composite.state) @@ -262,7 +289,7 @@ def run(self, interval): self.compile() self.compiled_composite.run(interval) - def ports(self): + def ports(self, print_ports=False): # self.compile() tree_dict = dict_from_builder_tree(self.tree) tree_type = tree_dict.get('_type') @@ -271,7 +298,11 @@ def ports(self): elif tree_type not in EDGE_KEYS: warnings.warn(f"Expected '_type' to be in {EDGE_KEYS}, found '{tree_type}' instead.") elif tree_type: - return get_process_ports(tree_dict, self.schema) + process_ports = get_process_ports(tree_dict, self.schema) + if not print_ports: + return process_ports + else: + print(custom_pf(process_ports)) def visualize(self, filename=None, out_dir=None, **kwargs): if filename and not out_dir: @@ -286,7 +317,7 @@ def visualize(self, filename=None, out_dir=None, **kwargs): tree_dict, out_dir=out_dir, filename=filename, - show_process_schema=False, + # show_process_schema=False, **kwargs) def get_results(self, query=None): @@ -308,7 +339,7 @@ def emitter(self, name='ram-emitter', emit_keys=None): def build_gillespie(): - from process_bigraph.experiments.minimal_gillespie import GillespieEvent #, GillespieInterval + from process_bigraph.experiments.minimal_gillespie import GillespieEvent #, GillespieInterval gillespie = Builder() @@ -339,9 +370,12 @@ def build_gillespie(): ) gillespie['interval_process'].add_process( name='GillespieInterval', - inputs={'port_id': ['store']} # we should be able to set the wires directly like this + # inputs={'port_id': ['store']} # we should be able to set the wires directly like this ) + ## visualize part-way through build + gillespie.visualize(filename='bigraph1', out_dir='out') + ## choose an emitter gillespie.emitter(name='ram-emitter', path=[]) # choose the emitter, path=[] would be all gillespie.emitter(name='csv-emitter', path=['cell1', 'internal'], emit_tree={}) # add a second emitter diff --git a/notebooks/demo.ipynb b/notebooks/demo.ipynb index d585251..ae0a2ff 100644 --- a/notebooks/demo.ipynb +++ b/notebooks/demo.ipynb @@ -49,7 +49,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['console-emitter', 'ram-emitter']\n" + "['ram-emitter', 'console-emitter']\n" ] } ], @@ -79,7 +79,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['console-emitter', 'GillespieEvent', 'GillespieInterval', 'ram-emitter']\n" + "['GillespieInterval', 'ram-emitter', 'console-emitter', 'GillespieEvent']\n" ] } ], @@ -94,16 +94,162 @@ "metadata": {}, "outputs": [], "source": [ - "# ## add processes\n", - "# b['event_process'].add_process(\n", - "# name='GillespieEvent',\n", - "# kdeg=1.0, # kwargs fill parameters in the config\n", - "# )" + "## add processes\n", + "b['event_process'].add_process(\n", + " name='GillespieEvent',\n", + " kdeg=1.0, # kwargs fill parameters in the config\n", + ")" ] }, { "cell_type": "code", "execution_count": 7, + "id": "b094f1e5-5202-48d0-8bdd-57bbdded7fd1", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b.compile()" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "5ea31425-a8bb-45c3-a31d-77714cc8c137", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + "'_inputs': {\n", + " 'mRNA': 'map[float]',\n", + " 'DNA': {\n", + " 'A gene': 'float',\n", + " 'B gene': 'float'\n", + " }\n", + "},\n", + "'_outputs': {\n", + " 'mRNA': 'map[float]'\n", + "}\n", + "}\n" + ] + } + ], + "source": [ + "b['event_process'].ports(True)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "c9f462bb-5316-4724-aa8e-b3b71eb379b2", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{\n", + "'event_process': {\n", + " '_type': 'process',\n", + " 'address': 'local:GillespieEvent',\n", + " 'config': {\n", + " 'kdeg': 1.0,\n", + " 'ktsc': 5.0\n", + " },\n", + " 'inputs': {},\n", + " 'outputs': {},\n", + " 'instance': ,\n", + " 'interval': 1.0\n", + "},\n", + "'global_time': 0.0\n", + "}" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "79809baf-1d87-475a-b85f-3729f4716cb4", + "metadata": {}, + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "bigraph\n", + "\n", + "\n", + "\n", + "('global_time',)\n", + "\n", + "global_time\n", + "\n", + "\n", + "\n", + "('event_process',)\n", + "\n", + "event_process\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "b.visualize()" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "72088795-49c9-4e28-b539-1bdacd70ea91", + "metadata": {}, + "outputs": [], + "source": [ + "# from builder.builder_api import Builder, dict_from_builder_tree\n", + "# tree_dict = dict_from_builder_tree(b.tree)\n", + "\n", + "# tree_dict" + ] + }, + { + "cell_type": "code", + "execution_count": 12, "id": "1ee84904801a9ab", "metadata": { "ExecuteTime": { @@ -123,8 +269,8 @@ " 'B': 'float',\n", " }\n", "\n", - " def __init__(self, config):\n", - " super().__init__(config)\n", + " def __init__(self, config, core):\n", + " super().__init__(config, core)\n", "\n", " def schema(self):\n", " return {\n", @@ -144,7 +290,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 13, "id": "dae8ca8db70c4845", "metadata": { "ExecuteTime": { @@ -160,7 +306,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['ram-emitter', 'GillespieEvent', 'console-emitter', 'GillespieInterval', 'toy']\n" + "['GillespieInterval', 'console-emitter', 'toy', 'GillespieEvent', 'ram-emitter']\n" ] } ], @@ -168,14 +314,6 @@ "b.list_processes()" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "1ab07d86-695d-4113-8bbb-66bebc7b22ce", - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, @@ -186,7 +324,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 14, "id": "8b1f49a78de17642", "metadata": { "ExecuteTime": { @@ -198,32 +336,14 @@ "outputs_hidden": false } }, - "outputs": [ - { - "ename": "TypeError", - "evalue": "__init__() takes 2 positional arguments but 3 were given", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[9], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mb\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mtoy\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43madd_process\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mtoy\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m~/code/bigraph-builder/builder/builder_api.py:202\u001b[0m, in \u001b[0;36mBuilder.add_process\u001b[0;34m(self, name, config, inputs, outputs, **kwargs)\u001b[0m\n\u001b[1;32m 193\u001b[0m initial_state \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 194\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_type\u001b[39m\u001b[38;5;124m'\u001b[39m: edge_type,\n\u001b[1;32m 195\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124maddress\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mlocal:\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mname\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;66;03m# TODO -- only support local right now?\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 198\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124moutputs\u001b[39m\u001b[38;5;124m'\u001b[39m: outputs \u001b[38;5;129;01mor\u001b[39;00m {},\n\u001b[1;32m 199\u001b[0m }\n\u001b[1;32m 201\u001b[0m initial_schema \u001b[38;5;241m=\u001b[39m {\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_type\u001b[39m\u001b[38;5;124m'\u001b[39m: edge_type}\n\u001b[0;32m--> 202\u001b[0m schema, state \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcore\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcomplete\u001b[49m\u001b[43m(\u001b[49m\u001b[43minitial_schema\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43minitial_state\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 204\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtree \u001b[38;5;241m=\u001b[39m builder_tree_from_dict(state)\n\u001b[1;32m 205\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mschema \u001b[38;5;241m=\u001b[39m schema \u001b[38;5;129;01mor\u001b[39;00m {}\n", - "File \u001b[0;32m~/code/bigraph-schema/bigraph_schema/type_system.py:1246\u001b[0m, in \u001b[0;36mTypeSystem.complete\u001b[0;34m(self, initial_schema, initial_state)\u001b[0m\n\u001b[1;32m 1242\u001b[0m full_schema \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39maccess(\n\u001b[1;32m 1243\u001b[0m initial_schema)\n\u001b[1;32m 1245\u001b[0m \u001b[38;5;66;03m# hydrate the state given the initial composition\u001b[39;00m\n\u001b[0;32m-> 1246\u001b[0m state \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhydrate\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1247\u001b[0m \u001b[43m \u001b[49m\u001b[43mfull_schema\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1248\u001b[0m \u001b[43m \u001b[49m\u001b[43minitial_state\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1250\u001b[0m \u001b[38;5;66;03m# fill in the parts of the composition schema\u001b[39;00m\n\u001b[1;32m 1251\u001b[0m \u001b[38;5;66;03m# determined by the state\u001b[39;00m\n\u001b[1;32m 1252\u001b[0m schema, state \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39minfer_schema(\n\u001b[1;32m 1253\u001b[0m full_schema,\n\u001b[1;32m 1254\u001b[0m state)\n", - "File \u001b[0;32m~/code/bigraph-schema/bigraph_schema/type_system.py:1237\u001b[0m, in \u001b[0;36mTypeSystem.hydrate\u001b[0;34m(self, schema, state)\u001b[0m\n\u001b[1;32m 1235\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mhydrate\u001b[39m(\u001b[38;5;28mself\u001b[39m, schema, state):\n\u001b[1;32m 1236\u001b[0m \u001b[38;5;66;03m# TODO: support partial hydration (!)\u001b[39;00m\n\u001b[0;32m-> 1237\u001b[0m hydrated \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhydrate_state\u001b[49m\u001b[43m(\u001b[49m\u001b[43mschema\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstate\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1238\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfill(schema, hydrated)\n", - "File \u001b[0;32m~/code/bigraph-schema/bigraph_schema/type_system.py:1209\u001b[0m, in \u001b[0;36mTypeSystem.hydrate_state\u001b[0;34m(self, schema, state)\u001b[0m\n\u001b[1;32m 1207\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mhydrate_state\u001b[39m(\u001b[38;5;28mself\u001b[39m, schema, state):\n\u001b[1;32m 1208\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(state, \u001b[38;5;28mstr\u001b[39m) \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_deserialize\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;129;01min\u001b[39;00m schema:\n\u001b[0;32m-> 1209\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdeserialize\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1210\u001b[0m \u001b[43m \u001b[49m\u001b[43mschema\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1211\u001b[0m \u001b[43m \u001b[49m\u001b[43mstate\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1213\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(state, \u001b[38;5;28mdict\u001b[39m):\n\u001b[1;32m 1214\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(schema, \u001b[38;5;28mstr\u001b[39m):\n", - "File \u001b[0;32m~/code/bigraph-schema/bigraph_schema/type_system.py:606\u001b[0m, in \u001b[0;36mTypeSystem.deserialize\u001b[0;34m(self, schema, encoded)\u001b[0m\n\u001b[1;32m 603\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m encoded \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 604\u001b[0m encoded \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdefault(schema)\n\u001b[0;32m--> 606\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mdeserialize_function\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 607\u001b[0m \u001b[43m \u001b[49m\u001b[43mencoded\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 608\u001b[0m \u001b[43m \u001b[49m\u001b[43mfound\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 609\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 611\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(encoded, \u001b[38;5;28mdict\u001b[39m):\n\u001b[1;32m 612\u001b[0m result \u001b[38;5;241m=\u001b[39m {}\n", - "File \u001b[0;32m~/code/process-bigraph/process_bigraph/composite.py:94\u001b[0m, in \u001b[0;36mdeserialize_process\u001b[0;34m(encoded, schema, core)\u001b[0m\n\u001b[1;32m 89\u001b[0m interval \u001b[38;5;241m=\u001b[39m core\u001b[38;5;241m.\u001b[39mdeserialize(\n\u001b[1;32m 90\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124minterval\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[1;32m 91\u001b[0m encoded\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124minterval\u001b[39m\u001b[38;5;124m'\u001b[39m))\n\u001b[1;32m 93\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124minstance\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;129;01min\u001b[39;00m deserialized:\n\u001b[0;32m---> 94\u001b[0m process \u001b[38;5;241m=\u001b[39m \u001b[43minstantiate\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcore\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 95\u001b[0m deserialized[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124minstance\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m process\n\u001b[1;32m 97\u001b[0m deserialized[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mconfig\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m config\n", - "\u001b[0;31mTypeError\u001b[0m: __init__() takes 2 positional arguments but 3 were given" - ] - } - ], + "outputs": [], "source": [ "b['toy'].add_process(name='toy')" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "329e64816e8ff626", "metadata": { "ExecuteTime": { @@ -234,14 +354,25 @@ "outputs_hidden": false } }, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'_inputs': {}, '_outputs': {}}" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "b['toy'].ports()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "id": "3b1dd8569f3bb67a", "metadata": { "ExecuteTime": { @@ -252,14 +383,58 @@ "outputs_hidden": false } }, - "outputs": [], + "outputs": [ + { + "data": { + "image/svg+xml": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "bigraph\n", + "\n", + "\n", + "\n", + "('global_time',)\n", + "\n", + "global_time\n", + "\n", + "\n", + "\n", + "('event_process',)\n", + "\n", + "event_process\n", + "\n", + "\n", + "\n", + "('toy',)\n", + "\n", + "toy\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "b.plot()" + "b.visualize()" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "f02c15797bdb73b8", "metadata": { "ExecuteTime": { @@ -270,7 +445,20 @@ "outputs_hidden": false } }, - "outputs": [], + "outputs": [ + { + "ename": "AssertionError", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[17], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mb\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mtoy\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconnect\u001b[49m\u001b[43m(\u001b[49m\u001b[43mport\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mA\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtarget\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mA_store\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m# b['toy'].connect(port='B', target='B_store') # TODO -- compile is trying to connect A at the wrong level??\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;66;03m# b['toy'].connect(port='C', target='C_store')\u001b[39;00m\n", + "File \u001b[0;32m~/code/bigraph-builder/builder/builder_api.py:228\u001b[0m, in \u001b[0;36mBuilder.connect\u001b[0;34m(self, port, target)\u001b[0m\n\u001b[1;32m 227\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mconnect\u001b[39m(\u001b[38;5;28mself\u001b[39m, port\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, target\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[0;32m--> 228\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcore\u001b[38;5;241m.\u001b[39mcheck(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124medge\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mschema)\n\u001b[1;32m 229\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m port \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mschema[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m_inputs\u001b[39m\u001b[38;5;124m'\u001b[39m]:\n\u001b[1;32m 230\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtree[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124minputs\u001b[39m\u001b[38;5;124m'\u001b[39m][port] \u001b[38;5;241m=\u001b[39m target\n", + "\u001b[0;31mAssertionError\u001b[0m: " + ] + } + ], "source": [ "b['toy'].connect(port='A', target='A_store')\n", "# b['toy'].connect(port='B', target='B_store') # TODO -- compile is trying to connect A at the wrong level??\n",