Skip to content

Commit

Permalink
add functionality to get linked kitems by annotation, update docs (#31)
Browse files Browse the repository at this point in the history
* add functionality to get linked kitems by annotation, update docs

* add retrieval of linked kitems per ktype and debug kitem check of ktype
  • Loading branch information
MBueschelberger authored Aug 23, 2024
1 parent af75773 commit f5e8b77
Show file tree
Hide file tree
Showing 9 changed files with 2,029 additions and 133 deletions.
102 changes: 78 additions & 24 deletions docs/dsms_sdk/tutorials/2_creation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -62,7 +62,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -72,13 +72,13 @@
"\n",
"\tname = Machine-1, \n",
"\n",
"\tid = dd091666-a7c9-4b3b-8832-910bdec5c63c, \n",
"\tid = 6a5fd4a4-4dc0-4643-84eb-1e35513974ba, \n",
"\n",
"\tktype_id = KTypes.TestingMachine, \n",
"\n",
"\tin_backend = False, \n",
"\n",
"\tslug = machine-1-dd091666, \n",
"\tslug = machine-1-6a5fd4a4, \n",
"\n",
"\tannotations = [], \n",
"\n",
Expand Down Expand Up @@ -118,7 +118,7 @@
")"
]
},
"execution_count": 26,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -145,16 +145,16 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'https://bue.materials-data.space/knowledge/testing-machine/machine-1-dd091666'"
"'https://stahldigital.materials-data.space/knowledge/testing-machine/machine-1-6a5fd4a4'"
]
},
"execution_count": 27,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -173,7 +173,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand All @@ -183,13 +183,13 @@
"\n",
"\tname = Machine-1, \n",
"\n",
"\tid = dd091666-a7c9-4b3b-8832-910bdec5c63c, \n",
"\tid = 6a5fd4a4-4dc0-4643-84eb-1e35513974ba, \n",
"\n",
"\tktype_id = testing-machine, \n",
"\n",
"\tin_backend = True, \n",
"\n",
"\tslug = machine-1-dd091666, \n",
"\tslug = machine-1-6a5fd4a4, \n",
"\n",
"\tannotations = [], \n",
"\n",
Expand All @@ -201,17 +201,17 @@
"\n",
"\tauthors = [\n",
"\t\t{\n",
"\t\t\tuser_id: 7f0e5a37-353b-4bbc-b1f1-b6ad575f562d\n",
"\t\t\tuser_id: aa97bc4c-939e-4142-8f22-c6be8c0df228\n",
"\t\t}\n",
"\t], \n",
"\n",
"\tavatar_exists = False, \n",
"\n",
"\tcontacts = [], \n",
"\n",
"\tcreated_at = 2024-08-19 18:12:11.338394, \n",
"\tcreated_at = 2024-08-23 18:16:24.190604, \n",
"\n",
"\tupdated_at = 2024-08-19 18:12:11.338394, \n",
"\tupdated_at = 2024-08-23 18:16:24.190604, \n",
"\n",
"\texternal_links = [], \n",
"\n",
Expand All @@ -233,7 +233,7 @@
")"
]
},
"execution_count": 28,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -251,7 +251,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand All @@ -260,7 +260,7 @@
"'Machine-1'"
]
},
"execution_count": 29,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -273,27 +273,81 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To check the type of the item newly created we can use the following:"
"As well as the id of the kitem we can do it as follows:"
]
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dsms.knowledge.kitem.KItem"
"UUID('6a5fd4a4-4dc0-4643-84eb-1e35513974ba')"
]
},
"execution_count": 30,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(item)"
"item.id"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To check the KType of the item newly created we can use the following:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"KType(id='testing-machine', name='Testing Machine', webform=<class 'dsms.knowledge.utils.CustomPropertiesModel'>, json_schema=None)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"item.ktype"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"... and also check the KType:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"item.is_a(dsms.ktypes.TestingMachine)"
]
},
{
Expand Down Expand Up @@ -325,7 +379,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.12.2"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit f5e8b77

Please sign in to comment.