bigraph-schema 0.0.55__tar.gz → 0.0.56__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bigraph-schema might be problematic. Click here for more details.
- {bigraph-schema-0.0.55/bigraph_schema.egg-info → bigraph-schema-0.0.56}/PKG-INFO +1 -5
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/type_functions.py +131 -6
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/type_system.py +1 -11
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56/bigraph_schema.egg-info}/PKG-INFO +1 -5
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/setup.py +1 -1
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/AUTHORS.md +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/LICENSE +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/README.md +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/__init__.py +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/edge.py +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/parse.py +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/protocols.py +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/registry.py +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/type_system_tests.py +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/units.py +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema/utilities.py +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema.egg-info/SOURCES.txt +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema.egg-info/dependency_links.txt +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema.egg-info/requires.txt +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema.egg-info/top_level.txt +0 -0
- {bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/setup.cfg +0 -0
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bigraph-schema
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.56
|
|
4
4
|
Summary: A serializable type schema for compositional systems biology
|
|
5
5
|
Home-page: https://github.com/vivarium-collective/bigraph-schema
|
|
6
6
|
Author: Eran Agmon, Ryan Spangler
|
|
7
7
|
Author-email: agmon.eran@gmail.com, ryan.spangler@gmail.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Platform: UNKNOWN
|
|
10
8
|
Classifier: Development Status :: 3 - Alpha
|
|
11
9
|
Classifier: Intended Audience :: Developers
|
|
12
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -53,5 +51,3 @@ This resource will guide you through the core concepts and methods, helping you
|
|
|
53
51
|
## License
|
|
54
52
|
|
|
55
53
|
Bigraph-schema is open-source software released under the [Apache 2 License](https://github.com/vivarium-collective/bigraph-schema/blob/main/LICENSE).
|
|
56
|
-
|
|
57
|
-
|
|
@@ -75,6 +75,7 @@ import typing
|
|
|
75
75
|
from typing import NewType, Union, Mapping, List, Dict, Optional, Callable
|
|
76
76
|
from dataclasses import field, make_dataclass
|
|
77
77
|
|
|
78
|
+
from bigraph_schema import get_path, set_path
|
|
78
79
|
from bigraph_schema.units import units, render_units_type
|
|
79
80
|
from bigraph_schema.registry import (
|
|
80
81
|
is_schema_key, non_schema_keys, type_parameter_key, deep_merge, hierarchy_depth, establish_path
|
|
@@ -1083,8 +1084,50 @@ def serialize_edge(schema, value, core):
|
|
|
1083
1084
|
def serialize_enum(schema, value, core):
|
|
1084
1085
|
return value
|
|
1085
1086
|
|
|
1087
|
+
def recur_serialize_schema(schema, core, path=None, parents=None):
|
|
1088
|
+
""" Serialize schema to a string """
|
|
1089
|
+
path = path or []
|
|
1090
|
+
parents = parents or []
|
|
1091
|
+
schema_id = id(schema)
|
|
1092
|
+
|
|
1093
|
+
if schema_id in parents:
|
|
1094
|
+
index = parents.index(schema_id)
|
|
1095
|
+
reference = path[:index]
|
|
1096
|
+
output = '/'.join(reference)
|
|
1097
|
+
return f'/{output}'
|
|
1098
|
+
|
|
1099
|
+
if isinstance(schema, str):
|
|
1100
|
+
return schema
|
|
1101
|
+
|
|
1102
|
+
elif isinstance(schema, tuple):
|
|
1103
|
+
inner = [
|
|
1104
|
+
recur_serialize_schema(
|
|
1105
|
+
schema=element,
|
|
1106
|
+
core=core,
|
|
1107
|
+
path=path+[index],
|
|
1108
|
+
parents=parents+[schema_id])
|
|
1109
|
+
for index, element in enumerate(schema)]
|
|
1110
|
+
|
|
1111
|
+
return inner
|
|
1112
|
+
|
|
1113
|
+
elif isinstance(schema, dict):
|
|
1114
|
+
inner = {}
|
|
1115
|
+
for key in schema:
|
|
1116
|
+
subschema = recur_serialize_schema(
|
|
1117
|
+
schema=schema[key],
|
|
1118
|
+
core=core,
|
|
1119
|
+
path=path+[key],
|
|
1120
|
+
parents=parents+[schema_id])
|
|
1121
|
+
inner[key] = subschema
|
|
1122
|
+
|
|
1123
|
+
return inner
|
|
1124
|
+
|
|
1125
|
+
else:
|
|
1126
|
+
return schema
|
|
1127
|
+
|
|
1086
1128
|
def serialize_schema(schema, state, core):
|
|
1087
|
-
|
|
1129
|
+
""" Serialize schema to a string """
|
|
1130
|
+
return recur_serialize_schema(schema=state, core=core)
|
|
1088
1131
|
|
|
1089
1132
|
def serialize_array(schema, value, core):
|
|
1090
1133
|
""" Serialize numpy array to list """
|
|
@@ -1229,6 +1272,9 @@ def deserialize_maybe(schema, encoded, core):
|
|
|
1229
1272
|
|
|
1230
1273
|
return core.deserialize(value_type, encoded)
|
|
1231
1274
|
|
|
1275
|
+
def deserialize_quote(schema, state, core):
|
|
1276
|
+
return state
|
|
1277
|
+
|
|
1232
1278
|
def deserialize_boolean(schema, encoded, core) -> bool:
|
|
1233
1279
|
if encoded == 'true':
|
|
1234
1280
|
return True
|
|
@@ -1313,8 +1359,52 @@ def deserialize_array(schema, encoded, core):
|
|
|
1313
1359
|
def deserialize_edge(schema, encoded, core):
|
|
1314
1360
|
return encoded
|
|
1315
1361
|
|
|
1362
|
+
def recur_deserialize_schema(schema, core, top_state=None, path=None):
|
|
1363
|
+
top_state = top_state or schema
|
|
1364
|
+
path = path or []
|
|
1365
|
+
|
|
1366
|
+
if isinstance(schema, dict):
|
|
1367
|
+
subschema = {}
|
|
1368
|
+
for key, value in schema.items():
|
|
1369
|
+
subschema[key] = recur_deserialize_schema(
|
|
1370
|
+
value,
|
|
1371
|
+
core,
|
|
1372
|
+
top_state=top_state,
|
|
1373
|
+
path=path+[key])
|
|
1374
|
+
|
|
1375
|
+
return subschema
|
|
1376
|
+
|
|
1377
|
+
elif isinstance(schema, list):
|
|
1378
|
+
subschema = []
|
|
1379
|
+
for index, value in enumerate(schema):
|
|
1380
|
+
subschema.append(
|
|
1381
|
+
recur_deserialize_schema(
|
|
1382
|
+
value,
|
|
1383
|
+
core,
|
|
1384
|
+
top_state=top_state,
|
|
1385
|
+
path=path+[index]))
|
|
1386
|
+
|
|
1387
|
+
return tuple(subschema)
|
|
1388
|
+
|
|
1389
|
+
elif isinstance(schema, str):
|
|
1390
|
+
if schema.startswith('/'): # this is a reference to another schema
|
|
1391
|
+
local_path = schema.split('/')[1:]
|
|
1392
|
+
reference = get_path(top_state, local_path)
|
|
1393
|
+
|
|
1394
|
+
set_path(
|
|
1395
|
+
tree=top_state,
|
|
1396
|
+
path=path,
|
|
1397
|
+
value=reference)
|
|
1398
|
+
|
|
1399
|
+
return reference
|
|
1400
|
+
else:
|
|
1401
|
+
return schema
|
|
1402
|
+
else:
|
|
1403
|
+
return schema
|
|
1404
|
+
|
|
1405
|
+
|
|
1316
1406
|
def deserialize_schema(schema, state, core):
|
|
1317
|
-
return state
|
|
1407
|
+
return recur_deserialize_schema(schema=state, core=core)
|
|
1318
1408
|
|
|
1319
1409
|
|
|
1320
1410
|
# =========================
|
|
@@ -2061,6 +2151,8 @@ def generate_any(core, schema, state, top_schema=None, top_state=None, path=None
|
|
|
2061
2151
|
generated_state)
|
|
2062
2152
|
|
|
2063
2153
|
else:
|
|
2154
|
+
if not core.check(schema, state):
|
|
2155
|
+
state = core.deserialize(schema, state)
|
|
2064
2156
|
generated_schema, generated_state = schema, state
|
|
2065
2157
|
|
|
2066
2158
|
return generated_schema, generated_state, top_schema, top_state
|
|
@@ -2076,10 +2168,6 @@ def default_quote(schema, core):
|
|
|
2076
2168
|
return None
|
|
2077
2169
|
|
|
2078
2170
|
|
|
2079
|
-
def deserialize_quote(schema, state, core):
|
|
2080
|
-
return state
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
2171
|
def generate_map(core, schema, state, top_schema=None, top_state=None, path=None):
|
|
2084
2172
|
schema = schema or {}
|
|
2085
2173
|
state = state or core.default(schema)
|
|
@@ -2322,9 +2410,45 @@ def sort_any(core, schema, state):
|
|
|
2322
2410
|
|
|
2323
2411
|
return merged_schema, merged_state
|
|
2324
2412
|
|
|
2413
|
+
|
|
2325
2414
|
def sort_quote(core, schema, state):
|
|
2326
2415
|
return schema, state
|
|
2327
2416
|
|
|
2417
|
+
|
|
2418
|
+
def sort_map(core, schema, state):
|
|
2419
|
+
if not isinstance(schema, dict):
|
|
2420
|
+
schema = core.find(schema)
|
|
2421
|
+
if not isinstance(state, dict):
|
|
2422
|
+
return schema, state
|
|
2423
|
+
|
|
2424
|
+
merged_schema = {}
|
|
2425
|
+
merged_state = {}
|
|
2426
|
+
|
|
2427
|
+
value_schema = core.find_parameter(
|
|
2428
|
+
schema,
|
|
2429
|
+
'value')
|
|
2430
|
+
|
|
2431
|
+
for key in union_keys(schema, state):
|
|
2432
|
+
if is_schema_key(key):
|
|
2433
|
+
if key in state:
|
|
2434
|
+
merged_schema[key] = core.merge_schemas(
|
|
2435
|
+
schema.get(key, {}),
|
|
2436
|
+
state[key])
|
|
2437
|
+
else:
|
|
2438
|
+
merged_schema[key] = schema[key]
|
|
2439
|
+
else:
|
|
2440
|
+
subschema, merged_state[key] = core.sort(
|
|
2441
|
+
schema.get(key, {}),
|
|
2442
|
+
state.get(key, None))
|
|
2443
|
+
if subschema:
|
|
2444
|
+
value_schema = core.merge_schemas(
|
|
2445
|
+
value_schema,
|
|
2446
|
+
subschema)
|
|
2447
|
+
# merged_schema[key] = subschema
|
|
2448
|
+
|
|
2449
|
+
return merged_schema, merged_state
|
|
2450
|
+
|
|
2451
|
+
|
|
2328
2452
|
def find_union_type(core, schema, state):
|
|
2329
2453
|
parameters = core.parameters_for(schema)
|
|
2330
2454
|
|
|
@@ -2584,6 +2708,7 @@ base_types = {
|
|
|
2584
2708
|
'_slice': slice_map,
|
|
2585
2709
|
'_fold': fold_map,
|
|
2586
2710
|
'_divide': divide_map,
|
|
2711
|
+
'_sort': sort_map,
|
|
2587
2712
|
'_type_parameters': ['value'],
|
|
2588
2713
|
'_description': 'flat mapping from keys of strings to values of any type'},
|
|
2589
2714
|
|
|
@@ -349,20 +349,10 @@ class TypeSystem(Registry):
|
|
|
349
349
|
registry_type = self.retrieve(
|
|
350
350
|
schema['_type'])
|
|
351
351
|
|
|
352
|
-
# found = self.resolve(
|
|
353
|
-
# registry_type,
|
|
354
|
-
# schema)
|
|
355
|
-
|
|
356
352
|
found = self.merge_schemas(
|
|
357
353
|
registry_type,
|
|
358
354
|
schema)
|
|
359
355
|
|
|
360
|
-
# found = schema.copy()
|
|
361
|
-
|
|
362
|
-
# for key, value in registry_type.items():
|
|
363
|
-
# if key == '_type' or key not in found:
|
|
364
|
-
# found[key] = value
|
|
365
|
-
|
|
366
356
|
else:
|
|
367
357
|
found = {
|
|
368
358
|
key: self.access(
|
|
@@ -1610,7 +1600,7 @@ class TypeSystem(Registry):
|
|
|
1610
1600
|
if inner_view is not None:
|
|
1611
1601
|
result[port_key] = inner_view
|
|
1612
1602
|
else:
|
|
1613
|
-
raise Exception(f'trying to
|
|
1603
|
+
raise Exception(f'trying to view state with these ports:\n{schema}\nbut not sure what these wires are:\n{wires}')
|
|
1614
1604
|
|
|
1615
1605
|
return result
|
|
1616
1606
|
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bigraph-schema
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.56
|
|
4
4
|
Summary: A serializable type schema for compositional systems biology
|
|
5
5
|
Home-page: https://github.com/vivarium-collective/bigraph-schema
|
|
6
6
|
Author: Eran Agmon, Ryan Spangler
|
|
7
7
|
Author-email: agmon.eran@gmail.com, ryan.spangler@gmail.com
|
|
8
|
-
License: UNKNOWN
|
|
9
|
-
Platform: UNKNOWN
|
|
10
8
|
Classifier: Development Status :: 3 - Alpha
|
|
11
9
|
Classifier: Intended Audience :: Developers
|
|
12
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -53,5 +51,3 @@ This resource will guide you through the core concepts and methods, helping you
|
|
|
53
51
|
## License
|
|
54
52
|
|
|
55
53
|
Bigraph-schema is open-source software released under the [Apache 2 License](https://github.com/vivarium-collective/bigraph-schema/blob/main/LICENSE).
|
|
56
|
-
|
|
57
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bigraph-schema-0.0.55 → bigraph-schema-0.0.56}/bigraph_schema.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|