foxglove-sdk 0.8.1__cp312-cp312-win32.whl → 0.16.3__cp312-cp312-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of foxglove-sdk might be problematic. Click here for more details.
- foxglove/__init__.py +245 -124
- foxglove/_foxglove_py/__init__.pyi +233 -167
- foxglove/_foxglove_py/channels.pyi +2792 -2580
- foxglove/_foxglove_py/cloud.pyi +9 -0
- foxglove/_foxglove_py/mcap.pyi +125 -84
- foxglove/_foxglove_py/schemas.pyi +1009 -839
- foxglove/_foxglove_py/schemas_wkt.pyi +85 -77
- foxglove/_foxglove_py/websocket.pyi +394 -343
- foxglove/_foxglove_py.cp312-win32.pyd +0 -0
- foxglove/benchmarks/test_mcap_serialization.py +160 -160
- foxglove/channel.py +241 -234
- foxglove/channels/__init__.py +94 -90
- foxglove/cloud.py +61 -0
- foxglove/mcap.py +12 -12
- foxglove/notebook/__init__.py +0 -0
- foxglove/notebook/foxglove_widget.py +100 -0
- foxglove/notebook/notebook_buffer.py +114 -0
- foxglove/schemas/__init__.py +163 -155
- foxglove/tests/test_channel.py +243 -215
- foxglove/tests/test_context.py +10 -0
- foxglove/tests/test_logging.py +62 -16
- foxglove/tests/test_mcap.py +477 -116
- foxglove/tests/test_parameters.py +178 -154
- foxglove/tests/test_schemas.py +17 -0
- foxglove/tests/test_server.py +141 -110
- foxglove/tests/test_time.py +137 -137
- foxglove/websocket.py +220 -195
- foxglove_sdk-0.16.3.dist-info/METADATA +53 -0
- foxglove_sdk-0.16.3.dist-info/RECORD +32 -0
- {foxglove_sdk-0.8.1.dist-info → foxglove_sdk-0.16.3.dist-info}/WHEEL +1 -1
- foxglove_sdk-0.8.1.dist-info/METADATA +0 -51
- foxglove_sdk-0.8.1.dist-info/RECORD +0 -25
foxglove/tests/test_time.py
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
import datetime
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
from foxglove.schemas import Duration, Timestamp
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def test_duration_normalization() -> None:
|
|
8
|
-
assert Duration(sec=0, nsec=1_111_222_333) == Duration(sec=1, nsec=111_222_333)
|
|
9
|
-
assert Duration(sec=0, nsec=2**32 - 1) == Duration(sec=4, nsec=294_967_295)
|
|
10
|
-
assert Duration(sec=-2, nsec=1_000_000_001) == Duration(sec=-1, nsec=1)
|
|
11
|
-
assert Duration(sec=-(2**31), nsec=1_000_000_001) == Duration(
|
|
12
|
-
sec=-(2**31) + 1, nsec=1
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
# argument conversions
|
|
16
|
-
d = Duration(sec=-(2**31))
|
|
17
|
-
assert d.sec == -(2**31)
|
|
18
|
-
assert d.nsec == 0
|
|
19
|
-
|
|
20
|
-
d = Duration(sec=0, nsec=2**32 - 1)
|
|
21
|
-
assert d.sec == 4
|
|
22
|
-
assert d.nsec == 294_967_295
|
|
23
|
-
|
|
24
|
-
d = Duration(sec=2**31 - 1, nsec=999_999_999)
|
|
25
|
-
assert d.sec == 2**31 - 1
|
|
26
|
-
assert d.nsec == 999_999_999
|
|
27
|
-
|
|
28
|
-
with pytest.raises(OverflowError):
|
|
29
|
-
Duration(sec=-(2**31) - 1)
|
|
30
|
-
with pytest.raises(OverflowError):
|
|
31
|
-
Duration(sec=2**31)
|
|
32
|
-
with pytest.raises(OverflowError):
|
|
33
|
-
Duration(sec=0, nsec=-1)
|
|
34
|
-
with pytest.raises(OverflowError):
|
|
35
|
-
Duration(sec=0, nsec=2**32)
|
|
36
|
-
|
|
37
|
-
# overflow past upper bound
|
|
38
|
-
with pytest.raises(OverflowError):
|
|
39
|
-
Duration(sec=2**31 - 1, nsec=1_000_000_000)
|
|
40
|
-
|
|
41
|
-
# we don't handle this corner case, where seconds is beyond the lower
|
|
42
|
-
# bound, but nanoseconds overflow to bring the duration within range.
|
|
43
|
-
with pytest.raises(OverflowError):
|
|
44
|
-
Duration(sec=-(2**31) - 1, nsec=1_000_000_000)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def test_duration_from_secs() -> None:
|
|
48
|
-
assert Duration.from_secs(1.123) == Duration(sec=1, nsec=123_000_000)
|
|
49
|
-
assert Duration.from_secs(-0.123) == Duration(sec=-1, nsec=877_000_000)
|
|
50
|
-
assert Duration.from_secs(-1.123) == Duration(sec=-2, nsec=877_000_000)
|
|
51
|
-
|
|
52
|
-
with pytest.raises(OverflowError):
|
|
53
|
-
Duration.from_secs(-1e42)
|
|
54
|
-
|
|
55
|
-
with pytest.raises(OverflowError):
|
|
56
|
-
Duration.from_secs(1e42)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def test_duration_from_timedelta() -> None:
|
|
60
|
-
td = datetime.timedelta(seconds=1, milliseconds=123)
|
|
61
|
-
assert Duration.from_timedelta(td) == Duration(sec=1, nsec=123_000_000)
|
|
62
|
-
|
|
63
|
-
# no loss of precision
|
|
64
|
-
td = datetime.timedelta(days=9876, microseconds=123_456)
|
|
65
|
-
assert Duration.from_timedelta(td) == Duration(sec=853_286_400, nsec=123_456_000)
|
|
66
|
-
|
|
67
|
-
# timedeltas are normalized
|
|
68
|
-
td = datetime.timedelta(seconds=8 * 24 * 3600, milliseconds=99_111)
|
|
69
|
-
assert Duration.from_timedelta(td) == Duration(sec=691_299, nsec=111_000_000)
|
|
70
|
-
|
|
71
|
-
with pytest.raises(OverflowError):
|
|
72
|
-
Duration.from_timedelta(datetime.timedelta.min)
|
|
73
|
-
|
|
74
|
-
with pytest.raises(OverflowError):
|
|
75
|
-
Duration.from_timedelta(datetime.timedelta.max)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def test_timestamp_normalization() -> None:
|
|
79
|
-
assert Timestamp(sec=0, nsec=1_111_222_333) == Timestamp(sec=1, nsec=111_222_333)
|
|
80
|
-
assert Timestamp(sec=0, nsec=2**32 - 1) == Timestamp(sec=4, nsec=294_967_295)
|
|
81
|
-
|
|
82
|
-
# argument conversions
|
|
83
|
-
t = Timestamp(sec=0)
|
|
84
|
-
assert t.sec == 0
|
|
85
|
-
assert t.nsec == 0
|
|
86
|
-
|
|
87
|
-
t = Timestamp(sec=0, nsec=2**32 - 1)
|
|
88
|
-
assert t.sec == 4
|
|
89
|
-
assert t.nsec == 294_967_295
|
|
90
|
-
|
|
91
|
-
t = Timestamp(sec=2**32 - 1, nsec=999_999_999)
|
|
92
|
-
assert t.sec == 2**32 - 1
|
|
93
|
-
assert t.nsec == 999_999_999
|
|
94
|
-
|
|
95
|
-
with pytest.raises(OverflowError):
|
|
96
|
-
Timestamp(sec=-1)
|
|
97
|
-
with pytest.raises(OverflowError):
|
|
98
|
-
Timestamp(sec=2**32)
|
|
99
|
-
with pytest.raises(OverflowError):
|
|
100
|
-
Timestamp(sec=0, nsec=-1)
|
|
101
|
-
with pytest.raises(OverflowError):
|
|
102
|
-
Timestamp(sec=0, nsec=2**32)
|
|
103
|
-
|
|
104
|
-
# overflow past upper bound
|
|
105
|
-
with pytest.raises(OverflowError):
|
|
106
|
-
Timestamp(sec=2**32 - 1, nsec=1_000_000_000)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def test_timestamp_from_epoch_secs() -> None:
|
|
110
|
-
assert Timestamp.from_epoch_secs(1.123) == Timestamp(sec=1, nsec=123_000_000)
|
|
111
|
-
|
|
112
|
-
with pytest.raises(OverflowError):
|
|
113
|
-
Timestamp.from_epoch_secs(-1.0)
|
|
114
|
-
|
|
115
|
-
with pytest.raises(OverflowError):
|
|
116
|
-
Timestamp.from_epoch_secs(1e42)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def test_timestamp_from_datetime() -> None:
|
|
120
|
-
utc = datetime.timezone.utc
|
|
121
|
-
dt = datetime.datetime(1970, 1, 1, tzinfo=utc)
|
|
122
|
-
assert Timestamp.from_datetime(dt) == Timestamp(sec=0)
|
|
123
|
-
|
|
124
|
-
# no loss of precision
|
|
125
|
-
dt = datetime.datetime(2025, 1, 1, microsecond=42, tzinfo=utc)
|
|
126
|
-
assert Timestamp.from_datetime(dt) == Timestamp(sec=1_735_689_600, nsec=42_000)
|
|
127
|
-
|
|
128
|
-
# alternative timezone
|
|
129
|
-
local_tz = datetime.timezone(datetime.timedelta(hours=-1))
|
|
130
|
-
dt = datetime.datetime(1970, 1, 1, 0, 0, 1, 123_000, tzinfo=local_tz)
|
|
131
|
-
assert Timestamp.from_datetime(dt) == Timestamp(sec=3601, nsec=123_000_000)
|
|
132
|
-
|
|
133
|
-
with pytest.raises(OverflowError):
|
|
134
|
-
Timestamp.from_datetime(datetime.datetime(1969, 12, 31, tzinfo=utc))
|
|
135
|
-
|
|
136
|
-
with pytest.raises(OverflowError):
|
|
137
|
-
Timestamp.from_datetime(datetime.datetime(2106, 2, 8, tzinfo=utc))
|
|
1
|
+
import datetime
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from foxglove.schemas import Duration, Timestamp
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_duration_normalization() -> None:
|
|
8
|
+
assert Duration(sec=0, nsec=1_111_222_333) == Duration(sec=1, nsec=111_222_333)
|
|
9
|
+
assert Duration(sec=0, nsec=2**32 - 1) == Duration(sec=4, nsec=294_967_295)
|
|
10
|
+
assert Duration(sec=-2, nsec=1_000_000_001) == Duration(sec=-1, nsec=1)
|
|
11
|
+
assert Duration(sec=-(2**31), nsec=1_000_000_001) == Duration(
|
|
12
|
+
sec=-(2**31) + 1, nsec=1
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# argument conversions
|
|
16
|
+
d = Duration(sec=-(2**31))
|
|
17
|
+
assert d.sec == -(2**31)
|
|
18
|
+
assert d.nsec == 0
|
|
19
|
+
|
|
20
|
+
d = Duration(sec=0, nsec=2**32 - 1)
|
|
21
|
+
assert d.sec == 4
|
|
22
|
+
assert d.nsec == 294_967_295
|
|
23
|
+
|
|
24
|
+
d = Duration(sec=2**31 - 1, nsec=999_999_999)
|
|
25
|
+
assert d.sec == 2**31 - 1
|
|
26
|
+
assert d.nsec == 999_999_999
|
|
27
|
+
|
|
28
|
+
with pytest.raises(OverflowError):
|
|
29
|
+
Duration(sec=-(2**31) - 1)
|
|
30
|
+
with pytest.raises(OverflowError):
|
|
31
|
+
Duration(sec=2**31)
|
|
32
|
+
with pytest.raises(OverflowError):
|
|
33
|
+
Duration(sec=0, nsec=-1)
|
|
34
|
+
with pytest.raises(OverflowError):
|
|
35
|
+
Duration(sec=0, nsec=2**32)
|
|
36
|
+
|
|
37
|
+
# overflow past upper bound
|
|
38
|
+
with pytest.raises(OverflowError):
|
|
39
|
+
Duration(sec=2**31 - 1, nsec=1_000_000_000)
|
|
40
|
+
|
|
41
|
+
# we don't handle this corner case, where seconds is beyond the lower
|
|
42
|
+
# bound, but nanoseconds overflow to bring the duration within range.
|
|
43
|
+
with pytest.raises(OverflowError):
|
|
44
|
+
Duration(sec=-(2**31) - 1, nsec=1_000_000_000)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_duration_from_secs() -> None:
|
|
48
|
+
assert Duration.from_secs(1.123) == Duration(sec=1, nsec=123_000_000)
|
|
49
|
+
assert Duration.from_secs(-0.123) == Duration(sec=-1, nsec=877_000_000)
|
|
50
|
+
assert Duration.from_secs(-1.123) == Duration(sec=-2, nsec=877_000_000)
|
|
51
|
+
|
|
52
|
+
with pytest.raises(OverflowError):
|
|
53
|
+
Duration.from_secs(-1e42)
|
|
54
|
+
|
|
55
|
+
with pytest.raises(OverflowError):
|
|
56
|
+
Duration.from_secs(1e42)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def test_duration_from_timedelta() -> None:
|
|
60
|
+
td = datetime.timedelta(seconds=1, milliseconds=123)
|
|
61
|
+
assert Duration.from_timedelta(td) == Duration(sec=1, nsec=123_000_000)
|
|
62
|
+
|
|
63
|
+
# no loss of precision
|
|
64
|
+
td = datetime.timedelta(days=9876, microseconds=123_456)
|
|
65
|
+
assert Duration.from_timedelta(td) == Duration(sec=853_286_400, nsec=123_456_000)
|
|
66
|
+
|
|
67
|
+
# timedeltas are normalized
|
|
68
|
+
td = datetime.timedelta(seconds=8 * 24 * 3600, milliseconds=99_111)
|
|
69
|
+
assert Duration.from_timedelta(td) == Duration(sec=691_299, nsec=111_000_000)
|
|
70
|
+
|
|
71
|
+
with pytest.raises(OverflowError):
|
|
72
|
+
Duration.from_timedelta(datetime.timedelta.min)
|
|
73
|
+
|
|
74
|
+
with pytest.raises(OverflowError):
|
|
75
|
+
Duration.from_timedelta(datetime.timedelta.max)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def test_timestamp_normalization() -> None:
|
|
79
|
+
assert Timestamp(sec=0, nsec=1_111_222_333) == Timestamp(sec=1, nsec=111_222_333)
|
|
80
|
+
assert Timestamp(sec=0, nsec=2**32 - 1) == Timestamp(sec=4, nsec=294_967_295)
|
|
81
|
+
|
|
82
|
+
# argument conversions
|
|
83
|
+
t = Timestamp(sec=0)
|
|
84
|
+
assert t.sec == 0
|
|
85
|
+
assert t.nsec == 0
|
|
86
|
+
|
|
87
|
+
t = Timestamp(sec=0, nsec=2**32 - 1)
|
|
88
|
+
assert t.sec == 4
|
|
89
|
+
assert t.nsec == 294_967_295
|
|
90
|
+
|
|
91
|
+
t = Timestamp(sec=2**32 - 1, nsec=999_999_999)
|
|
92
|
+
assert t.sec == 2**32 - 1
|
|
93
|
+
assert t.nsec == 999_999_999
|
|
94
|
+
|
|
95
|
+
with pytest.raises(OverflowError):
|
|
96
|
+
Timestamp(sec=-1)
|
|
97
|
+
with pytest.raises(OverflowError):
|
|
98
|
+
Timestamp(sec=2**32)
|
|
99
|
+
with pytest.raises(OverflowError):
|
|
100
|
+
Timestamp(sec=0, nsec=-1)
|
|
101
|
+
with pytest.raises(OverflowError):
|
|
102
|
+
Timestamp(sec=0, nsec=2**32)
|
|
103
|
+
|
|
104
|
+
# overflow past upper bound
|
|
105
|
+
with pytest.raises(OverflowError):
|
|
106
|
+
Timestamp(sec=2**32 - 1, nsec=1_000_000_000)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_timestamp_from_epoch_secs() -> None:
|
|
110
|
+
assert Timestamp.from_epoch_secs(1.123) == Timestamp(sec=1, nsec=123_000_000)
|
|
111
|
+
|
|
112
|
+
with pytest.raises(OverflowError):
|
|
113
|
+
Timestamp.from_epoch_secs(-1.0)
|
|
114
|
+
|
|
115
|
+
with pytest.raises(OverflowError):
|
|
116
|
+
Timestamp.from_epoch_secs(1e42)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def test_timestamp_from_datetime() -> None:
|
|
120
|
+
utc = datetime.timezone.utc
|
|
121
|
+
dt = datetime.datetime(1970, 1, 1, tzinfo=utc)
|
|
122
|
+
assert Timestamp.from_datetime(dt) == Timestamp(sec=0)
|
|
123
|
+
|
|
124
|
+
# no loss of precision
|
|
125
|
+
dt = datetime.datetime(2025, 1, 1, microsecond=42, tzinfo=utc)
|
|
126
|
+
assert Timestamp.from_datetime(dt) == Timestamp(sec=1_735_689_600, nsec=42_000)
|
|
127
|
+
|
|
128
|
+
# alternative timezone
|
|
129
|
+
local_tz = datetime.timezone(datetime.timedelta(hours=-1))
|
|
130
|
+
dt = datetime.datetime(1970, 1, 1, 0, 0, 1, 123_000, tzinfo=local_tz)
|
|
131
|
+
assert Timestamp.from_datetime(dt) == Timestamp(sec=3601, nsec=123_000_000)
|
|
132
|
+
|
|
133
|
+
with pytest.raises(OverflowError):
|
|
134
|
+
Timestamp.from_datetime(datetime.datetime(1969, 12, 31, tzinfo=utc))
|
|
135
|
+
|
|
136
|
+
with pytest.raises(OverflowError):
|
|
137
|
+
Timestamp.from_datetime(datetime.datetime(2106, 2, 8, tzinfo=utc))
|