diff --git a/builder/builder_api.py b/builder/builder_api.py index 060c99e..7d9cd61 100644 --- a/builder/builder_api.py +++ b/builder/builder_api.py @@ -11,7 +11,7 @@ from pprint import pformat as pf import warnings -from process_bigraph import Process, Step, Composite, ProcessTypes +from process_bigraph import Process, Step, Edge, Composite, ProcessTypes from bigraph_schema.protocols import local_lookup_module from bigraph_viz import plot_bigraph @@ -84,31 +84,39 @@ def __init__(self, tree=None, schema=None, parent=None, core=None): # TODO -- add an emitter by default so results are automatic - def register_process(self, process_name, address): - assert isinstance(process_name, str), f'process name must be a string: {process_name}' - # Check if address is a class object - if inspect.isclass(address): - self.core.process_registry.register(process_name, address) - # Check if address is a string - elif isinstance(address, str): - try: - # separate out the protocol from the address - protocol, addr = address.split(':', 1) - assert protocol == 'local', 'BigraphBuilder only supports local protocol in the current version' - - # TODO -- check protocol registry? - if addr[0] == '!': - process_class = local_lookup_module(addr[1:]) - # Now you have the protocol and address separated, you can process them as needed - self.core.process_registry.register(process_name, process_class) - else: - Exception('only support local addresses') - - except ValueError: - Exception(f"Address '{address}' does not contain a protocol. Registration failed.") + def register_process(self, process_name, address=None): + assert isinstance(process_name, str), f'Process name must be a string: {process_name}' + + if address is None: # use as a decorator + 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) + return cls + return decorator + else: - # Handle other types if necessary - Exception(f"Unsupported address type for {process_name}. Registration failed.") + # Check if address is a class object + if issubclass(address, Edge): + self.core.process_registry.register(process_name, address) + + # Check if address is a string + elif isinstance(address, str): + try: + protocol, addr = address.split(':', 1) + if protocol != 'local': + raise ValueError('BigraphBuilder only supports the local protocol in the current version') + + if addr.startswith('!'): + process_class = local_lookup_module(addr[1:]) + self.core.process_registry.register(process_name, process_class) + else: + raise ValueError('Only local addresses starting with "!" are supported') + except ValueError as e: + # Handle cases where the string does not conform to "protocol:address" + raise ValueError(f"Error parsing address '{address}': {e}") + else: + raise TypeError(f"Unsupported address type for {process_name}: {type(address)}. Registration failed.") def top(self): # recursively get the top parent @@ -389,7 +397,7 @@ def build_gillespie(): def test1(): b = Builder() - # @register_process('toy') + @b.register_process('toy') class Toy(Process): config_schema = { 'A': 'float', @@ -406,27 +414,27 @@ def schema(self): def update(self, state, interval): return {'C': state['A'] + state['B']} - b.register('toy', Toy) - print(b.list_types()) - - b['toy'].add_process(name='toy') - - # b.tree - ports = b['toy'].ports() - print(ports) - # b.plot(filename='toy[1]') - - b['toy'].connect(port='A', target=['A_store']) - b['A_store'] = 2.3 - b['toy'].connect(port='B', target=['B_store']) - - # plot the bigraph - b.visualize(filename='toy[2]') - - b.write(filename='toy[2]', outdir='out') + # b.register('toy', Toy) + # print(b.list_types()) + # + # b['toy'].add_process(name='toy') + # + # # b.tree + # ports = b['toy'].ports() + # print(ports) + # # b.plot(filename='toy[1]') + # + # b['toy'].connect(port='A', target=['A_store']) + # b['A_store'] = 2.3 + # b['toy'].connect(port='B', target=['B_store']) + # + # # plot the bigraph + # b.visualize(filename='toy[2]') + # + # b.write(filename='toy[2]', outdir='out') if __name__ == '__main__': - build_gillespie() - # test1() + # build_gillespie() + test1() diff --git a/notebooks/demo.ipynb b/notebooks/demo.ipynb index 1a1966f..d585251 100644 --- a/notebooks/demo.ipynb +++ b/notebooks/demo.ipynb @@ -49,7 +49,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['ram-emitter', 'console-emitter']\n" + "['console-emitter', 'ram-emitter']\n" ] } ], @@ -79,7 +79,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "['GillespieEvent', 'ram-emitter', 'GillespieInterval', 'console-emitter']\n" + "['console-emitter', 'GillespieEvent', 'GillespieInterval', 'ram-emitter']\n" ] } ], @@ -89,135 +89,21 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 6, "id": "503863ee-0a58-44b3-accc-20e0167b947b", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Unexpected exception formatting exception. Falling back to standard exception\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Traceback (most recent call last):\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/IPython/core/interactiveshell.py\", line 3550, in run_code\n", - " exec(code_obj, self.user_global_ns, self.user_ns)\n", - " File \"/var/folders/vy/vr0_ytms6m95qrnk7xnh0bth0000gq/T/ipykernel_53425/3145499072.py\", line 2, in \n", - " b['event_process'].add_process(\n", - " File \"/Users/eranagmon/code/bigraph-builder/builder/builder_api.py\", line 201, in add_process\n", - " File \"/Users/eranagmon/code/bigraph-builder/builder/builder_api.py\", line 235, in compile\n", - " else:\n", - " File \"/Users/eranagmon/code/bigraph-builder/builder/builder_api.py\", line 241, in compile\n", - " File \"/Users/eranagmon/code/process-bigraph/process_bigraph/composite.py\", line 731, in __init__\n", - " super().__init__(config, core)\n", - " File \"/Users/eranagmon/code/process-bigraph/process_bigraph/composite.py\", line 440, in __init__\n", - " self.config = self.core.fill(\n", - "AttributeError: 'NoneType' object has no attribute 'fill'\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/IPython/core/interactiveshell.py\", line 2144, in showtraceback\n", - " stb = self.InteractiveTB.structured_traceback(\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/IPython/core/ultratb.py\", line 1435, in structured_traceback\n", - " return FormattedTB.structured_traceback(\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/IPython/core/ultratb.py\", line 1326, in structured_traceback\n", - " return VerboseTB.structured_traceback(\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/IPython/core/ultratb.py\", line 1173, in structured_traceback\n", - " formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/IPython/core/ultratb.py\", line 1088, in format_exception_as_a_whole\n", - " frames.append(self.format_record(record))\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/IPython/core/ultratb.py\", line 970, in format_record\n", - " frame_info.lines, Colors, self.has_colors, lvals\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/IPython/core/ultratb.py\", line 792, in lines\n", - " return self._sd.lines\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/stack_data/utils.py\", line 145, in cached_property_wrapper\n", - " value = obj.__dict__[self.func.__name__] = self.func(obj)\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/stack_data/core.py\", line 734, in lines\n", - " pieces = self.included_pieces\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/stack_data/utils.py\", line 145, in cached_property_wrapper\n", - " value = obj.__dict__[self.func.__name__] = self.func(obj)\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/stack_data/core.py\", line 681, in included_pieces\n", - " pos = scope_pieces.index(self.executing_piece)\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/stack_data/utils.py\", line 145, in cached_property_wrapper\n", - " value = obj.__dict__[self.func.__name__] = self.func(obj)\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/stack_data/core.py\", line 660, in executing_piece\n", - " return only(\n", - " File \"/Users/eranagmon/code/bigraph-builder/venv/lib/python3.9/site-packages/executing/executing.py\", line 116, in only\n", - " raise NotOneValueFound('Expected one value, found 0')\n", - "executing.executing.NotOneValueFound: Expected one value, found 0\n" - ] - } - ], - "source": [ - "## 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": null, - "id": "2f1f606b-160c-4158-9a54-54dba22f0732", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a93508ae-95d3-4a7f-ae18-54c17e6f409e", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "a84d340622208914", - "metadata": { - "ExecuteTime": { - "end_time": "2024-01-21T21:29:21.988572Z", - "start_time": "2024-01-21T21:29:21.986667Z" - }, - "collapsed": false, - "jupyter": { - "outputs_hidden": false - } - }, "outputs": [], "source": [ - "# b['fba'].add_process(name='cobra')" + "# ## 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": "235efcd79c0f13c1", - "metadata": { - "ExecuteTime": { - "start_time": "2024-01-21T21:29:21.988497Z" - }, - "collapsed": false, - "jupyter": { - "outputs_hidden": false - } - }, - "outputs": [], - "source": [ - "# b['smoldyn'].add_process(name='smoldyn_process')" - ] - }, - { - "cell_type": "code", - "execution_count": 8, "id": "1ee84904801a9ab", "metadata": { "ExecuteTime": { @@ -230,6 +116,7 @@ }, "outputs": [], "source": [ + "@b.register_process('toy')\n", "class Toy(Process):\n", " config_schema = {\n", " 'A': 'float',\n", @@ -252,14 +139,12 @@ " update = {\n", " 'C': state['A'] + state['B']\n", " }\n", - " return update\n", - "\n", - "b.register_process('toy', Toy)" + " return update\n" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "id": "dae8ca8db70c4845", "metadata": { "ExecuteTime": { @@ -272,24 +157,36 @@ }, "outputs": [ { - "ename": "AttributeError", - "evalue": "'Builder' object has no attribute 'process_registry_list'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mAttributeError\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[38;5;241;43m.\u001b[39;49m\u001b[43mprocess_registry_list\u001b[49m()\n", - "\u001b[0;31mAttributeError\u001b[0m: 'Builder' object has no attribute 'process_registry_list'" + "name": "stdout", + "output_type": "stream", + "text": [ + "['ram-emitter', 'GillespieEvent', 'console-emitter', 'GillespieInterval', 'toy']\n" ] } ], "source": [ - "b.process_registry_list()" + "b.list_processes()" ] }, { "cell_type": "code", "execution_count": null, + "id": "1ab07d86-695d-4113-8bbb-66bebc7b22ce", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "2694ee21-d3b6-4c5d-9dbf-ea2348c97797", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 9, "id": "8b1f49a78de17642", "metadata": { "ExecuteTime": { @@ -301,7 +198,25 @@ "outputs_hidden": false } }, - "outputs": [], + "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" + ] + } + ], "source": [ "b['toy'].add_process(name='toy')" ]