diff --git a/notebooks/demo.html b/notebooks/demo.html index 9bb5779..fa353de 100644 --- a/notebooks/demo.html +++ b/notebooks/demo.html @@ -7500,7 +7500,7 @@
-e git+ssh://git@github.com/vivarium-collective/bigraph-schema.git@212737a5bf8b627664cf12a9cd752c8cda12c650#egg=bigraph_schema -bigraph-viz==0.0.30 --
A type system comprises a set of rules and constraints that govern the organization, interaction, and manipulation of bigraph nodes, facilitating efficient and error-free compositional modeling by guaranteeing compatibility and seamless communication between various components within a simulation.
The main class for working with bigraph_schema is TypeSystem
, which handles the different type schemas and provides methods for their manipulation. We will use TypeSystem.validate_schema
to check our schemas, TypeSystem.access
to fill in missing details to prepare the schema for simulation, and TypeSystem.type_registry
to access different schemas and register new ones.
Schemas serve as a formalized framework for defining and organizing types, providing explicit specifications for data representation, validation, and transformation. In a schema, types are characterized by specific schema_keys
associated with type definitions, encompassing default values, serialization/deserialization methods, and additional metadata. The schema_keys
encompass the following attributes. We will see specific instances of these below.
types = TypeSystem()
-
# from bigraph_schema.registry import type_schema_keys
-# type_schema_keys
+core = TypeSystem()
types.type_registry.list()
+core.type_registry.list()
['', - 'current*length^2', - 'length^4*mass/time^3', + 'temperature', + 'length^4*mass/current*time^3', + 'mass/length*time^2', 'luminosity', - 'current*length^2*time', - 'edge', + 'length^0_5*mass^0_5', + 'length^3*mass/current^2*time^4', + 'length^2/time', + 'length*time/mass', + 'current*time/substance', + 'length^2*mass/current^2*time^2', + 'length^2', + 'length^2*mass/current*time^2', + 'current*length*time', + 'length^3/mass*time^2', + 'length^4*mass/time^3', + 'printing_unit/length', + 'length', + 'mass/temperature^4*time^3', + 'map', + 'schema', + 'boolean', + 'length^2*mass/time^2', + 'length/time^2', 'union', + 'current*length^2', 'length^2*mass/current^2*time^3', - 'length^2/time', + 'length^2*mass/time^3', 'mass/time^2', - 'length^2*mass/temperature*time^2', - 'length^3*mass/current^2*time^4', - 'current*time/substance', - 'time/length', - 'length^0_5*mass^0_5', + 'mass/length*time', + 'current^2*time^3/length^2*mass', + 'list', + 'current', + 'length*temperature', + 'mass/time^3', + 'tree', + 'length/mass', 'current*time^2/length^2*mass', - 'length^2*mass/time^2', - 'length^1_5*mass^0_5/time', + 'length^3', + 'substance/time', + 'mass/length^3', + 'wires', + 'length*mass/current^2*time^2', + 'int', 'substance/length^3', - 'printing_unit', - 'length/mass', - 'length*time/mass', - 'dict', - 'mass/time^3', 'array', + 'any', + 'edge', + 'mass', + '/length', + 'length^0_5*mass^0_5/time', + '/printing_unit', 'length*mass/time^2', - 'number', - 'length^2*mass/current^2*time^2', - 'length/time', - 'mass/length^3', + 'current*time', 'maybe', - 'mass', - 'length^2', - 'mass/length*time^2', - 'length*mass/current*time^3', - 'any', - 'length*mass/current^2*time^2', - 'current*time/mass', - 'tree', - 'length^3/time', - 'length^2*mass/time', - '/time', - 'current*length*time', - 'int', 'mass/length', - 'time', - 'float', - 'length^2*mass/current*time^3', - 'luminosity/length^2', - 'substance', 'mass^0_5/length^1_5', - 'string', - '/substance', - 'length*temperature', - 'length^3', - 'length^2*mass/current*time^2', - 'mass/length*time', - 'length^1_5*mass^0_5/time^2', - 'temperature', - 'length', - 'length^3/mass*time^2', - 'substance/time', - 'current^2*time^4/length^2*mass', - 'length^0_5*mass^0_5/time', - 'printing_unit/length', + 'number', + 'length^2*mass/temperature*time^2', + 'luminosity/length^2', 'length^2*mass/substance*temperature*time^2', + 'length^1_5*mass^0_5/time', + 'tuple', 'time^2/length', - 'length^4*mass/current*time^3', - 'current*time', - 'current^2*time^3/length^2*mass', - '/length', - '/temperature*time', - 'length/time^2', + 'length/time', + 'length^1_5*mass^0_5/time^2', + 'substance', 'length^2/time^2', - 'current', + 'printing_unit', + 'current^2*time^4/length^2*mass', + '/substance', + 'mass/current*time^2', + 'time', + 'length^2*mass/time', + 'float', 'current^2*time^4/length^3*mass', - '/printing_unit', - 'length^2*mass/time^3', - 'mass/temperature^4*time^3', - 'mass^0_5/length^0_5*time', - 'list', - 'mass/current*time^2']+ 'length*mass/current*time^3', + '/temperature*time', + 'string', + 'current*time/mass', + '/time', + 'time/length', + 'current*length^2*time', + 'length^2*mass/current*time^3', + 'length^3/time', + 'mass^0_5/length^0_5*time']
float_schema = types.access('float')
+float_schema = core.access('float')
float_schema
{'_type': 'float', - '_apply': 'accumulate', - '_serialize': 'to_string', + '_apply': 'bigraph_schema.type_system.accumulate', + '_check': 'bigraph_schema.type_system.check_float', + '_serialize': 'bigraph_schema.type_system.to_string', '_description': '64-bit floating point precision number', '_default': '0.0', - '_deserialize': 'float', - '_divide': 'divide_float', + '_deserialize': 'bigraph_schema.type_system.deserialize_float', + '_divide': 'bigraph_schema.type_system.divide_float', '_super': ['number']}
# here showing the method specified by the `float` type
-apply_method = types.apply_registry.access(float_schema['_apply'])
-serialize_method = types.serialize_registry.access(float_schema['_serialize'])
-deserialize_method = types.deserialize_registry.access(float_schema['_deserialize'])
-divide_method = types.divide_registry.access(float_schema['_divide'])
+apply_method = core.type_registry.apply_registry.access(float_schema['_apply'])
+serialize_method = core.type_registry.serialize_registry.access(float_schema['_serialize'])
+deserialize_method = core.type_registry.deserialize_registry.access(float_schema['_deserialize'])
+divide_method = core.type_registry.divide_registry.access(float_schema['_divide'])
default_value = float_schema['_default']
deserialized_default_value = deserialize_method(default_value)
@@ -7831,10 +7804,10 @@ Use access to expand a composite
-In [8]:
+In [7]:
-pp(types.access('edge'))
+pp(core.access('edge'))
@@ -7847,58 +7820,112 @@ Use access to expand a composite
-{ '_apply': 'apply_edge',
- '_default': '{"wires": {}}',
+{ '_apply': 'bigraph_schema.type_system.apply_edge',
+ '_check': 'bigraph_schema.type_system.check_edge',
+ '_default': {'inputs': {}, 'outputs': {}},
'_description': 'hyperedges in the bigraph, with ports as a type parameter',
- '_deserialize': 'deserialize_edge',
- '_divide': 'divide_edge',
- '_serialize': 'serialize_edge',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_edge',
+ '_divide': 'bigraph_schema.type_system.divide_edge',
+ '_serialize': 'bigraph_schema.type_system.serialize_edge',
'_type': 'edge',
- '_type_parameters': ['ports'],
- 'wires': { '_apply': 'apply_tree',
- '_bindings': {'leaf': ['list', ['string']]},
- '_default': '{}',
- '_description': 'mapping from str to some type (or nested dicts)',
- '_deserialize': 'deserialize_tree',
- '_divide': 'divide_tree',
- '_leaf': { '_apply': 'concatenate',
- '_bindings': {'element': 'string'},
- '_default': '[]',
- '_description': 'general list type (or sublists)',
- '_deserialize': 'evaluate',
- '_divide': 'divide_list',
- '_element': { '_apply': 'replace',
- '_default': '""',
- '_description': '64-bit integer',
- '_deserialize': 'deserialize_string',
- '_divide': 'divide_int',
- '_serialize': 'serialize_string',
- '_type': 'string'},
- '_serialize': 'to_string',
- '_type': 'list',
- '_type_parameters': ['element']},
- '_serialize': 'serialize_tree',
- '_type': 'tree',
- '_type_parameters': ['leaf']}}
+ '_type_parameters': ['inputs', 'outputs'],
+ 'inputs': { '_apply': 'bigraph_schema.registry.apply_tree',
+ '_bindings': { 'leaf': { '_apply': 'bigraph_schema.type_system.apply_list',
+ '_bindings': {'element': 'string'},
+ '_check': 'bigraph_schema.type_system.check_list',
+ '_default': [],
+ '_description': 'general list type (or '
+ 'sublists)',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_list',
+ '_divide': 'bigraph_schema.type_system.divide_list',
+ '_element': { '_apply': 'bigraph_schema.type_system.replace',
+ '_check': 'bigraph_schema.type_system.check_string',
+ '_default': '',
+ '_description': '64-bit '
+ 'integer',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_string',
+ '_serialize': 'bigraph_schema.type_system.serialize_string',
+ '_type': 'string'},
+ '_serialize': 'bigraph_schema.type_system.serialize_list',
+ '_type': 'list',
+ '_type_parameters': ['element']}},
+ '_check': 'bigraph_schema.type_system.check_tree',
+ '_default': {},
+ '_description': 'mapping from str to some type in a potentially '
+ 'nested form',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_tree',
+ '_divide': 'bigraph_schema.type_system.divide_tree',
+ '_leaf': { '_apply': 'bigraph_schema.type_system.apply_list',
+ '_bindings': {'element': 'string'},
+ '_check': 'bigraph_schema.type_system.check_list',
+ '_default': [],
+ '_description': 'general list type (or sublists)',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_list',
+ '_divide': 'bigraph_schema.type_system.divide_list',
+ '_element': { '_apply': 'bigraph_schema.type_system.replace',
+ '_check': 'bigraph_schema.type_system.check_string',
+ '_default': '',
+ '_description': '64-bit integer',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_string',
+ '_serialize': 'bigraph_schema.type_system.serialize_string',
+ '_type': 'string'},
+ '_serialize': 'bigraph_schema.type_system.serialize_list',
+ '_type': 'list',
+ '_type_parameters': ['element']},
+ '_serialize': 'bigraph_schema.type_system.serialize_tree',
+ '_type': 'tree',
+ '_type_parameters': ['leaf']},
+ 'outputs': { '_apply': 'bigraph_schema.registry.apply_tree',
+ '_bindings': { 'leaf': { '_apply': 'bigraph_schema.type_system.apply_list',
+ '_bindings': {'element': 'string'},
+ '_check': 'bigraph_schema.type_system.check_list',
+ '_default': [],
+ '_description': 'general list type (or '
+ 'sublists)',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_list',
+ '_divide': 'bigraph_schema.type_system.divide_list',
+ '_element': { '_apply': 'bigraph_schema.type_system.replace',
+ '_check': 'bigraph_schema.type_system.check_string',
+ '_default': '',
+ '_description': '64-bit '
+ 'integer',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_string',
+ '_serialize': 'bigraph_schema.type_system.serialize_string',
+ '_type': 'string'},
+ '_serialize': 'bigraph_schema.type_system.serialize_list',
+ '_type': 'list',
+ '_type_parameters': ['element']}},
+ '_check': 'bigraph_schema.type_system.check_tree',
+ '_default': {},
+ '_description': 'mapping from str to some type in a potentially '
+ 'nested form',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_tree',
+ '_divide': 'bigraph_schema.type_system.divide_tree',
+ '_leaf': { '_apply': 'bigraph_schema.type_system.apply_list',
+ '_bindings': {'element': 'string'},
+ '_check': 'bigraph_schema.type_system.check_list',
+ '_default': [],
+ '_description': 'general list type (or sublists)',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_list',
+ '_divide': 'bigraph_schema.type_system.divide_list',
+ '_element': { '_apply': 'bigraph_schema.type_system.replace',
+ '_check': 'bigraph_schema.type_system.check_string',
+ '_default': '',
+ '_description': '64-bit integer',
+ '_deserialize': 'bigraph_schema.type_system.deserialize_string',
+ '_serialize': 'bigraph_schema.type_system.serialize_string',
+ '_type': 'string'},
+ '_serialize': 'bigraph_schema.type_system.serialize_list',
+ '_type': 'list',
+ '_type_parameters': ['element']},
+ '_serialize': 'bigraph_schema.type_system.serialize_tree',
+ '_type': 'tree',
+ '_type_parameters': ['leaf']}}
-
-
foursquare_schema = {
- '_type': 'foursquare',
- '00': 'union[bool,foursquare]',
- '01': 'union[bool,foursquare]',
- '10': 'union[bool,foursquare]',
- '11': 'union[bool,foursquare]',
- '_default': {
- '00': False,
- '01': False,
- '10': False,
- '11': False
- },
- '_description': '',
-}
-types.type_registry.register(
- 'foursquare', foursquare_schema)
+def apply_foursquare(current, update, bindings, core):
+ if isinstance(current, bool) or isinstance(update, bool):
+ return update
+ else:
+ for key, value in update.items():
+ current[key] = apply_foursquare(
+ current[key],
+ value,
+ bindings,
+ core)
+
+ return current
+
+foursquare_schema = {
+ '_apply': apply_foursquare,
+ '00': 'boolean~foursquare',
+ '01': 'boolean~foursquare',
+ '10': 'boolean~foursquare',
+ '11': 'boolean~foursquare'}
+
+core.register(
+ 'foursquare',
+ foursquare_schema, force=True)
import os
@@ -7982,63 +8016,61 @@ Register a new type schemafig_path = os.path.join(out_dir, filename)
plt.savefig(fig_path, format='png', dpi=300)
plt.show()
+
foursquare_schema = {
+ '_apply': apply_foursquare,
+ '00': 'boolean~foursquare',
+ '01': 'boolean~foursquare',
+ '10': 'boolean~foursquare',
+ '11': 'boolean~foursquare'}
+
+core.register(
+ 'foursquare',
+ foursquare_schema)
example = {
- '00': True,
+ '00': True,
+ '01': False,
+ '10': False,
'11': {
- '00': True,
+ '00': True,
+ '01': False,
+ '10': False,
'11': {
- '00': True,
+ '00': True,
+ '01': False,
+ '10': False,
'11': {
- '00': True,
+ '00': True,
+ '01': False,
+ '10': False,
'11': {
- '00': True,
+ '00': True,
+ '01': False,
+ '10': False,
'11': {
- '00': True,
- },
- },
- },
- },
- },
-}
-# TODO: get this to register as a type
-example_full = {
- '_type': 'foursquare',
- '00': {
- '_value': True,
- '_type': 'bool'},
- '11': {
- '_type': 'foursquare',
- '00': {
- '_value': True,
- '_type': 'bool'},
- '11': {
- '_type': 'foursquare',
- '00': {
- '_value': True,
- '_type': 'bool'},
- '11': {
- '_type': 'foursquare',
- '00': {
- '_value': True,
- '_type': 'bool'},
- '11': {
- '_type': 'foursquare',
- '00': {
- '_value': True,
- '_type': 'bool'},
- '11': {
- '_type': 'foursquare',
- '00': {
- '_value': True,
- '_type': 'bool'},
- },
- },
- },
- },
- },
-}
+ '00': True,
+ '01': False,
+ '10': False,
+ '11': False}}}}}}
+
+assert core.check(
+ 'foursquare',
+ example)
+# plot
plot_foursquare(example, filename="example.png")
---------------------------------------------------------------------------- -ModuleNotFoundError Traceback (most recent call last) -Cell In[10], line 2 - 1 import os -----> 2 import matplotlib.pyplot as plt - 3 import numpy as np - 5 def render(data, arr, x, y, size): - -ModuleNotFoundError: No module named 'matplotlib'+
# TODO: get this to register as a type
-example = {
- '00': True,
- '11': True,
- '01': {
- '11': True,
- '00': {
- '00': True
- }
- }
-}
-
-plot_foursquare(example, filename="example.png")
+plot_bigraph(example, out_dir='out', filename="foursquarebigraph")
---------------------------------------------------------------------------- -NameError Traceback (most recent call last) -Cell In[11], line 13 - 1 # TODO: get this to register as a type - 2 example = { - 3 '00': True, - 4 '11': True, - (...) - 10 } - 11 } ----> 13 plot_foursquare(example, filename="example.png") - -NameError: name 'plot_foursquare' is not defined+
Writing out/foursquarebigraph +
plot_bigraph(example)
+update = {
+ '00': False,
+ '10': {
+ '01': True,
+ '10': {
+ '01': True,
+ '10': {
+ '01': True,
+ '10': {
+ '01': True,
+ '10': {
+ '01': True,
+ }}}}}}
+
+result = core.apply(
+ 'foursquare',
+ example,
+ update)
+
+plot_foursquare(result, filename="example2.png")
---------------------------------------------------------------------------- -FileNotFoundError Traceback (most recent call last) -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:79, in run_check(cmd, input_lines, encoding, quiet, **kwargs) - 78 kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE ----> 79 proc = _run_input_lines(cmd, input_lines, kwargs=kwargs) - 80 else: - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:99, in _run_input_lines(cmd, input_lines, kwargs) - 98 def _run_input_lines(cmd, input_lines, *, kwargs): ----> 99 popen = subprocess.Popen(cmd, stdin=subprocess.PIPE, **kwargs) - 101 stdin_write = popen.stdin.write - -File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group) - 1023 self.stderr = io.TextIOWrapper(self.stderr, - 1024 encoding=encoding, errors=errors) --> 1026 self._execute_child(args, executable, preexec_fn, close_fds, - 1027 pass_fds, cwd, env, - 1028 startupinfo, creationflags, shell, - 1029 p2cread, p2cwrite, - 1030 c2pread, c2pwrite, - 1031 errread, errwrite, - 1032 restore_signals, - 1033 gid, gids, uid, umask, - 1034 start_new_session, process_group) - 1035 except: - 1036 # Cleanup if the child failed starting. - -File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1950, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group) - 1949 err_msg = os.strerror(errno_num) --> 1950 raise child_exception_type(errno_num, err_msg, err_filename) - 1951 raise child_exception_type(err_msg) - -FileNotFoundError: [Errno 2] No such file or directory: PosixPath('dot') - -The above exception was the direct cause of the following exception: - -ExecutableNotFound Traceback (most recent call last) -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/IPython/core/formatters.py:974, in MimeBundleFormatter.__call__(self, obj, include, exclude) - 971 method = get_real_method(obj, self.print_method) - 973 if method is not None: ---> 974 return method(include=include, exclude=exclude) - 975 return None - 976 else: - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in JupyterIntegration._repr_mimebundle_(self, include, exclude, **_) - 96 include = set(include) if include is not None else {self._jupyter_mimetype} - 97 include -= set(exclude or []) ----> 98 return {mimetype: getattr(self, method_name)() - 99 for mimetype, method_name in MIME_TYPES.items() - 100 if mimetype in include} - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in <dictcomp>(.0) - 96 include = set(include) if include is not None else {self._jupyter_mimetype} - 97 include -= set(exclude or []) ----> 98 return {mimetype: getattr(self, method_name)() - 99 for mimetype, method_name in MIME_TYPES.items() - 100 if mimetype in include} - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:112, in JupyterIntegration._repr_image_svg_xml(self) - 110 def _repr_image_svg_xml(self) -> str: - 111 """Return the rendered graph as SVG string.""" ---> 112 return self.pipe(format='svg', encoding=SVG_ENCODING) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:104, in Pipe.pipe(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding) - 55 def pipe(self, - 56 format: typing.Optional[str] = None, - 57 renderer: typing.Optional[str] = None, - (...) - 61 engine: typing.Optional[str] = None, - 62 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]: - 63 """Return the source piped through the Graphviz layout command. - 64 - 65 Args: - (...) - 102 '<?xml version=' - 103 """ ---> 104 return self._pipe_legacy(format, - 105 renderer=renderer, - 106 formatter=formatter, - 107 neato_no_op=neato_no_op, - 108 quiet=quiet, - 109 engine=engine, - 110 encoding=encoding) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/_tools.py:171, in deprecate_positional_args.<locals>.decorator.<locals>.wrapper(*args, **kwargs) - 162 wanted = ', '.join(f'{name}={value!r}' - 163 for name, value in deprecated.items()) - 164 warnings.warn(f'The signature of {func.__name__} will be reduced' - 165 f' to {supported_number} positional args' - 166 f' {list(supported)}: pass {wanted}' - 167 ' as keyword arg(s)', - 168 stacklevel=stacklevel, - 169 category=category) ---> 171 return func(*args, **kwargs) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:121, in Pipe._pipe_legacy(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding) - 112 @_tools.deprecate_positional_args(supported_number=2) - 113 def _pipe_legacy(self, - 114 format: typing.Optional[str] = None, - (...) - 119 engine: typing.Optional[str] = None, - 120 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]: ---> 121 return self._pipe_future(format, - 122 renderer=renderer, - 123 formatter=formatter, - 124 neato_no_op=neato_no_op, - 125 quiet=quiet, - 126 engine=engine, - 127 encoding=encoding) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:149, in Pipe._pipe_future(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding) - 146 if encoding is not None: - 147 if codecs.lookup(encoding) is codecs.lookup(self.encoding): - 148 # common case: both stdin and stdout need the same encoding ---> 149 return self._pipe_lines_string(*args, encoding=encoding, **kwargs) - 150 try: - 151 raw = self._pipe_lines(*args, input_encoding=self.encoding, **kwargs) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/piping.py:212, in pipe_lines_string(engine, format, input_lines, encoding, renderer, formatter, neato_no_op, quiet) - 206 cmd = dot_command.command(engine, format, - 207 renderer=renderer, - 208 formatter=formatter, - 209 neato_no_op=neato_no_op) - 210 kwargs = {'input_lines': input_lines, 'encoding': encoding} ---> 212 proc = execute.run_check(cmd, capture_output=True, quiet=quiet, **kwargs) - 213 return proc.stdout - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:84, in run_check(cmd, input_lines, encoding, quiet, **kwargs) - 82 except OSError as e: - 83 if e.errno == errno.ENOENT: ----> 84 raise ExecutableNotFound(cmd) from e - 85 raise - 87 if not quiet and proc.stderr: - -ExecutableNotFound: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH+
<graphviz.graphs.Digraph at 0x7f6101d8d050>+
# plot_bigraph(example)
+
bigraph_state = {
@@ -8310,7 +8207,7 @@ Instance¶
'node2.2': 2.1
}
}
-plot_bigraph(bigraph_state, show_values=True)
+plot_bigraph(bigraph_state)
---------------------------------------------------------------------------- -FileNotFoundError Traceback (most recent call last) -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:79, in run_check(cmd, input_lines, encoding, quiet, **kwargs) - 78 kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE ----> 79 proc = _run_input_lines(cmd, input_lines, kwargs=kwargs) - 80 else: - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:99, in _run_input_lines(cmd, input_lines, kwargs) - 98 def _run_input_lines(cmd, input_lines, *, kwargs): ----> 99 popen = subprocess.Popen(cmd, stdin=subprocess.PIPE, **kwargs) - 101 stdin_write = popen.stdin.write - -File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group) - 1023 self.stderr = io.TextIOWrapper(self.stderr, - 1024 encoding=encoding, errors=errors) --> 1026 self._execute_child(args, executable, preexec_fn, close_fds, - 1027 pass_fds, cwd, env, - 1028 startupinfo, creationflags, shell, - 1029 p2cread, p2cwrite, - 1030 c2pread, c2pwrite, - 1031 errread, errwrite, - 1032 restore_signals, - 1033 gid, gids, uid, umask, - 1034 start_new_session, process_group) - 1035 except: - 1036 # Cleanup if the child failed starting. - -File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1950, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group) - 1949 err_msg = os.strerror(errno_num) --> 1950 raise child_exception_type(errno_num, err_msg, err_filename) - 1951 raise child_exception_type(err_msg) - -FileNotFoundError: [Errno 2] No such file or directory: PosixPath('dot') - -The above exception was the direct cause of the following exception: - -ExecutableNotFound Traceback (most recent call last) -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/IPython/core/formatters.py:974, in MimeBundleFormatter.__call__(self, obj, include, exclude) - 971 method = get_real_method(obj, self.print_method) - 973 if method is not None: ---> 974 return method(include=include, exclude=exclude) - 975 return None - 976 else: - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in JupyterIntegration._repr_mimebundle_(self, include, exclude, **_) - 96 include = set(include) if include is not None else {self._jupyter_mimetype} - 97 include -= set(exclude or []) ----> 98 return {mimetype: getattr(self, method_name)() - 99 for mimetype, method_name in MIME_TYPES.items() - 100 if mimetype in include} - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in <dictcomp>(.0) - 96 include = set(include) if include is not None else {self._jupyter_mimetype} - 97 include -= set(exclude or []) ----> 98 return {mimetype: getattr(self, method_name)() - 99 for mimetype, method_name in MIME_TYPES.items() - 100 if mimetype in include} - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:112, in JupyterIntegration._repr_image_svg_xml(self) - 110 def _repr_image_svg_xml(self) -> str: - 111 """Return the rendered graph as SVG string.""" ---> 112 return self.pipe(format='svg', encoding=SVG_ENCODING) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:104, in Pipe.pipe(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding) - 55 def pipe(self, - 56 format: typing.Optional[str] = None, - 57 renderer: typing.Optional[str] = None, - (...) - 61 engine: typing.Optional[str] = None, - 62 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]: - 63 """Return the source piped through the Graphviz layout command. - 64 - 65 Args: - (...) - 102 '<?xml version=' - 103 """ ---> 104 return self._pipe_legacy(format, - 105 renderer=renderer, - 106 formatter=formatter, - 107 neato_no_op=neato_no_op, - 108 quiet=quiet, - 109 engine=engine, - 110 encoding=encoding) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/_tools.py:171, in deprecate_positional_args.<locals>.decorator.<locals>.wrapper(*args, **kwargs) - 162 wanted = ', '.join(f'{name}={value!r}' - 163 for name, value in deprecated.items()) - 164 warnings.warn(f'The signature of {func.__name__} will be reduced' - 165 f' to {supported_number} positional args' - 166 f' {list(supported)}: pass {wanted}' - 167 ' as keyword arg(s)', - 168 stacklevel=stacklevel, - 169 category=category) ---> 171 return func(*args, **kwargs) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:121, in Pipe._pipe_legacy(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding) - 112 @_tools.deprecate_positional_args(supported_number=2) - 113 def _pipe_legacy(self, - 114 format: typing.Optional[str] = None, - (...) - 119 engine: typing.Optional[str] = None, - 120 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]: ---> 121 return self._pipe_future(format, - 122 renderer=renderer, - 123 formatter=formatter, - 124 neato_no_op=neato_no_op, - 125 quiet=quiet, - 126 engine=engine, - 127 encoding=encoding) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:149, in Pipe._pipe_future(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding) - 146 if encoding is not None: - 147 if codecs.lookup(encoding) is codecs.lookup(self.encoding): - 148 # common case: both stdin and stdout need the same encoding ---> 149 return self._pipe_lines_string(*args, encoding=encoding, **kwargs) - 150 try: - 151 raw = self._pipe_lines(*args, input_encoding=self.encoding, **kwargs) - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/piping.py:212, in pipe_lines_string(engine, format, input_lines, encoding, renderer, formatter, neato_no_op, quiet) - 206 cmd = dot_command.command(engine, format, - 207 renderer=renderer, - 208 formatter=formatter, - 209 neato_no_op=neato_no_op) - 210 kwargs = {'input_lines': input_lines, 'encoding': encoding} ---> 212 proc = execute.run_check(cmd, capture_output=True, quiet=quiet, **kwargs) - 213 return proc.stdout - -File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:84, in run_check(cmd, input_lines, encoding, quiet, **kwargs) - 82 except OSError as e: - 83 if e.errno == errno.ENOENT: ----> 84 raise ExecutableNotFound(cmd) from e - 85 raise - 87 if not quiet and proc.stderr: - -ExecutableNotFound: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH-
<graphviz.graphs.Digraph at 0x7f61024e9990>+
dual_edge_schema = {
@@ -8505,7 +8261,7 @@ Fill state¶
},
}
-types.type_registry.register('dual_edge', dual_edge_schema, force=True)
+core.type_registry.register('dual_edge', dual_edge_schema, force=True)
schema = {
'store1': 'dual_edge',
@@ -8538,8 +8294,8 @@ Fill state¶
}
},
}
-filled_instance = types.fill(schema, instance)
-filled_schema = types.type_registry.access(schema)
+filled_instance = core.fill(schema, instance)
+filled_schema = core.type_registry.access(schema)
print(f'schema:\n {pf(schema)}\n')
@@ -8574,16 +8330,22 @@ Fill state¶
'store1': 'dual_edge'}
instance:
- { 'edge3': {'wires': {'port1': 'store1'}},
- 'store1': { 'edge1': {'wires': {'port1': 'store1.1', 'port2': 'store1.2'}},
- 'edge2': {'wires': {'port1': 'store1.1', 'port2': 'store1.2'}}}}
+ { 'edge3': {'inputs': {}, 'outputs': {}, 'wires': {'port1': 'store1'}},
+ 'store1': { 'edge1': { 'inputs': {},
+ 'outputs': {},
+ 'wires': {'port1': 'store1.1', 'port2': 'store1.2'}},
+ 'edge2': { 'inputs': {},
+ 'outputs': {},
+ 'wires': {'port1': 'store1.1', 'port2': 'store1.2'}}}}
filled instance:
- { 'edge3': {'wires': {'port1': 'store1'}},
- 'store1': { 'edge1': {'wires': {'port1': 'store1.1', 'port2': 'store1.2'}},
- 'edge2': {'wires': {'port1': 'store1.1', 'port2': 'store1.2'}},
- 'store1.1': 0.0,
- 'store1.2': 0}}
+ { 'edge3': {'inputs': {}, 'outputs': {}, 'wires': {'port1': 'store1'}},
+ 'store1': { 'edge1': { 'inputs': {},
+ 'outputs': {},
+ 'wires': {'port1': 'store1.1', 'port2': 'store1.2'}},
+ 'edge2': { 'inputs': {},
+ 'outputs': {},
+ 'wires': {'port1': 'store1.1', 'port2': 'store1.2'}}}}
plot_bigraph(filled_instance, remove_process_place_edges=True, port_labels=False)
@@ -8608,151 +8370,10 @@ Fill state¶
-
-
-
-
----------------------------------------------------------------------------
-FileNotFoundError Traceback (most recent call last)
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:79, in run_check(cmd, input_lines, encoding, quiet, **kwargs)
- 78 kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE
----> 79 proc = _run_input_lines(cmd, input_lines, kwargs=kwargs)
- 80 else:
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:99, in _run_input_lines(cmd, input_lines, kwargs)
- 98 def _run_input_lines(cmd, input_lines, *, kwargs):
----> 99 popen = subprocess.Popen(cmd, stdin=subprocess.PIPE, **kwargs)
- 101 stdin_write = popen.stdin.write
-
-File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
- 1023 self.stderr = io.TextIOWrapper(self.stderr,
- 1024 encoding=encoding, errors=errors)
--> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
- 1027 pass_fds, cwd, env,
- 1028 startupinfo, creationflags, shell,
- 1029 p2cread, p2cwrite,
- 1030 c2pread, c2pwrite,
- 1031 errread, errwrite,
- 1032 restore_signals,
- 1033 gid, gids, uid, umask,
- 1034 start_new_session, process_group)
- 1035 except:
- 1036 # Cleanup if the child failed starting.
-
-File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1950, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
- 1949 err_msg = os.strerror(errno_num)
--> 1950 raise child_exception_type(errno_num, err_msg, err_filename)
- 1951 raise child_exception_type(err_msg)
-
-FileNotFoundError: [Errno 2] No such file or directory: PosixPath('dot')
-
-The above exception was the direct cause of the following exception:
-
-ExecutableNotFound Traceback (most recent call last)
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/IPython/core/formatters.py:974, in MimeBundleFormatter.__call__(self, obj, include, exclude)
- 971 method = get_real_method(obj, self.print_method)
- 973 if method is not None:
---> 974 return method(include=include, exclude=exclude)
- 975 return None
- 976 else:
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in JupyterIntegration._repr_mimebundle_(self, include, exclude, **_)
- 96 include = set(include) if include is not None else {self._jupyter_mimetype}
- 97 include -= set(exclude or [])
----> 98 return {mimetype: getattr(self, method_name)()
- 99 for mimetype, method_name in MIME_TYPES.items()
- 100 if mimetype in include}
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in <dictcomp>(.0)
- 96 include = set(include) if include is not None else {self._jupyter_mimetype}
- 97 include -= set(exclude or [])
----> 98 return {mimetype: getattr(self, method_name)()
- 99 for mimetype, method_name in MIME_TYPES.items()
- 100 if mimetype in include}
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:112, in JupyterIntegration._repr_image_svg_xml(self)
- 110 def _repr_image_svg_xml(self) -> str:
- 111 """Return the rendered graph as SVG string."""
---> 112 return self.pipe(format='svg', encoding=SVG_ENCODING)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:104, in Pipe.pipe(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
- 55 def pipe(self,
- 56 format: typing.Optional[str] = None,
- 57 renderer: typing.Optional[str] = None,
- (...)
- 61 engine: typing.Optional[str] = None,
- 62 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]:
- 63 """Return the source piped through the Graphviz layout command.
- 64
- 65 Args:
- (...)
- 102 '<?xml version='
- 103 """
---> 104 return self._pipe_legacy(format,
- 105 renderer=renderer,
- 106 formatter=formatter,
- 107 neato_no_op=neato_no_op,
- 108 quiet=quiet,
- 109 engine=engine,
- 110 encoding=encoding)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/_tools.py:171, in deprecate_positional_args.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
- 162 wanted = ', '.join(f'{name}={value!r}'
- 163 for name, value in deprecated.items())
- 164 warnings.warn(f'The signature of {func.__name__} will be reduced'
- 165 f' to {supported_number} positional args'
- 166 f' {list(supported)}: pass {wanted}'
- 167 ' as keyword arg(s)',
- 168 stacklevel=stacklevel,
- 169 category=category)
---> 171 return func(*args, **kwargs)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:121, in Pipe._pipe_legacy(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
- 112 @_tools.deprecate_positional_args(supported_number=2)
- 113 def _pipe_legacy(self,
- 114 format: typing.Optional[str] = None,
- (...)
- 119 engine: typing.Optional[str] = None,
- 120 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]:
---> 121 return self._pipe_future(format,
- 122 renderer=renderer,
- 123 formatter=formatter,
- 124 neato_no_op=neato_no_op,
- 125 quiet=quiet,
- 126 engine=engine,
- 127 encoding=encoding)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:149, in Pipe._pipe_future(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
- 146 if encoding is not None:
- 147 if codecs.lookup(encoding) is codecs.lookup(self.encoding):
- 148 # common case: both stdin and stdout need the same encoding
---> 149 return self._pipe_lines_string(*args, encoding=encoding, **kwargs)
- 150 try:
- 151 raw = self._pipe_lines(*args, input_encoding=self.encoding, **kwargs)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/piping.py:212, in pipe_lines_string(engine, format, input_lines, encoding, renderer, formatter, neato_no_op, quiet)
- 206 cmd = dot_command.command(engine, format,
- 207 renderer=renderer,
- 208 formatter=formatter,
- 209 neato_no_op=neato_no_op)
- 210 kwargs = {'input_lines': input_lines, 'encoding': encoding}
---> 212 proc = execute.run_check(cmd, capture_output=True, quiet=quiet, **kwargs)
- 213 return proc.stdout
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:84, in run_check(cmd, input_lines, encoding, quiet, **kwargs)
- 82 except OSError as e:
- 83 if e.errno == errno.ENOENT:
----> 84 raise ExecutableNotFound(cmd) from e
- 85 raise
- 87 if not quiet and proc.stderr:
-
-ExecutableNotFound: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH
-
-
-Out[17]:
-
-<graphviz.graphs.Digraph at 0x7f61015e7950>
+Out[18]:
+
+
@@ -8773,7 +8394,7 @@ Update¶
-In [18]:
+In [19]:
place_schema = {
@@ -8797,151 +8418,10 @@ Update¶
-
-
-
-
----------------------------------------------------------------------------
-FileNotFoundError Traceback (most recent call last)
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:79, in run_check(cmd, input_lines, encoding, quiet, **kwargs)
- 78 kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE
----> 79 proc = _run_input_lines(cmd, input_lines, kwargs=kwargs)
- 80 else:
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:99, in _run_input_lines(cmd, input_lines, kwargs)
- 98 def _run_input_lines(cmd, input_lines, *, kwargs):
----> 99 popen = subprocess.Popen(cmd, stdin=subprocess.PIPE, **kwargs)
- 101 stdin_write = popen.stdin.write
-
-File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
- 1023 self.stderr = io.TextIOWrapper(self.stderr,
- 1024 encoding=encoding, errors=errors)
--> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
- 1027 pass_fds, cwd, env,
- 1028 startupinfo, creationflags, shell,
- 1029 p2cread, p2cwrite,
- 1030 c2pread, c2pwrite,
- 1031 errread, errwrite,
- 1032 restore_signals,
- 1033 gid, gids, uid, umask,
- 1034 start_new_session, process_group)
- 1035 except:
- 1036 # Cleanup if the child failed starting.
-
-File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1950, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
- 1949 err_msg = os.strerror(errno_num)
--> 1950 raise child_exception_type(errno_num, err_msg, err_filename)
- 1951 raise child_exception_type(err_msg)
-
-FileNotFoundError: [Errno 2] No such file or directory: PosixPath('dot')
-
-The above exception was the direct cause of the following exception:
-
-ExecutableNotFound Traceback (most recent call last)
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/IPython/core/formatters.py:974, in MimeBundleFormatter.__call__(self, obj, include, exclude)
- 971 method = get_real_method(obj, self.print_method)
- 973 if method is not None:
---> 974 return method(include=include, exclude=exclude)
- 975 return None
- 976 else:
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in JupyterIntegration._repr_mimebundle_(self, include, exclude, **_)
- 96 include = set(include) if include is not None else {self._jupyter_mimetype}
- 97 include -= set(exclude or [])
----> 98 return {mimetype: getattr(self, method_name)()
- 99 for mimetype, method_name in MIME_TYPES.items()
- 100 if mimetype in include}
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in <dictcomp>(.0)
- 96 include = set(include) if include is not None else {self._jupyter_mimetype}
- 97 include -= set(exclude or [])
----> 98 return {mimetype: getattr(self, method_name)()
- 99 for mimetype, method_name in MIME_TYPES.items()
- 100 if mimetype in include}
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:112, in JupyterIntegration._repr_image_svg_xml(self)
- 110 def _repr_image_svg_xml(self) -> str:
- 111 """Return the rendered graph as SVG string."""
---> 112 return self.pipe(format='svg', encoding=SVG_ENCODING)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:104, in Pipe.pipe(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
- 55 def pipe(self,
- 56 format: typing.Optional[str] = None,
- 57 renderer: typing.Optional[str] = None,
- (...)
- 61 engine: typing.Optional[str] = None,
- 62 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]:
- 63 """Return the source piped through the Graphviz layout command.
- 64
- 65 Args:
- (...)
- 102 '<?xml version='
- 103 """
---> 104 return self._pipe_legacy(format,
- 105 renderer=renderer,
- 106 formatter=formatter,
- 107 neato_no_op=neato_no_op,
- 108 quiet=quiet,
- 109 engine=engine,
- 110 encoding=encoding)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/_tools.py:171, in deprecate_positional_args.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
- 162 wanted = ', '.join(f'{name}={value!r}'
- 163 for name, value in deprecated.items())
- 164 warnings.warn(f'The signature of {func.__name__} will be reduced'
- 165 f' to {supported_number} positional args'
- 166 f' {list(supported)}: pass {wanted}'
- 167 ' as keyword arg(s)',
- 168 stacklevel=stacklevel,
- 169 category=category)
---> 171 return func(*args, **kwargs)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:121, in Pipe._pipe_legacy(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
- 112 @_tools.deprecate_positional_args(supported_number=2)
- 113 def _pipe_legacy(self,
- 114 format: typing.Optional[str] = None,
- (...)
- 119 engine: typing.Optional[str] = None,
- 120 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]:
---> 121 return self._pipe_future(format,
- 122 renderer=renderer,
- 123 formatter=formatter,
- 124 neato_no_op=neato_no_op,
- 125 quiet=quiet,
- 126 engine=engine,
- 127 encoding=encoding)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:149, in Pipe._pipe_future(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
- 146 if encoding is not None:
- 147 if codecs.lookup(encoding) is codecs.lookup(self.encoding):
- 148 # common case: both stdin and stdout need the same encoding
---> 149 return self._pipe_lines_string(*args, encoding=encoding, **kwargs)
- 150 try:
- 151 raw = self._pipe_lines(*args, input_encoding=self.encoding, **kwargs)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/piping.py:212, in pipe_lines_string(engine, format, input_lines, encoding, renderer, formatter, neato_no_op, quiet)
- 206 cmd = dot_command.command(engine, format,
- 207 renderer=renderer,
- 208 formatter=formatter,
- 209 neato_no_op=neato_no_op)
- 210 kwargs = {'input_lines': input_lines, 'encoding': encoding}
---> 212 proc = execute.run_check(cmd, capture_output=True, quiet=quiet, **kwargs)
- 213 return proc.stdout
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:84, in run_check(cmd, input_lines, encoding, quiet, **kwargs)
- 82 except OSError as e:
- 83 if e.errno == errno.ENOENT:
----> 84 raise ExecutableNotFound(cmd) from e
- 85 raise
- 87 if not quiet and proc.stderr:
-
-ExecutableNotFound: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH
-
-
-Out[18]:
-
-<graphviz.graphs.Digraph at 0x7f610159cd50>
+Out[19]:
+
+
@@ -8951,7 +8431,7 @@ Update¶
-In [19]:
+In [21]:
update = {
@@ -8962,7 +8442,7 @@ Update¶
}
}
-place_state2 = types.apply(
+place_state2 = core.apply(
place_schema,
place_state1,
update
@@ -8977,151 +8457,10 @@ Update¶
-
-
-
-
----------------------------------------------------------------------------
-FileNotFoundError Traceback (most recent call last)
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:79, in run_check(cmd, input_lines, encoding, quiet, **kwargs)
- 78 kwargs['stdout'] = kwargs['stderr'] = subprocess.PIPE
----> 79 proc = _run_input_lines(cmd, input_lines, kwargs=kwargs)
- 80 else:
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:99, in _run_input_lines(cmd, input_lines, kwargs)
- 98 def _run_input_lines(cmd, input_lines, *, kwargs):
----> 99 popen = subprocess.Popen(cmd, stdin=subprocess.PIPE, **kwargs)
- 101 stdin_write = popen.stdin.write
-
-File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
- 1023 self.stderr = io.TextIOWrapper(self.stderr,
- 1024 encoding=encoding, errors=errors)
--> 1026 self._execute_child(args, executable, preexec_fn, close_fds,
- 1027 pass_fds, cwd, env,
- 1028 startupinfo, creationflags, shell,
- 1029 p2cread, p2cwrite,
- 1030 c2pread, c2pwrite,
- 1031 errread, errwrite,
- 1032 restore_signals,
- 1033 gid, gids, uid, umask,
- 1034 start_new_session, process_group)
- 1035 except:
- 1036 # Cleanup if the child failed starting.
-
-File ~/.pyenv/versions/3.11.4/lib/python3.11/subprocess.py:1950, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
- 1949 err_msg = os.strerror(errno_num)
--> 1950 raise child_exception_type(errno_num, err_msg, err_filename)
- 1951 raise child_exception_type(err_msg)
-
-FileNotFoundError: [Errno 2] No such file or directory: PosixPath('dot')
-
-The above exception was the direct cause of the following exception:
-
-ExecutableNotFound Traceback (most recent call last)
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/IPython/core/formatters.py:974, in MimeBundleFormatter.__call__(self, obj, include, exclude)
- 971 method = get_real_method(obj, self.print_method)
- 973 if method is not None:
---> 974 return method(include=include, exclude=exclude)
- 975 return None
- 976 else:
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in JupyterIntegration._repr_mimebundle_(self, include, exclude, **_)
- 96 include = set(include) if include is not None else {self._jupyter_mimetype}
- 97 include -= set(exclude or [])
----> 98 return {mimetype: getattr(self, method_name)()
- 99 for mimetype, method_name in MIME_TYPES.items()
- 100 if mimetype in include}
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:98, in <dictcomp>(.0)
- 96 include = set(include) if include is not None else {self._jupyter_mimetype}
- 97 include -= set(exclude or [])
----> 98 return {mimetype: getattr(self, method_name)()
- 99 for mimetype, method_name in MIME_TYPES.items()
- 100 if mimetype in include}
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/jupyter_integration.py:112, in JupyterIntegration._repr_image_svg_xml(self)
- 110 def _repr_image_svg_xml(self) -> str:
- 111 """Return the rendered graph as SVG string."""
---> 112 return self.pipe(format='svg', encoding=SVG_ENCODING)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:104, in Pipe.pipe(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
- 55 def pipe(self,
- 56 format: typing.Optional[str] = None,
- 57 renderer: typing.Optional[str] = None,
- (...)
- 61 engine: typing.Optional[str] = None,
- 62 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]:
- 63 """Return the source piped through the Graphviz layout command.
- 64
- 65 Args:
- (...)
- 102 '<?xml version='
- 103 """
---> 104 return self._pipe_legacy(format,
- 105 renderer=renderer,
- 106 formatter=formatter,
- 107 neato_no_op=neato_no_op,
- 108 quiet=quiet,
- 109 engine=engine,
- 110 encoding=encoding)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/_tools.py:171, in deprecate_positional_args.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
- 162 wanted = ', '.join(f'{name}={value!r}'
- 163 for name, value in deprecated.items())
- 164 warnings.warn(f'The signature of {func.__name__} will be reduced'
- 165 f' to {supported_number} positional args'
- 166 f' {list(supported)}: pass {wanted}'
- 167 ' as keyword arg(s)',
- 168 stacklevel=stacklevel,
- 169 category=category)
---> 171 return func(*args, **kwargs)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:121, in Pipe._pipe_legacy(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
- 112 @_tools.deprecate_positional_args(supported_number=2)
- 113 def _pipe_legacy(self,
- 114 format: typing.Optional[str] = None,
- (...)
- 119 engine: typing.Optional[str] = None,
- 120 encoding: typing.Optional[str] = None) -> typing.Union[bytes, str]:
---> 121 return self._pipe_future(format,
- 122 renderer=renderer,
- 123 formatter=formatter,
- 124 neato_no_op=neato_no_op,
- 125 quiet=quiet,
- 126 engine=engine,
- 127 encoding=encoding)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/piping.py:149, in Pipe._pipe_future(self, format, renderer, formatter, neato_no_op, quiet, engine, encoding)
- 146 if encoding is not None:
- 147 if codecs.lookup(encoding) is codecs.lookup(self.encoding):
- 148 # common case: both stdin and stdout need the same encoding
---> 149 return self._pipe_lines_string(*args, encoding=encoding, **kwargs)
- 150 try:
- 151 raw = self._pipe_lines(*args, input_encoding=self.encoding, **kwargs)
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/piping.py:212, in pipe_lines_string(engine, format, input_lines, encoding, renderer, formatter, neato_no_op, quiet)
- 206 cmd = dot_command.command(engine, format,
- 207 renderer=renderer,
- 208 formatter=formatter,
- 209 neato_no_op=neato_no_op)
- 210 kwargs = {'input_lines': input_lines, 'encoding': encoding}
---> 212 proc = execute.run_check(cmd, capture_output=True, quiet=quiet, **kwargs)
- 213 return proc.stdout
-
-File ~/.pyenv/versions/3.11.4/envs/bigraph-schema/lib/python3.11/site-packages/graphviz/backend/execute.py:84, in run_check(cmd, input_lines, encoding, quiet, **kwargs)
- 82 except OSError as e:
- 83 if e.errno == errno.ENOENT:
----> 84 raise ExecutableNotFound(cmd) from e
- 85 raise
- 87 if not quiet and proc.stderr:
-
-ExecutableNotFound: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH
-
-
-Out[19]:
-
-<graphviz.graphs.Digraph at 0x7f610158ac10>
+Out[21]:
+
+
@@ -9131,7 +8470,7 @@ Update¶
-In [20]:
+In [22]:
# update = {
@@ -9149,7 +8488,7 @@ Update¶
],
}
-place_state3 = types.apply(
+place_state3 = core.apply(
place_schema,
place_state2,
update
@@ -9170,7 +8509,7 @@ Update¶
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
-Cell In[20], line 16
+Cell In[22], line 16
1 # update = {
2 # '_remove': ['node1'],
3 # 'node2': {
@@ -9183,53 +8522,52 @@ Update¶
12 ['node2', 'node2.2'],
13 ],
14 }
----> 16 place_state3 = types.apply(
+---> 16 place_state3 = core.apply(
17 place_schema,
18 place_state2,
19 update
20 )
21 plot_bigraph(place_state2, show_values=True)
-File ~/code/bigraph-schema/bigraph_schema/type_schema.py:214, in TypeSchema.apply(self, original_schema, initial, update)
- 212 schema = self.access(original_schema)
- 213 state = copy.deepcopy(initial)
---> 214 return self.apply_update(schema, initial, update)
-
-File ~/code/bigraph-schema/bigraph_schema/type_schema.py:183, in TypeSchema.apply_update(self, schema, state, update)
- 180 if '_apply' in schema:
- 181 apply_function = self.apply_registry.access(schema['_apply'])
---> 183 state = apply_function(
- 184 state,
- 185 update,
- 186 schema.get('_bindings'),
- 187 self)
- 189 elif isinstance(schema, str) or isinstance(schema, list):
- 190 schema = self.access(schema)
-
-File ~/code/bigraph-schema/bigraph_schema/base_types.py:241, in apply_tree(current, update, bindings, types)
- 239 current.update(branch)
- 240 elif key == '_remove':
---> 241 current = remove_path(current, branch)
- 242 else:
- 243 current[key] = apply_tree(
- 244 current.get(key),
- 245 branch,
- 246 bindings,
- 247 types)
-
-File ~/code/bigraph-schema/bigraph_schema/registry.py:176, in remove_path(tree, path)
- 173 if path is None or len(path) == 0:
- 174 return None
---> 176 upon = get_path(tree, path[:-1])
- 177 if upon is not None:
- 178 del upon[path[-1]]
-
-File ~/code/bigraph-schema/bigraph_schema/registry.py:126, in get_path(tree, path)
- 124 else:
- 125 head = path[0]
---> 126 if head not in tree:
- 127 return None
- 128 else:
+File ~/code/bigraph-schema/bigraph_schema/type_system.py:415, in TypeSystem.apply(self, original_schema, initial, update)
+ 413 schema = self.access(original_schema)
+ 414 state = copy.deepcopy(initial)
+--> 415 return self.apply_update(schema, state, update)
+
+File ~/code/bigraph-schema/bigraph_schema/type_system.py:381, in TypeSystem.apply_update(self, schema, state, update)
+ 378 elif '_apply' in schema and schema['_apply'] != 'any':
+ 379 apply_function = self.type_registry.apply_registry.access(schema['_apply'])
+--> 381 state = apply_function(
+ 382 state,
+ 383 update,
+ 384 schema.get('_bindings'),
+ 385 self)
+ 387 elif isinstance(schema, str) or isinstance(schema, list):
+ 388 schema = self.access(schema)
+
+File ~/code/bigraph-schema/bigraph_schema/registry.py:391, in apply_tree(current, update, bindings, core)
+ 389 current.update(branch)
+ 390 elif key == '_remove':
+--> 391 current = remove_path(current, branch)
+ 392 elif core.check(leaf_type, branch):
+ 393 current[key] = core.apply(
+ 394 leaf_type,
+ 395 current.get(key),
+ 396 branch)
+
+File ~/code/bigraph-schema/bigraph_schema/registry.py:311, in remove_path(tree, path)
+ 308 if path is None or len(path) == 0:
+ 309 return None
+--> 311 upon = get_path(tree, path[:-1])
+ 312 if upon is not None:
+ 313 del upon[path[-1]]
+
+File ~/code/bigraph-schema/bigraph_schema/registry.py:178, in get_path(tree, path)
+ 176 else:
+ 177 head = path[0]
+--> 178 if not tree or head not in tree:
+ 179 return None
+ 180 else:
TypeError: unhashable type: 'list'