Skip to content

Commit 05ecab5

Browse files
committed
Some (incomplete) fixes to examples
1 parent c63cd11 commit 05ecab5

7 files changed

Lines changed: 11 additions & 10 deletions

File tree

‎examples/controller_logic.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing_extensions import override
44

5-
from osw.controller.entity import Entity, Hardware
5+
from osw.controller.entity import Entity
66
from osw.express import OswExpress
77

88
# Create/update the password file under examples/accounts.pwd.yaml
@@ -18,7 +18,7 @@
1818
osw_obj.fetch_schema(
1919
fetchSchemaParam=OswExpress.FetchSchemaParam(schema_title="Category:Hardware")
2020
)
21-
21+
from osw.model.entity import Hardware # noqa: E402
2222

2323
title = "Item:OSW7d7193567ea14e4e89b74de88983b718"
2424
# title = "Item:OSWe02213b6c4664d04834355dc8eb08b99"

‎examples/create_entity.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import osw.model.entity as model
44

55
my_entity = model.Item(
6-
label=[model.Label(text="MyItem")], statements=[model.Statement(predicate="IsA")]
6+
label=[model.Label(text="MyItem")],
7+
statements=[model.DataStatement(property="IsA", value="Category:Item")],
78
)
89
pprint(my_entity.dict())
910
print(my_entity.json())

‎examples/device_inventory.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
model, "Corporation"
2727
): # only load if not already loaded. note: does not detect updated schemas yet
2828
DEPENDENCIES = {
29-
"MetaDeviceCategory": "Category:OSWd845b96813a344458f140e48c4d063fd",
29+
"DeviceType": "Category:OSWd845b96813a344458f140e48c4d063fd",
3030
"Device(SubclassWithMetaModel)": "Category:OSW5bf1542d9cf847db83cbc73d579ba9d6",
3131
"Corporation": "Category:OSW5f4a3751d23e482d80fb0b72dcd6bc31", #
3232
}
@@ -47,7 +47,7 @@
4747
)
4848

4949
# Create a new device type with the new manufacturer as manufacturer
50-
new_category = model.MetaDeviceCategory( # here used as a device type
50+
new_category = model.DeviceType( # here used as a device type
5151
uuid=uuid.uuid5(
5252
uuid_namespace, "MyNewDeviceCategory"
5353
), # use a stable id from the source dataset / file
@@ -70,7 +70,7 @@
7070
namespace="Category",
7171
# meta_category_title= (
7272
# "Category:OSWd845b96813a344458f140e48c4d063fd")
73-
# usage of MetaDeviceCategory not yet supported
73+
# usage of DeviceType not yet supported
7474
)
7575
)
7676

‎examples/generate_rdf.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# load dependencies
2020
DEPENDENCIES = {
2121
"Tool": "Category:OSWe427aafafbac4262955b9f690a83405d",
22+
"Device": "Category:OSWf0fe562f422d49c6877490b3dfee2f3f",
2223
}
2324
osw_obj.install_dependencies(DEPENDENCIES, mode="append", policy="if-missing")
2425

‎examples/register_model.py‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from typing import ClassVar
44
from uuid import uuid4
55

6-
from pydantic.v1 import BaseModel
7-
86
import osw.model.entity as model
97
from osw.core import OSW
108
from osw.express import OswExpress
@@ -20,7 +18,7 @@
2018

2119
# todo: does dataclass export only most specific class jsonschema
2220
class MyPythonClass(
23-
BaseModel
21+
model.OswBaseModel
2422
): # We don't inherit from model.Item here because this will trigger a full schema
2523
# export
2624
__uuid__: ClassVar[uuid4] = "23e4356e-b726-4c5b-b63f-620b301eb836"

‎examples/store_entity.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
)
1515

1616
my_entity = model.Item(
17-
label=[model.Label(text="MyItem")], statements=[model.Statement(predicate="IsA")]
17+
label=[model.Label(text="MyItem")],
18+
statements=[model.DataStatement(property="IsA", value="Category:Item")],
1819
)
1920
pprint(my_entity)
2021

0 commit comments

Comments
 (0)