-
Notifications
You must be signed in to change notification settings - Fork 394
/
Copy pathcheck_parallelism_caching_reentrancy.py
195 lines (164 loc) · 6.25 KB
/
check_parallelism_caching_reentrancy.py
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
from __future__ import annotations
import math
import os
import random
from argparse import Namespace
from uuid import uuid4
import numpy as np
import rerun as rr
import rerun.blueprint as rrb
README = """\
# Parallelism, caching, reentrancy, etc
This check simply puts a lot of pressure on all things parallel.
### Actions
* Scrub the time cursor like crazy: do your worst!
If nothing weird happens, you can close this recording.
"""
def blueprint() -> rrb.BlueprintLike:
return rrb.Grid(
rrb.Vertical(*[rrb.TimeSeriesView(name="plots", origin="/plots") for _ in range(0, 3)]),
rrb.Vertical(*[
rrb.TimeSeriesView(
name="plots",
origin="/plots",
time_ranges=rrb.VisibleTimeRange(
"frame_nr",
start=rrb.TimeRangeBoundary.cursor_relative(seq=50 - i * 10),
end=rrb.TimeRangeBoundary.cursor_relative(seq=50 - i * 10 + 10),
),
)
for i in range(0, 10)
]),
rrb.Vertical(*[rrb.TextLogView(name="logs", origin="/text") for _ in range(0, 3)]),
rrb.Vertical(*[rrb.Spatial2DView(name="2D", origin="/2D") for _ in range(0, 3)]),
rrb.Vertical(*[
rrb.Spatial2DView(
name="2D",
origin="/2D",
time_ranges=rrb.VisibleTimeRange(
"frame_nr",
start=rrb.TimeRangeBoundary.infinite(),
end=rrb.TimeRangeBoundary.cursor_relative(),
),
)
for _ in range(0, 3)
]),
rrb.Vertical(*[rrb.Spatial3DView(name="3D", origin="/3D") for _ in range(0, 3)]),
rrb.Vertical(*[
rrb.Spatial3DView(
name="3D",
origin="/3D",
time_ranges=rrb.VisibleTimeRange(
"frame_nr",
start=rrb.TimeRangeBoundary.infinite(),
end=rrb.TimeRangeBoundary.infinite(),
),
)
for _ in range(0, 3)
]),
rrb.TextDocumentView(origin="readme"),
grid_columns=4,
)
def log_readme() -> None:
rr.log("readme", rr.TextDocument(README, media_type=rr.MediaType.MARKDOWN), static=True)
def log_text_logs() -> None:
for t in range(0, 100):
rr.set_time_sequence("frame_nr", t)
rr.log("text", rr.TextLog("Something good happened", level=rr.TextLogLevel.INFO))
rr.log("text", rr.TextLog("Something bad happened", level=rr.TextLogLevel.ERROR))
def log_plots() -> None:
from math import cos, sin, tau
rr.log("plots/sin", rr.SeriesLine(color=[255, 0, 0], name="sin(0.01t)"), static=True)
rr.log("plots/cos", rr.SeriesLine(color=[0, 255, 0], name="cos(0.01t)"), static=True)
for t in range(0, int(tau * 2 * 10.0)):
rr.set_time_sequence("frame_nr", t)
sin_of_t = sin(float(t) / 10.0)
rr.log("plots/sin", rr.Scalar(sin_of_t))
cos_of_t = cos(float(t) / 10.0)
rr.log("plots/cos", rr.Scalar(cos_of_t))
def log_spatial() -> None:
for t in range(0, 100):
rr.set_time_sequence("frame_nr", t)
positions3d = [
[math.sin((i + t) * 0.2) * 5, math.cos((i + t) * 0.2) * 5 - 10.0, i * 0.4 - 5.0] for i in range(0, 100)
]
rr.log(
"3D/points",
rr.Points3D(
np.array(positions3d),
labels=[str(i) for i in range(t, t + 100)],
colors=np.array([[random.randrange(255) for _ in range(3)] for _ in range(t, t + 100)]),
),
)
rr.log(
"3D/lines",
rr.LineStrips3D(
np.array(positions3d),
labels=[str(i) for i in range(t, t + 100)],
colors=np.array([[random.randrange(255) for _ in range(3)] for _ in range(t, t + 100)]),
),
)
rr.log(
"3D/arrows",
rr.Arrows3D(
vectors=np.array(positions3d),
radii=0.1,
labels=[str(i) for i in range(t, t + 100)],
colors=np.array([[random.randrange(255) for _ in range(3)] for _ in range(t, t + 100)]),
),
)
rr.log(
"3D/boxes",
rr.Boxes3D(
half_sizes=np.array(positions3d),
labels=[str(i) for i in range(t, t + 100)],
colors=np.array([[random.randrange(255) for _ in range(3)] for _ in range(t, t + 100)]),
),
)
positions2d = [[math.sin(i * math.tau / 100.0) * t, math.cos(i * math.tau / 100.0) * t] for i in range(0, 100)]
rr.log(
"2D/points",
rr.Points2D(
np.array(positions2d),
labels=[str(i) for i in range(t, t + 100)],
colors=np.array([[random.randrange(255) for _ in range(3)] for _ in range(t, t + 100)]),
),
)
rr.log(
"2D/lines",
rr.LineStrips2D(
np.array(positions2d),
labels=[str(i) for i in range(t, t + 100)],
colors=np.array([[random.randrange(255) for _ in range(3)] for _ in range(t, t + 100)]),
),
)
rr.log(
"2D/arrows",
rr.Arrows2D(
vectors=np.array(positions2d),
radii=0.1,
labels=[str(i) for i in range(t, t + 100)],
colors=np.array([[random.randrange(255) for _ in range(3)] for _ in range(t, t + 100)]),
),
)
rr.log(
"2D/boxes",
rr.Boxes2D(
half_sizes=np.array(positions2d),
labels=[str(i) for i in range(t, t + 100)],
colors=np.array([[random.randrange(255) for _ in range(3)] for _ in range(t, t + 100)]),
),
)
def run(args: Namespace) -> None:
rr.script_setup(args, f"{os.path.basename(__file__)}", recording_id=uuid4())
rr.send_blueprint(blueprint(), make_active=True, make_default=True)
log_readme()
log_text_logs()
log_plots()
log_spatial()
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Interactive release checklist")
rr.script_add_args(parser)
args = parser.parse_args()
run(args)