Skip to content

Commit 3cbc99c

Browse files
dan-obxloryruta
authored andcommitted
examples: store model file next to apps, add model json file #25
1 parent 6b19059 commit 3cbc99c

6 files changed

Lines changed: 98 additions & 4 deletions

File tree

example/ollama/llamas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DocumentEmbedding:
3030

3131
model = Model()
3232
model.entity(DocumentEmbedding)
33-
sync_model(model)
33+
sync_model(model, os.path.join(os.path.dirname(__file__),"obx-model.json") )
3434

3535
store = objectbox.Store(model=model)
3636
box = store.box(DocumentEmbedding)

example/ollama/obx-model.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.",
3+
"_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
4+
"_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
5+
"entities": [
6+
{
7+
"id": "1:8004313811940756000",
8+
"name": "DocumentEmbedding",
9+
"lastPropertyId": "3:1002055376809445224",
10+
"properties": [
11+
{
12+
"id": "1:5231290100164136665",
13+
"name": "id"
14+
},
15+
{
16+
"id": "2:2794747928415190181",
17+
"name": "document"
18+
},
19+
{
20+
"id": "3:1002055376809445224",
21+
"name": "embedding",
22+
"indexId": "1:5402707781572973098"
23+
}
24+
]
25+
}
26+
],
27+
"lastEntityId": "1:8004313811940756000",
28+
"lastIndexId": "1:5402707781572973098",
29+
"modelVersionParserMinimum": 5
30+
}

example/tasks/model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from objectbox.model import *
22
from objectbox.model.sync_model import sync_model
3+
import os.path
34

45
@Entity()
56
class Task:
@@ -13,5 +14,5 @@ class Task:
1314
def get_objectbox_model():
1415
m = Model()
1516
m.entity(Task)
16-
sync_model(m)
17+
sync_model(m, os.path.join(os.path.dirname(__file__),"obx-model.json") )
1718
return m

example/tasks/obx-model.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.",
3+
"_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
4+
"_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
5+
"entities": [
6+
{
7+
"id": "1:6465125355924028123",
8+
"name": "Task",
9+
"lastPropertyId": "4:8015673551585674115",
10+
"properties": [
11+
{
12+
"id": "1:8700906525982901970",
13+
"name": "id"
14+
},
15+
{
16+
"id": "2:6068517061615452812",
17+
"name": "text"
18+
},
19+
{
20+
"id": "3:1585967268027923630",
21+
"name": "date_created"
22+
},
23+
{
24+
"id": "4:8015673551585674115",
25+
"name": "date_finished"
26+
}
27+
]
28+
}
29+
],
30+
"lastEntityId": "1:6465125355924028123",
31+
"lastIndexId": "0:0",
32+
"modelVersionParserMinimum": 5
33+
}

example/vectorsearch-cities/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from objectbox.model.sync_model import sync_model
44
import objectbox
55
import numpy as np
6-
6+
import os.path
77

88
@Entity()
99
class City:
@@ -17,5 +17,5 @@ class City:
1717
def get_objectbox_model():
1818
m = Model()
1919
m.entity(City)
20-
sync_model(m)
20+
sync_model(m, os.path.join(os.path.dirname(__file__),"obx-model.json") )
2121
return m
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.",
3+
"_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
4+
"_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
5+
"entities": [
6+
{
7+
"id": "1:4817145754065816046",
8+
"name": "City",
9+
"lastPropertyId": "3:8621035483966640033",
10+
"properties": [
11+
{
12+
"id": "1:5906277260829377830",
13+
"name": "id"
14+
},
15+
{
16+
"id": "2:1820212786894711110",
17+
"name": "name"
18+
},
19+
{
20+
"id": "3:8621035483966640033",
21+
"name": "location",
22+
"indexId": "1:933206701064379830"
23+
}
24+
]
25+
}
26+
],
27+
"lastEntityId": "1:4817145754065816046",
28+
"lastIndexId": "1:933206701064379830",
29+
"modelVersionParserMinimum": 5
30+
}

0 commit comments

Comments
 (0)