146 lines
3.5 KiB
Plaintext
146 lines
3.5 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "e02ccafe-e04d-4312-acba-e41cf7b1c021",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"/home/smgr/.pyenv/versions/co4/lib/python3.12/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
|
" from .autonotebook import tqdm as notebook_tqdm\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"from co3 import Mapper\n",
|
|
"\n",
|
|
"import vegetables"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "7d80f7b9-7458-4ad4-8c1a-3ea56e796b4e",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"vegetable_mapper = Mapper(\n",
|
|
" vegetables.Vegetable,\n",
|
|
" vegetables.vegetable_schema\n",
|
|
")\n",
|
|
"\n",
|
|
"vegetable_mapper.attach(\n",
|
|
" vegetables.Vegetable,\n",
|
|
" vegetables.vegetable_table,\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "f9408562-bf50-4522-909c-318557f85948",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# manually attach component\n",
|
|
"vegetable_mapper.attach(\n",
|
|
" vegetables.Tomato,\n",
|
|
" vegetables.tomato_table,\n",
|
|
" coll_groups={\n",
|
|
" 'aging': vegetables.vegetable_schema.get_component('tomato_aging_states'),\n",
|
|
" 'cooking': vegetables.vegetable_schema.get_component('tomato_cooking_states'),\n",
|
|
" },\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "05fdd404-87ee-4187-832f-2305272758ae",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# attach by name in schema\n",
|
|
"vegetable_mapper.attach(\n",
|
|
" vegetables.Tomato,\n",
|
|
" vegetables.tomato_table,\n",
|
|
" coll_groups={\n",
|
|
" 'aging': 'tomato_aging_states',\n",
|
|
" 'cooking': 'tomato_cooking_states',\n",
|
|
" },\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "e9b6af49-a69d-41cc-beae-1b6f171cd2f5",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# attach entire type hierarchy w/ type->name map\n",
|
|
"vegetable_mapper.attach_hierarchy(\n",
|
|
"# this might make more sense during init\n",
|
|
" lambda x:x.__name__.lower())\n",
|
|
")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"id": "2e4336ab-5b5f-484d-815d-164d4b6f40a0",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"defaultdict(dict,\n",
|
|
" {vegetables.Tomato: {'aging': <co3.components.SQLTable at 0x7ece94358aa0>,\n",
|
|
" 'cooking': <co3.components.SQLTable at 0x7ece94358ad0>}})"
|
|
]
|
|
},
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"vegetable_mapper.collation_groups"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "d416f9cd-2cb6-4a6e-bab7-86ac21216b8c",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "co3",
|
|
"language": "python",
|
|
"name": "co3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.12.2"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|