1. Connecting with the SDK to DSMS#
In this tutorial we see the overview on how to setup and basic use DSMS-SDK
1.1. Setting up#
Before you run this tutorial: make sure to have access to a DSMS-instance of your interest, alongwith with installation of this package and have establised access to the DSMS through DSMS-SDK (refer to Connecting to DSMS)
Now let us import the needed classes and functions for this tutorial.
[1]:
from dsms import DSMS
Now source the environmental variables from an .env file and start the DSMS-session.
[2]:
dsms = DSMS(env=".env")
1.2. Introduction to KItems#
We can see which kitems we own as a user (in the beginning, we own none):
[5]:
dsms.get_kitems(limit=100)
[5]:
kitems: []
total_count: 0
We can investigate what a KItem needs in order to be created. KItems are entirely based on Pydantic-Models (v2), hence the properties (in Pydantic called Fields) are automatically validated once we set them.
The schema of the KItem itself is a JSON schema which is machine-readable and can be directly incorporated into Swagger-supported APIs like e.g. FastAPI.
We can investigate the KTypes defined in the remote instance:
[6]:
for ktype in dsms.ktypes:
print(ktype)
ktype:
id: organization
name: null
context: false
context_schema: []
webform: null
json_schema: null
created_at: '2024-12-09T15:48:24.918527'
updated_at: '2024-12-09T15:48:24.918527'
ktype:
id: expert
name: null
context: false
context_schema: []
webform: null
json_schema: null
created_at: '2024-12-09T15:48:24.918527'
updated_at: '2024-12-09T15:48:24.918527'
ktype:
id: app
name: null
context: false
context_schema: []
webform: null
json_schema: null
created_at: '2024-12-09T15:48:24.918527'
updated_at: '2024-12-09T15:48:24.918527'
ktype:
id: dataset
name: dataset
context: false
context_schema: []
webform: null
json_schema: null
created_at: '2024-12-09T15:48:24.918527'
updated_at: '2024-12-09T15:48:24.918527'
ktype:
id: dataset-catalog
name: dataset catalog
context: false
context_schema: []
webform: null
json_schema: null
created_at: '2024-12-09T15:48:24.918527'
updated_at: '2024-12-09T15:48:24.918527'
ktype:
id: material
name: Material
context: false
context_schema: []
webform:
semantics_enabled: true
sections_enabled: true
class_mapping:
- https://w3id.org/emmo#EMMO_4207e895_8b83_4318_996a_72cfb32acd94
sections:
- id: id37bef167f3118
name: Material spec
inputs:
- id: idd4eca7fb62c54
label: Material type
widget: Select
required: false
value: null
hint: null
hidden: false
ignore: false
select_options:
- key: option1
label: Crystal
disabled: false
- key: option2
label: Liquid
disabled: false
- key: option3
label: Gas
disabled: false
measurement_unit: null
relation_mapping:
iri: https://w3id.org/steel/ProcessOntology/hasMaterialClass_Object
type: object_property
class_iri: https://w3id.org/emmo#EMMO_39348191_08fd_4bb6_9b1e_012d5b2f1ff6
relation_mapping_extra: null
multiple_selection: false
knowledge_type: null
range_options: null
placeholder: null
- id: id0ff68b6b11bf4
label: Supplier
widget: Multi-select
required: false
value: null
hint: null
hidden: false
ignore: false
select_options:
- key: option1
label: Company 1
disabled: false
- key: option2
label: Company 2
disabled: false
measurement_unit: null
relation_mapping:
iri: https://w3id.org/steel/ProcessOntology/hasSupplier_Object
type: object_property
class_iri: https://w3id.org/steel/ProcessOntology/Supplier
relation_mapping_extra: null
multiple_selection: false
knowledge_type: null
range_options: null
placeholder: null
- id: id8cc24aecb9282
label: Product form
widget: Radio
required: false
value: Sheet
hint: null
hidden: false
ignore: false
select_options:
- key: option1
label: Sheet
disabled: false
- key: option2
label: Block
disabled: false
measurement_unit: null
relation_mapping:
iri: https://w3id.org/emmo#EMMO_17e27c22_37e1_468c_9dd7_95e137f73e7f
type: object_property
class_iri: https://w3id.org/emmo#EMMO_dd4b7d81_28a9_4801_8831_4cbab217e362
relation_mapping_extra: null
multiple_selection: false
knowledge_type: null
range_options: null
placeholder: null
hidden: false
json_schema:
iri:
- https://w3id.org/emmo#EMMO_4207e895_8b83_4318_996a_72cfb32acd94
suffix: slug
source: material[*]
suffix_from_location: true
custom_relations:
- object_location: material-type
relation: https://w3id.org/steel/ProcessOntology/hasMaterialClass_Object
relation_type: object_property
object_type:
iri: https://w3id.org/emmo#EMMO_39348191_08fd_4bb6_9b1e_012d5b2f1ff6
- object_location: supplier
relation: https://w3id.org/steel/ProcessOntology/hasSupplier_Object
relation_type: object_property
object_type:
iri: https://w3id.org/steel/ProcessOntology/Supplier
- object_location: product-form
relation: https://w3id.org/emmo#EMMO_17e27c22_37e1_468c_9dd7_95e137f73e7f
relation_type: object_property
object_type:
iri: https://w3id.org/emmo#EMMO_dd4b7d81_28a9_4801_8831_4cbab217e362
- object_location: Name
relation: http://www.w3.org/2000/01/rdf-schema#label
relation_type: annotation_property
object_data_type: string
created_at: '2024-12-09T23:14:18.843010'
updated_at: '2025-01-17T09:57:57.584798'
ktype:
id: testingmachine
name: Testing machine
context: false
context_schema: []
webform:
semantics_enabled: true
sections_enabled: false
class_mapping:
- https://w3id.org/pmd/co/Specimen
sections:
- id: id18d888a9c9fa48
name: Untitled Section
inputs:
- id: ida450e96a27a6e8
label: Machine
widget: Knowledge item
required: false
value: null
hint: null
hidden: false
ignore: false
select_options: []
measurement_unit: null
relation_mapping:
iri: https://w3id.org/steel/ProcessOntology/hasMachine_Object
type: object_property
class_iri: https://w3id.org/steel/ProcessOntology/Machine
relation_mapping_extra: null
multiple_selection: false
knowledge_type: testingmachine
range_options: null
placeholder: null
- id: idba8e853b2fdbe
label: Specimen
widget: Knowledge item
required: false
value: null
hint: null
hidden: false
ignore: false
select_options: []
measurement_unit: null
relation_mapping:
iri: https://w3id.org/steel/ProcessOntology/hasTestPiece_Object
type: object_property
class_iri: https://w3id.org/pmd/co/Specimen
relation_mapping_extra: null
multiple_selection: true
knowledge_type: specimen
range_options: null
placeholder: null
hidden: false
json_schema:
iri:
- https://w3id.org/pmd/co/Specimen
suffix: slug
source: testingmachine[*]
suffix_from_location: true
custom_relations:
- object_location: machine
relation: https://w3id.org/steel/ProcessOntology/hasMachine_Object
relation_type: object_property
object_type: anyURI
- object_location: specimen
relation: https://w3id.org/steel/ProcessOntology/hasTestPiece_Object
relation_type: object_property
object_type: anyURI
- object_location: Name
relation: http://www.w3.org/2000/01/rdf-schema#label
relation_type: annotation_property
object_data_type: string
created_at: '2024-12-12T17:56:45.095403'
updated_at: '2025-01-16T15:19:06.989779'
ktype:
id: specimen
name: Specimen
context: false
context_schema: []
webform:
semantics_enabled: true
sections_enabled: false
class_mapping:
- https://w3id.org/pmd/co/Specimen
sections:
- id: ida3c5c42685526
name: Untitled Section
inputs:
- id: id175f885f8dda58
label: Width
widget: Slider
required: false
value: null
hint: null
hidden: false
ignore: false
select_options: []
measurement_unit:
label: Millimetre
iri: http://qudt.org/vocab/unit/MilliM
symbol: null
namespace: http://qudt.org/vocab/unit
relation_mapping:
iri: https://w3id.org/steel/ProcessOntology/hasWidth_Object
type: object_property
class_iri: https://w3id.org/emmo#EMMO_e4de48b1_dabb_4490_ac2b_040f926c64f0
relation_mapping_extra: null
multiple_selection: false
knowledge_type: null
range_options:
min: 0
max: 1
step: 0.1
range: false
placeholder: null
- id: idef5a37328789f
label: Length
widget: Slider
required: false
value: null
hint: null
hidden: false
ignore: false
select_options: []
measurement_unit:
label: Millimetre
iri: http://qudt.org/vocab/unit/MilliM
symbol: null
namespace: http://qudt.org/vocab/unit
relation_mapping:
iri: https://w3id.org/steel/ProcessOntology/hasTotalLength_Object
type: object_property
class_iri: https://w3id.org/steel/ProcessOntology/TotalLength
relation_mapping_extra:
iri: https://w3id.org/steel/ProcessOntology/hasTotalLength_Object
type: object_property
class_iri: https://w3id.org/steel/ProcessOntology/TotalLength
multiple_selection: false
knowledge_type: null
range_options:
min: 0
max: 1
step: 0.1
range: true
placeholder: null
- id: id54decb9641f9a
label: Radius
widget: Number
required: false
value: null
hint: null
hidden: false
ignore: false
select_options: []
measurement_unit:
label: Millimetre
iri: http://qudt.org/vocab/unit/MilliM
symbol: null
namespace: http://qudt.org/vocab/unit
relation_mapping:
iri: https://w3id.org/steel/ProcessOntology/hasRadius_Object
type: object_property
class_iri: https://w3id.org/emmo#EMMO_32dcd601_47c7_4028_b7fa_5e972ae57f12
relation_mapping_extra: null
multiple_selection: false
knowledge_type: null
range_options:
min: 0
max: 1
step: 0.1
range: false
placeholder: null
hidden: false
json_schema:
iri:
- https://w3id.org/pmd/co/Specimen
suffix: slug
source: specimen[*]
suffix_from_location: true
custom_relations:
- object_location: width
relation: https://w3id.org/steel/ProcessOntology/hasWidth_Object
relation_type: object_property
object_type:
iri: https://w3id.org/emmo#EMMO_e4de48b1_dabb_4490_ac2b_040f926c64f0
unit: http://qudt.org/vocab/unit/MilliM
- object_location: length[0]
relation: https://w3id.org/steel/ProcessOntology/hasTotalLength_Object
relation_type: object_property
object_type:
iri: https://w3id.org/steel/ProcessOntology/TotalLength
unit: http://qudt.org/vocab/unit/MilliM
suffix: min
- object_location: length[1]
relation: https://w3id.org/steel/ProcessOntology/hasTotalLength_Object
relation_type: object_property
object_type:
suffix: max
iri: https://w3id.org/steel/ProcessOntology/TotalLength
unit: http://qudt.org/vocab/unit/MilliM
- object_location: radius
relation: https://w3id.org/steel/ProcessOntology/hasRadius_Object
relation_type: object_property
object_type:
iri: https://w3id.org/emmo#EMMO_32dcd601_47c7_4028_b7fa_5e972ae57f12
unit: http://qudt.org/vocab/unit/MilliM
- object_location: Name
relation: http://www.w3.org/2000/01/rdf-schema#label
relation_type: annotation_property
object_data_type: string
created_at: '2024-12-17T11:00:34.924035'
updated_at: '2025-01-16T18:25:33.054442'