-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_data.py
More file actions
83 lines (77 loc) · 3.2 KB
/
Copy pathgenerate_data.py
File metadata and controls
83 lines (77 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from tardis import TARDIS, FieldUpdate
from datetime import timedelta
from random import choice, randint, uniform
from sqlmodel import Session
from uuid import uuid4
from datetime import datetime, timedelta
if __name__ == "__main__":
tardis = TARDIS("sqlite:///tardis_example.sqlite")
with Session(tardis.engine) as db:
db.add(FieldUpdate(
id=uuid4(),
event=uuid4(),
field="example:list",
setter="value",
subject_type="example:person",
subject_identifier="hannah",
body=[choice(list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")) for _ in range(20)],
updated_at=datetime.now()+timedelta(hours=randint(-256,0)),
params={}
))
db.add(FieldUpdate(
id=uuid4(),
event=uuid4(),
field="example:list",
setter="tardis:list:insert",
subject_type="example:person",
subject_identifier="hannah",
body="inserted at index 3!",
updated_at=datetime.now()+timedelta(hours=randint(-256,0)),
params={"index":"3"}
))
for _ in range(100):
db.add(FieldUpdate(
id=uuid4(),
event=uuid4(),
field="example:integer",
setter="tardis:numeric:delta",
subject_type="example:person",
subject_identifier=choice(["hannah", "alice", "bob"]),
body=randint(1,5),
updated_at=datetime.now()+timedelta(hours=randint(-256,0)),
params={}
))
db.add(FieldUpdate(
id=uuid4(),
event=uuid4(),
field="example:float",
setter="tardis:numeric:delta",
subject_type="example:person",
subject_identifier=choice(["hannah", "alice", "bob"]),
body=uniform(1,5),
updated_at=datetime.now()+timedelta(hours=randint(-256,0)),
params={}
))
db.add(FieldUpdate(
id=uuid4(),
event=uuid4(),
field="example:set",
setter=choice(["tardis:set:put", "tardis:set:remove"]), # Note that this will generate invalid removals
subject_type="example:person",
subject_identifier=choice(["hannah", "alice", "bob"]),
body=choice(list("abcdefghijklmnopqrstuvwxyz")),
updated_at=datetime.now()+timedelta(hours=randint(-256,0)),
params={}
))
db.add(FieldUpdate(
id=uuid4(),
event=uuid4(),
field="example:list",
setter=choice(["tardis:list:append", "tardis:list:remove"]), # Note that this will generate invalid removals
subject_type="example:person",
subject_identifier=choice(["hannah", "alice", "bob"]),
body=choice(list("abcdefghijklmnopqrstuvwxyz")),
updated_at=datetime.now()+timedelta(hours=randint(-256,0)),
params={}
))
db.commit()