" self.changelog: list = changelog if changelog is not None else []\n",
" self.label: list = label if label is not None else []\n",
" self.genericAttribute: list = genericAttribute if genericAttribute is not None else []\n",
" self.measure: list = measure if measure is not None else []\n",
" self.sharedWith: list = sharedWith if sharedWith is not None else []\n",
"\n",
" @classmethod\n",
" def parse_json(self, cls, json):\n",
...
...
@@ -340,7 +384,8 @@
" def from_json(cls, json):\n",
" kwargs = Item.parse_json(cls, json)\n",
" res = cls(**kwargs)\n",
" for e in res.get_all_edges(): e.source = res\n",
" for e in res.get_all_edges():\n",
" e.source = res\n",
" return res"
]
},
...
...
%% Cell type:code id: tags:
``` python
%load_extautoreload
%autoreload2
# default_exp data.itembase
```
%% Cell type:markdown id: tags:
# Itembase
%% Cell type:markdown id: tags:
Any data class in pymemri inherits from `Item`. It is a base class for items with some handy functionalities to create new items and edges, retrieve all edges to other items, and sync with the pod.
returns whether the node is expanded. An expanded node retrieved nodes that are
*directly* connected to it
from the pod, and stored their values via edges in the object.
%% Cell type:markdown id: tags:
# Usage
%% Cell type:markdown id: tags:
With the `Item` and `Edge` classes we can create an item and its surrounding graph. The schema is defined in schema.py, in general we want to use the from_data staticmethod to generate new items, because it ensures that edges are linked from both the source and the target object. Let's make a new item and add it to the pod.