quelware-core 0.1.3__tar.gz → 0.2.0__tar.gz
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.
- {quelware_core-0.1.3 → quelware_core-0.2.0}/PKG-INFO +1 -1
- {quelware_core-0.1.3 → quelware_core-0.2.0}/pyproject.toml +1 -1
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/result/__init__.py +6 -2
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/sysconf/__init__.py +13 -1
- quelware_core-0.2.0/src/quelware_core/pb/google/protobuf/__init__.py +208 -0
- quelware_core-0.2.0/src/quelware_core/pb/quelware/maintenance/v1/__init__.py +395 -0
- quelware_core-0.2.0/src/quelware_core/pb/quelware/trigger/v1/__init__.py +96 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/worker/v1/__init__.py +64 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/result/__init__.py +14 -26
- quelware_core-0.2.0/src/quelware_core/py.typed +0 -0
- quelware_core-0.2.0/tests/__init__.py +0 -0
- quelware_core-0.2.0/tests/pb_converter/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/tests/pb_converter/test_result.py +13 -40
- {quelware_core-0.1.3 → quelware_core-0.2.0}/uv.lock +1 -1
- {quelware_core-0.1.3 → quelware_core-0.2.0}/.gitignore +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/LICENSE +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/Makefile +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/README.md +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/clock/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/directives/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/instrument/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/port/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/resource/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/session/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/unit/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/user/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/waveform/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/waveform/sampled/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/worker/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/grpc_helper/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/grpc_helper/error/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/__init__.py +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb/quelware → quelware_core-0.2.0/src/quelware_core/pb/google}/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/message_pool.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/py.typed +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb/quelware/diagnostics → quelware_core-0.2.0/src/quelware_core/pb/quelware}/__init__.py +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb/quelware/instrument → quelware_core-0.2.0/src/quelware_core/pb/quelware/diagnostics}/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/diagnostics/v1/__init__.py +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb/quelware/models → quelware_core-0.2.0/src/quelware_core/pb/quelware/instrument}/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/instrument/v1/__init__.py +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb/quelware/resource → quelware_core-0.2.0/src/quelware_core/pb/quelware/maintenance}/__init__.py +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb/quelware/session → quelware_core-0.2.0/src/quelware_core/pb/quelware/models}/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/models/v1/__init__.py +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb/quelware/system_configuration → quelware_core-0.2.0/src/quelware_core/pb/quelware/resource}/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/resource/v1/__init__.py +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb/quelware/user → quelware_core-0.2.0/src/quelware_core/pb/quelware/session}/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/session/v1/__init__.py +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb/quelware/worker → quelware_core-0.2.0/src/quelware_core/pb/quelware/system_configuration}/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/system_configuration/v1/__init__.py +0 -0
- {quelware_core-0.1.3/src/quelware_core/pb_converter → quelware_core-0.2.0/src/quelware_core/pb/quelware/trigger}/__init__.py +0 -0
- {quelware_core-0.1.3/tests → quelware_core-0.2.0/src/quelware_core/pb/quelware/user}/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/user/v1/__init__.py +0 -0
- {quelware_core-0.1.3/tests/pb_converter → quelware_core-0.2.0/src/quelware_core/pb/quelware/worker}/__init__.py +0 -0
- /quelware_core-0.1.3/src/quelware_core/py.typed → /quelware_core-0.2.0/src/quelware_core/pb_converter/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/directive/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/instrument/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/port/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/resource/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/unit/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/user/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/worker/__init__.py +0 -0
- {quelware_core-0.1.3 → quelware_core-0.2.0}/tests/pb_converter/test_directive.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quelware-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Project-URL: Repository, https://github.com/quel-inc/quelware-client
|
|
5
5
|
Project-URL: Documentation, https://quel-inc.github.io/quelware-client/
|
|
6
6
|
Project-URL: Changelog, https://github.com/quel-inc/quelware-client/blob/main/quelware-core/CHANGELOG.md
|
|
@@ -4,10 +4,14 @@ from typing import TypeAlias
|
|
|
4
4
|
from quelware_core.entities.waveform.sampled import IqPoint, IqWaveform
|
|
5
5
|
|
|
6
6
|
CaptureWindowName: TypeAlias = str
|
|
7
|
-
IqResult: TypeAlias = list[IqWaveform] | list[IqPoint]
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
@dataclass
|
|
11
10
|
class ResultContainer:
|
|
12
|
-
|
|
11
|
+
iq_waveform_result: dict[CaptureWindowName, list[IqWaveform]] = field(
|
|
12
|
+
default_factory=dict
|
|
13
|
+
)
|
|
14
|
+
iq_point_result: dict[CaptureWindowName, list[IqPoint]] = field(
|
|
15
|
+
default_factory=dict
|
|
16
|
+
)
|
|
13
17
|
integer_result: dict[CaptureWindowName, list[int]] = field(default_factory=dict)
|
|
@@ -23,16 +23,26 @@ class MiscellaneousUnitType(Enum):
|
|
|
23
23
|
|
|
24
24
|
@dataclass
|
|
25
25
|
class GatewayServer:
|
|
26
|
-
name: str
|
|
26
|
+
name: str = ""
|
|
27
27
|
ipaddress: str = ""
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
@dataclass
|
|
31
|
+
class ClockConnection:
|
|
32
|
+
tdc: int = 0
|
|
33
|
+
ch: int = 0
|
|
34
|
+
dst: str = ""
|
|
35
|
+
|
|
36
|
+
|
|
30
37
|
@dataclass
|
|
31
38
|
class ClockUnit:
|
|
32
39
|
name: str
|
|
33
40
|
macaddress: str
|
|
34
41
|
ipaddress: str
|
|
35
42
|
type: ClockUnitType = ClockUnitType.UNKNOWN
|
|
43
|
+
clockconnection: list[ClockConnection] = field(default_factory=list)
|
|
44
|
+
max_tof: int = 0
|
|
45
|
+
ignored: bool = False
|
|
36
46
|
|
|
37
47
|
|
|
38
48
|
@dataclass
|
|
@@ -51,6 +61,7 @@ class MiscellaneousUnit:
|
|
|
51
61
|
type: MiscellaneousUnitType = MiscellaneousUnitType.UNKNOWN
|
|
52
62
|
macaddress: str = ""
|
|
53
63
|
ipaddress: str = ""
|
|
64
|
+
ignored: bool = False
|
|
54
65
|
|
|
55
66
|
|
|
56
67
|
@dataclass
|
|
@@ -73,6 +84,7 @@ def sysconf_from_dict(dic) -> SystemConfiguration:
|
|
|
73
84
|
|
|
74
85
|
|
|
75
86
|
__all__ = [
|
|
87
|
+
"ClockConnection",
|
|
76
88
|
"ClockUnit",
|
|
77
89
|
"ClockUnitType",
|
|
78
90
|
"ControlUnit",
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# sources: google/protobuf/timestamp.proto
|
|
3
|
+
# plugin: python-betterproto2
|
|
4
|
+
# This file has been @generated
|
|
5
|
+
|
|
6
|
+
__all__ = ("Timestamp",)
|
|
7
|
+
|
|
8
|
+
import datetime
|
|
9
|
+
import typing
|
|
10
|
+
from dataclasses import dataclass
|
|
11
|
+
|
|
12
|
+
import betterproto2
|
|
13
|
+
import dateutil.parser
|
|
14
|
+
|
|
15
|
+
from ...message_pool import default_message_pool
|
|
16
|
+
|
|
17
|
+
_COMPILER_VERSION = "0.9.0"
|
|
18
|
+
betterproto2.check_compiler_version(_COMPILER_VERSION)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(eq=False, repr=False)
|
|
22
|
+
class Timestamp(betterproto2.Message):
|
|
23
|
+
"""
|
|
24
|
+
A Timestamp represents a point in time independent of any time zone or local
|
|
25
|
+
calendar, encoded as a count of seconds and fractions of seconds at
|
|
26
|
+
nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
|
27
|
+
January 1, 1970, in the proleptic Gregorian calendar which extends the
|
|
28
|
+
Gregorian calendar backwards to year one.
|
|
29
|
+
|
|
30
|
+
All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
|
31
|
+
second table is needed for interpretation, using a [24-hour linear
|
|
32
|
+
smear](https://developers.google.com/time/smear).
|
|
33
|
+
|
|
34
|
+
The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
|
35
|
+
restricting to that range, we ensure that we can convert to and from [RFC
|
|
36
|
+
3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
|
37
|
+
|
|
38
|
+
# Examples
|
|
39
|
+
|
|
40
|
+
Example 1: Compute Timestamp from POSIX `time()`.
|
|
41
|
+
|
|
42
|
+
Timestamp timestamp;
|
|
43
|
+
timestamp.set_seconds(time(NULL));
|
|
44
|
+
timestamp.set_nanos(0);
|
|
45
|
+
|
|
46
|
+
Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
|
47
|
+
|
|
48
|
+
struct timeval tv;
|
|
49
|
+
gettimeofday(&tv, NULL);
|
|
50
|
+
|
|
51
|
+
Timestamp timestamp;
|
|
52
|
+
timestamp.set_seconds(tv.tv_sec);
|
|
53
|
+
timestamp.set_nanos(tv.tv_usec * 1000);
|
|
54
|
+
|
|
55
|
+
Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
|
56
|
+
|
|
57
|
+
FILETIME ft;
|
|
58
|
+
GetSystemTimeAsFileTime(&ft);
|
|
59
|
+
UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
|
60
|
+
|
|
61
|
+
// A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
|
62
|
+
// is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
|
63
|
+
Timestamp timestamp;
|
|
64
|
+
timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
|
65
|
+
timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
|
66
|
+
|
|
67
|
+
Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
|
68
|
+
|
|
69
|
+
long millis = System.currentTimeMillis();
|
|
70
|
+
|
|
71
|
+
Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
72
|
+
.setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
73
|
+
|
|
74
|
+
Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
75
|
+
|
|
76
|
+
Instant now = Instant.now();
|
|
77
|
+
|
|
78
|
+
Timestamp timestamp =
|
|
79
|
+
Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
80
|
+
.setNanos(now.getNano()).build();
|
|
81
|
+
|
|
82
|
+
Example 6: Compute Timestamp from current time in Python.
|
|
83
|
+
|
|
84
|
+
timestamp = Timestamp()
|
|
85
|
+
timestamp.GetCurrentTime()
|
|
86
|
+
|
|
87
|
+
# JSON Mapping
|
|
88
|
+
|
|
89
|
+
In JSON format, the Timestamp type is encoded as a string in the
|
|
90
|
+
[RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
|
91
|
+
format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
|
92
|
+
where {year} is always expressed using four digits while {month}, {day},
|
|
93
|
+
{hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
94
|
+
seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
95
|
+
are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
96
|
+
is required. A proto3 JSON serializer should always use UTC (as indicated by
|
|
97
|
+
"Z") when printing the Timestamp type and a proto3 JSON parser should be
|
|
98
|
+
able to accept both UTC and other timezones (as indicated by an offset).
|
|
99
|
+
|
|
100
|
+
For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
101
|
+
01:30 UTC on January 15, 2017.
|
|
102
|
+
|
|
103
|
+
In JavaScript, one can convert a Date object to this format using the
|
|
104
|
+
standard
|
|
105
|
+
[toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
|
106
|
+
method. In Python, a standard `datetime.datetime` object can be converted
|
|
107
|
+
to this format using
|
|
108
|
+
[`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
109
|
+
the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
110
|
+
the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
111
|
+
http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
|
|
112
|
+
) to obtain a formatter capable of generating timestamps in this format.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
seconds: "int" = betterproto2.field(1, betterproto2.TYPE_INT64)
|
|
116
|
+
"""
|
|
117
|
+
Represents seconds of UTC time since Unix epoch
|
|
118
|
+
1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
119
|
+
9999-12-31T23:59:59Z inclusive.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
nanos: "int" = betterproto2.field(2, betterproto2.TYPE_INT32)
|
|
123
|
+
"""
|
|
124
|
+
Non-negative fractions of a second at nanosecond resolution. Negative
|
|
125
|
+
second values with fractions must still have non-negative nanos values
|
|
126
|
+
that count forward in time. Must be from 0 to 999,999,999
|
|
127
|
+
inclusive.
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
@classmethod
|
|
131
|
+
def from_datetime(cls, dt: datetime.datetime) -> "Timestamp":
|
|
132
|
+
if not dt.tzinfo:
|
|
133
|
+
raise ValueError("datetime must be timezone aware")
|
|
134
|
+
|
|
135
|
+
dt = dt.astimezone(datetime.timezone.utc)
|
|
136
|
+
|
|
137
|
+
# manual epoch offset calulation to avoid rounding errors,
|
|
138
|
+
# to support negative timestamps (before 1970) and skirt
|
|
139
|
+
# around datetime bugs (apparently 0 isn't a year in [0, 9999]??)
|
|
140
|
+
offset = dt - datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc)
|
|
141
|
+
# below is the same as timedelta.total_seconds() but without dividing by 1e6
|
|
142
|
+
# so we end up with microseconds as integers instead of seconds as float
|
|
143
|
+
offset_us = (
|
|
144
|
+
offset.days * 24 * 60 * 60 + offset.seconds
|
|
145
|
+
) * 10**6 + offset.microseconds
|
|
146
|
+
seconds, us = divmod(offset_us, 10**6)
|
|
147
|
+
return cls(seconds, us * 1000)
|
|
148
|
+
|
|
149
|
+
def to_datetime(self) -> datetime.datetime:
|
|
150
|
+
# datetime.fromtimestamp() expects a timestamp in seconds, not microseconds
|
|
151
|
+
# if we pass it as a floating point number, we will run into rounding errors
|
|
152
|
+
# see also #407
|
|
153
|
+
offset = datetime.timedelta(
|
|
154
|
+
seconds=self.seconds, microseconds=self.nanos // 1000
|
|
155
|
+
)
|
|
156
|
+
return datetime.datetime(1970, 1, 1, tzinfo=datetime.timezone.utc) + offset
|
|
157
|
+
|
|
158
|
+
@staticmethod
|
|
159
|
+
def timestamp_to_json(dt: datetime.datetime) -> str:
|
|
160
|
+
nanos = dt.microsecond * 1e3
|
|
161
|
+
if dt.tzinfo is not None:
|
|
162
|
+
# change timezone aware datetime objects to utc
|
|
163
|
+
dt = dt.astimezone(datetime.timezone.utc)
|
|
164
|
+
copy = dt.replace(microsecond=0, tzinfo=None)
|
|
165
|
+
result = copy.isoformat()
|
|
166
|
+
if (nanos % 1e9) == 0:
|
|
167
|
+
# If there are 0 fractional digits, the fractional
|
|
168
|
+
# point '.' should be omitted when serializing.
|
|
169
|
+
return f"{result}Z"
|
|
170
|
+
if (nanos % 1e6) == 0:
|
|
171
|
+
# Serialize 3 fractional digits.
|
|
172
|
+
return f"{result}.{int(nanos // 1e6):03d}Z"
|
|
173
|
+
if (nanos % 1e3) == 0:
|
|
174
|
+
# Serialize 6 fractional digits.
|
|
175
|
+
return f"{result}.{int(nanos // 1e3):06d}Z"
|
|
176
|
+
# Serialize 9 fractional digits.
|
|
177
|
+
return f"{result}.{nanos:09d}"
|
|
178
|
+
|
|
179
|
+
@classmethod
|
|
180
|
+
def from_dict(cls, value, *, ignore_unknown_fields: bool = False):
|
|
181
|
+
if isinstance(value, str):
|
|
182
|
+
dt = dateutil.parser.isoparse(value)
|
|
183
|
+
dt = dt.astimezone(datetime.timezone.utc)
|
|
184
|
+
return Timestamp.from_datetime(dt)
|
|
185
|
+
|
|
186
|
+
return super().from_dict(value, ignore_unknown_fields=ignore_unknown_fields)
|
|
187
|
+
|
|
188
|
+
def to_dict(
|
|
189
|
+
self,
|
|
190
|
+
*,
|
|
191
|
+
output_format: betterproto2.OutputFormat = betterproto2.OutputFormat.PROTO_JSON,
|
|
192
|
+
casing: betterproto2.Casing = betterproto2.Casing.CAMEL,
|
|
193
|
+
include_default_values: bool = False,
|
|
194
|
+
) -> dict[str, typing.Any] | typing.Any:
|
|
195
|
+
# If the output format is PYTHON, we should have kept the wraped type without building the real class
|
|
196
|
+
assert output_format == betterproto2.OutputFormat.PROTO_JSON
|
|
197
|
+
|
|
198
|
+
return Timestamp.timestamp_to_json(self.to_datetime())
|
|
199
|
+
|
|
200
|
+
@staticmethod
|
|
201
|
+
def from_wrapped(wrapped: datetime.datetime) -> "Timestamp":
|
|
202
|
+
return Timestamp.from_datetime(wrapped)
|
|
203
|
+
|
|
204
|
+
def to_wrapped(self) -> datetime.datetime:
|
|
205
|
+
return self.to_datetime()
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
default_message_pool.register_message("google.protobuf", "Timestamp", Timestamp)
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# sources: quelware/maintenance/v1/maintenance.proto
|
|
3
|
+
# plugin: python-betterproto2
|
|
4
|
+
# This file has been @generated
|
|
5
|
+
|
|
6
|
+
__all__ = (
|
|
7
|
+
"GetMaintenanceJobRequest",
|
|
8
|
+
"GetMaintenanceJobResponse",
|
|
9
|
+
"JobKind",
|
|
10
|
+
"JobPhase",
|
|
11
|
+
"MaintenanceJob",
|
|
12
|
+
"MaintenanceServiceBase",
|
|
13
|
+
"MaintenanceServiceStub",
|
|
14
|
+
"StartLinkupRequest",
|
|
15
|
+
"StartLinkupResponse",
|
|
16
|
+
"StartTimeSyncRequest",
|
|
17
|
+
"StartTimeSyncResponse",
|
|
18
|
+
"UnitOutcome",
|
|
19
|
+
"UnitProgress",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
import datetime
|
|
23
|
+
from dataclasses import dataclass
|
|
24
|
+
from typing import TYPE_CHECKING
|
|
25
|
+
|
|
26
|
+
import betterproto2
|
|
27
|
+
import grpclib
|
|
28
|
+
from betterproto2 import grpclib as betterproto2_grpclib
|
|
29
|
+
|
|
30
|
+
from ....message_pool import default_message_pool
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
import grpclib.server
|
|
34
|
+
from betterproto2.grpclib.grpclib_client import MetadataLike
|
|
35
|
+
from grpclib.metadata import Deadline
|
|
36
|
+
|
|
37
|
+
_COMPILER_VERSION = "0.9.0"
|
|
38
|
+
betterproto2.check_compiler_version(_COMPILER_VERSION)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class JobKind(betterproto2.Enum):
|
|
42
|
+
UNSPECIFIED = 0
|
|
43
|
+
|
|
44
|
+
TIME_SYNC = 1
|
|
45
|
+
|
|
46
|
+
LINKUP = 2
|
|
47
|
+
|
|
48
|
+
@classmethod
|
|
49
|
+
def betterproto_value_to_renamed_proto_names(cls) -> dict[int, str]:
|
|
50
|
+
return {
|
|
51
|
+
0: "JOB_KIND_UNSPECIFIED",
|
|
52
|
+
1: "JOB_KIND_TIME_SYNC",
|
|
53
|
+
2: "JOB_KIND_LINKUP",
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def betterproto_renamed_proto_names_to_value(cls) -> dict[str, int]:
|
|
58
|
+
return {
|
|
59
|
+
"JOB_KIND_UNSPECIFIED": 0,
|
|
60
|
+
"JOB_KIND_TIME_SYNC": 1,
|
|
61
|
+
"JOB_KIND_LINKUP": 2,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class JobPhase(betterproto2.Enum):
|
|
66
|
+
UNSPECIFIED = 0
|
|
67
|
+
|
|
68
|
+
DRAINING = 1
|
|
69
|
+
|
|
70
|
+
SYNCING = 2
|
|
71
|
+
|
|
72
|
+
LINKING = 3
|
|
73
|
+
|
|
74
|
+
DONE = 4
|
|
75
|
+
|
|
76
|
+
FAILED = 5
|
|
77
|
+
|
|
78
|
+
@classmethod
|
|
79
|
+
def betterproto_value_to_renamed_proto_names(cls) -> dict[int, str]:
|
|
80
|
+
return {
|
|
81
|
+
0: "JOB_PHASE_UNSPECIFIED",
|
|
82
|
+
1: "JOB_PHASE_DRAINING",
|
|
83
|
+
2: "JOB_PHASE_SYNCING",
|
|
84
|
+
3: "JOB_PHASE_LINKING",
|
|
85
|
+
4: "JOB_PHASE_DONE",
|
|
86
|
+
5: "JOB_PHASE_FAILED",
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@classmethod
|
|
90
|
+
def betterproto_renamed_proto_names_to_value(cls) -> dict[str, int]:
|
|
91
|
+
return {
|
|
92
|
+
"JOB_PHASE_UNSPECIFIED": 0,
|
|
93
|
+
"JOB_PHASE_DRAINING": 1,
|
|
94
|
+
"JOB_PHASE_SYNCING": 2,
|
|
95
|
+
"JOB_PHASE_LINKING": 3,
|
|
96
|
+
"JOB_PHASE_DONE": 4,
|
|
97
|
+
"JOB_PHASE_FAILED": 5,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class UnitOutcome(betterproto2.Enum):
|
|
102
|
+
UNSPECIFIED = 0
|
|
103
|
+
|
|
104
|
+
OK = 1
|
|
105
|
+
|
|
106
|
+
SKIPPED = 2
|
|
107
|
+
|
|
108
|
+
FAILED = 3
|
|
109
|
+
|
|
110
|
+
@classmethod
|
|
111
|
+
def betterproto_value_to_renamed_proto_names(cls) -> dict[int, str]:
|
|
112
|
+
return {
|
|
113
|
+
0: "UNIT_OUTCOME_UNSPECIFIED",
|
|
114
|
+
1: "UNIT_OUTCOME_OK",
|
|
115
|
+
2: "UNIT_OUTCOME_SKIPPED",
|
|
116
|
+
3: "UNIT_OUTCOME_FAILED",
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@classmethod
|
|
120
|
+
def betterproto_renamed_proto_names_to_value(cls) -> dict[str, int]:
|
|
121
|
+
return {
|
|
122
|
+
"UNIT_OUTCOME_UNSPECIFIED": 0,
|
|
123
|
+
"UNIT_OUTCOME_OK": 1,
|
|
124
|
+
"UNIT_OUTCOME_SKIPPED": 2,
|
|
125
|
+
"UNIT_OUTCOME_FAILED": 3,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@dataclass(eq=False, repr=False)
|
|
130
|
+
class GetMaintenanceJobRequest(betterproto2.Message):
|
|
131
|
+
job_id: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
default_message_pool.register_message(
|
|
135
|
+
"quelware.maintenance.v1", "GetMaintenanceJobRequest", GetMaintenanceJobRequest
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@dataclass(eq=False, repr=False)
|
|
140
|
+
class GetMaintenanceJobResponse(betterproto2.Message):
|
|
141
|
+
job: "MaintenanceJob | None" = betterproto2.field(
|
|
142
|
+
1, betterproto2.TYPE_MESSAGE, optional=True
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
default_message_pool.register_message(
|
|
147
|
+
"quelware.maintenance.v1", "GetMaintenanceJobResponse", GetMaintenanceJobResponse
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
@dataclass(eq=False, repr=False)
|
|
152
|
+
class MaintenanceJob(betterproto2.Message):
|
|
153
|
+
job_id: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
|
|
154
|
+
|
|
155
|
+
kind: "JobKind" = betterproto2.field(
|
|
156
|
+
2, betterproto2.TYPE_ENUM, default_factory=lambda: JobKind(0)
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
phase: "JobPhase" = betterproto2.field(
|
|
160
|
+
3, betterproto2.TYPE_ENUM, default_factory=lambda: JobPhase(0)
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
started_at: "datetime.datetime | None" = betterproto2.field(
|
|
164
|
+
4,
|
|
165
|
+
betterproto2.TYPE_MESSAGE,
|
|
166
|
+
unwrap=lambda: ___google__protobuf__.Timestamp,
|
|
167
|
+
optional=True,
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
finished_at: "datetime.datetime | None" = betterproto2.field(
|
|
171
|
+
5,
|
|
172
|
+
betterproto2.TYPE_MESSAGE,
|
|
173
|
+
unwrap=lambda: ___google__protobuf__.Timestamp,
|
|
174
|
+
optional=True,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
error: "str" = betterproto2.field(6, betterproto2.TYPE_STRING)
|
|
178
|
+
|
|
179
|
+
unit_progress: "list[UnitProgress]" = betterproto2.field(
|
|
180
|
+
7, betterproto2.TYPE_MESSAGE, repeated=True
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
default_message_pool.register_message(
|
|
185
|
+
"quelware.maintenance.v1", "MaintenanceJob", MaintenanceJob
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
@dataclass(eq=False, repr=False)
|
|
190
|
+
class StartLinkupRequest(betterproto2.Message):
|
|
191
|
+
pass
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
default_message_pool.register_message(
|
|
195
|
+
"quelware.maintenance.v1", "StartLinkupRequest", StartLinkupRequest
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
@dataclass(eq=False, repr=False)
|
|
200
|
+
class StartLinkupResponse(betterproto2.Message):
|
|
201
|
+
job_id: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
default_message_pool.register_message(
|
|
205
|
+
"quelware.maintenance.v1", "StartLinkupResponse", StartLinkupResponse
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@dataclass(eq=False, repr=False)
|
|
210
|
+
class StartTimeSyncRequest(betterproto2.Message):
|
|
211
|
+
pass
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
default_message_pool.register_message(
|
|
215
|
+
"quelware.maintenance.v1", "StartTimeSyncRequest", StartTimeSyncRequest
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
@dataclass(eq=False, repr=False)
|
|
220
|
+
class StartTimeSyncResponse(betterproto2.Message):
|
|
221
|
+
job_id: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
default_message_pool.register_message(
|
|
225
|
+
"quelware.maintenance.v1", "StartTimeSyncResponse", StartTimeSyncResponse
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@dataclass(eq=False, repr=False)
|
|
230
|
+
class UnitProgress(betterproto2.Message):
|
|
231
|
+
unit_label: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
|
|
232
|
+
|
|
233
|
+
phase: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
|
|
234
|
+
|
|
235
|
+
outcome: "UnitOutcome" = betterproto2.field(
|
|
236
|
+
3, betterproto2.TYPE_ENUM, default_factory=lambda: UnitOutcome(0)
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
detail: "str" = betterproto2.field(4, betterproto2.TYPE_STRING)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
default_message_pool.register_message(
|
|
243
|
+
"quelware.maintenance.v1", "UnitProgress", UnitProgress
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
class MaintenanceServiceStub(betterproto2_grpclib.ServiceStub):
|
|
248
|
+
async def start_time_sync(
|
|
249
|
+
self,
|
|
250
|
+
message: "StartTimeSyncRequest | None" = None,
|
|
251
|
+
*,
|
|
252
|
+
timeout: "float | None" = None,
|
|
253
|
+
deadline: "Deadline | None" = None,
|
|
254
|
+
metadata: "MetadataLike | None" = None,
|
|
255
|
+
) -> "StartTimeSyncResponse":
|
|
256
|
+
"""
|
|
257
|
+
Drain all units, then run system-wide time synchronization.
|
|
258
|
+
"""
|
|
259
|
+
|
|
260
|
+
if message is None:
|
|
261
|
+
message = StartTimeSyncRequest()
|
|
262
|
+
|
|
263
|
+
return await self._unary_unary(
|
|
264
|
+
"/quelware.maintenance.v1.MaintenanceService/StartTimeSync",
|
|
265
|
+
message,
|
|
266
|
+
StartTimeSyncResponse,
|
|
267
|
+
timeout=timeout,
|
|
268
|
+
deadline=deadline,
|
|
269
|
+
metadata=metadata,
|
|
270
|
+
)
|
|
271
|
+
|
|
272
|
+
async def start_linkup(
|
|
273
|
+
self,
|
|
274
|
+
message: "StartLinkupRequest | None" = None,
|
|
275
|
+
*,
|
|
276
|
+
timeout: "float | None" = None,
|
|
277
|
+
deadline: "Deadline | None" = None,
|
|
278
|
+
metadata: "MetadataLike | None" = None,
|
|
279
|
+
) -> "StartLinkupResponse":
|
|
280
|
+
"""
|
|
281
|
+
Drain all units, then trigger linkup on each in parallel.
|
|
282
|
+
"""
|
|
283
|
+
|
|
284
|
+
if message is None:
|
|
285
|
+
message = StartLinkupRequest()
|
|
286
|
+
|
|
287
|
+
return await self._unary_unary(
|
|
288
|
+
"/quelware.maintenance.v1.MaintenanceService/StartLinkup",
|
|
289
|
+
message,
|
|
290
|
+
StartLinkupResponse,
|
|
291
|
+
timeout=timeout,
|
|
292
|
+
deadline=deadline,
|
|
293
|
+
metadata=metadata,
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
async def get_maintenance_job(
|
|
297
|
+
self,
|
|
298
|
+
message: "GetMaintenanceJobRequest",
|
|
299
|
+
*,
|
|
300
|
+
timeout: "float | None" = None,
|
|
301
|
+
deadline: "Deadline | None" = None,
|
|
302
|
+
metadata: "MetadataLike | None" = None,
|
|
303
|
+
) -> "GetMaintenanceJobResponse":
|
|
304
|
+
"""
|
|
305
|
+
Poll the state of a previously started job.
|
|
306
|
+
"""
|
|
307
|
+
|
|
308
|
+
return await self._unary_unary(
|
|
309
|
+
"/quelware.maintenance.v1.MaintenanceService/GetMaintenanceJob",
|
|
310
|
+
message,
|
|
311
|
+
GetMaintenanceJobResponse,
|
|
312
|
+
timeout=timeout,
|
|
313
|
+
deadline=deadline,
|
|
314
|
+
metadata=metadata,
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
from ....google import protobuf as ___google__protobuf__
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
class MaintenanceServiceBase(betterproto2_grpclib.ServiceBase):
|
|
322
|
+
async def start_time_sync(
|
|
323
|
+
self, message: "StartTimeSyncRequest"
|
|
324
|
+
) -> "StartTimeSyncResponse":
|
|
325
|
+
"""
|
|
326
|
+
Drain all units, then run system-wide time synchronization.
|
|
327
|
+
"""
|
|
328
|
+
|
|
329
|
+
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
330
|
+
|
|
331
|
+
async def start_linkup(
|
|
332
|
+
self, message: "StartLinkupRequest"
|
|
333
|
+
) -> "StartLinkupResponse":
|
|
334
|
+
"""
|
|
335
|
+
Drain all units, then trigger linkup on each in parallel.
|
|
336
|
+
"""
|
|
337
|
+
|
|
338
|
+
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
339
|
+
|
|
340
|
+
async def get_maintenance_job(
|
|
341
|
+
self, message: "GetMaintenanceJobRequest"
|
|
342
|
+
) -> "GetMaintenanceJobResponse":
|
|
343
|
+
"""
|
|
344
|
+
Poll the state of a previously started job.
|
|
345
|
+
"""
|
|
346
|
+
|
|
347
|
+
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
348
|
+
|
|
349
|
+
async def __rpc_start_time_sync(
|
|
350
|
+
self,
|
|
351
|
+
stream: "grpclib.server.Stream[StartTimeSyncRequest, StartTimeSyncResponse]",
|
|
352
|
+
) -> None:
|
|
353
|
+
request = await stream.recv_message()
|
|
354
|
+
assert request is not None
|
|
355
|
+
response = await self.start_time_sync(request)
|
|
356
|
+
await stream.send_message(response)
|
|
357
|
+
|
|
358
|
+
async def __rpc_start_linkup(
|
|
359
|
+
self, stream: "grpclib.server.Stream[StartLinkupRequest, StartLinkupResponse]"
|
|
360
|
+
) -> None:
|
|
361
|
+
request = await stream.recv_message()
|
|
362
|
+
assert request is not None
|
|
363
|
+
response = await self.start_linkup(request)
|
|
364
|
+
await stream.send_message(response)
|
|
365
|
+
|
|
366
|
+
async def __rpc_get_maintenance_job(
|
|
367
|
+
self,
|
|
368
|
+
stream: "grpclib.server.Stream[GetMaintenanceJobRequest, GetMaintenanceJobResponse]",
|
|
369
|
+
) -> None:
|
|
370
|
+
request = await stream.recv_message()
|
|
371
|
+
assert request is not None
|
|
372
|
+
response = await self.get_maintenance_job(request)
|
|
373
|
+
await stream.send_message(response)
|
|
374
|
+
|
|
375
|
+
def __mapping__(self) -> "dict[str, grpclib.const.Handler]":
|
|
376
|
+
return {
|
|
377
|
+
"/quelware.maintenance.v1.MaintenanceService/StartTimeSync": grpclib.const.Handler(
|
|
378
|
+
self.__rpc_start_time_sync,
|
|
379
|
+
grpclib.const.Cardinality.UNARY_UNARY,
|
|
380
|
+
StartTimeSyncRequest,
|
|
381
|
+
StartTimeSyncResponse,
|
|
382
|
+
),
|
|
383
|
+
"/quelware.maintenance.v1.MaintenanceService/StartLinkup": grpclib.const.Handler(
|
|
384
|
+
self.__rpc_start_linkup,
|
|
385
|
+
grpclib.const.Cardinality.UNARY_UNARY,
|
|
386
|
+
StartLinkupRequest,
|
|
387
|
+
StartLinkupResponse,
|
|
388
|
+
),
|
|
389
|
+
"/quelware.maintenance.v1.MaintenanceService/GetMaintenanceJob": grpclib.const.Handler(
|
|
390
|
+
self.__rpc_get_maintenance_job,
|
|
391
|
+
grpclib.const.Cardinality.UNARY_UNARY,
|
|
392
|
+
GetMaintenanceJobRequest,
|
|
393
|
+
GetMaintenanceJobResponse,
|
|
394
|
+
),
|
|
395
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
|
2
|
+
# sources: quelware/trigger/v1/trigger.proto
|
|
3
|
+
# plugin: python-betterproto2
|
|
4
|
+
# This file has been @generated
|
|
5
|
+
|
|
6
|
+
__all__ = (
|
|
7
|
+
"TriggerRequest",
|
|
8
|
+
"TriggerResponse",
|
|
9
|
+
"TriggerServiceBase",
|
|
10
|
+
"TriggerServiceStub",
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from dataclasses import dataclass
|
|
14
|
+
from typing import TYPE_CHECKING
|
|
15
|
+
|
|
16
|
+
import betterproto2
|
|
17
|
+
import grpclib
|
|
18
|
+
from betterproto2 import grpclib as betterproto2_grpclib
|
|
19
|
+
|
|
20
|
+
from ....message_pool import default_message_pool
|
|
21
|
+
|
|
22
|
+
if TYPE_CHECKING:
|
|
23
|
+
import grpclib.server
|
|
24
|
+
from betterproto2.grpclib.grpclib_client import MetadataLike
|
|
25
|
+
from grpclib.metadata import Deadline
|
|
26
|
+
|
|
27
|
+
_COMPILER_VERSION = "0.9.0"
|
|
28
|
+
betterproto2.check_compiler_version(_COMPILER_VERSION)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass(eq=False, repr=False)
|
|
32
|
+
class TriggerRequest(betterproto2.Message):
|
|
33
|
+
instrument_ids: "list[str]" = betterproto2.field(
|
|
34
|
+
1, betterproto2.TYPE_STRING, repeated=True
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
requested_min_wait_ms: "int | None" = betterproto2.field(
|
|
38
|
+
2, betterproto2.TYPE_UINT32, optional=True
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
default_message_pool.register_message(
|
|
43
|
+
"quelware.trigger.v1", "TriggerRequest", TriggerRequest
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass(eq=False, repr=False)
|
|
48
|
+
class TriggerResponse(betterproto2.Message):
|
|
49
|
+
scheduled_clock_count: "int" = betterproto2.field(1, betterproto2.TYPE_UINT64)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
default_message_pool.register_message(
|
|
53
|
+
"quelware.trigger.v1", "TriggerResponse", TriggerResponse
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class TriggerServiceStub(betterproto2_grpclib.ServiceStub):
|
|
58
|
+
async def trigger(
|
|
59
|
+
self,
|
|
60
|
+
message: "TriggerRequest",
|
|
61
|
+
*,
|
|
62
|
+
timeout: "float | None" = None,
|
|
63
|
+
deadline: "Deadline | None" = None,
|
|
64
|
+
metadata: "MetadataLike | None" = None,
|
|
65
|
+
) -> "TriggerResponse":
|
|
66
|
+
return await self._unary_unary(
|
|
67
|
+
"/quelware.trigger.v1.TriggerService/Trigger",
|
|
68
|
+
message,
|
|
69
|
+
TriggerResponse,
|
|
70
|
+
timeout=timeout,
|
|
71
|
+
deadline=deadline,
|
|
72
|
+
metadata=metadata,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class TriggerServiceBase(betterproto2_grpclib.ServiceBase):
|
|
77
|
+
async def trigger(self, message: "TriggerRequest") -> "TriggerResponse":
|
|
78
|
+
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
79
|
+
|
|
80
|
+
async def __rpc_trigger(
|
|
81
|
+
self, stream: "grpclib.server.Stream[TriggerRequest, TriggerResponse]"
|
|
82
|
+
) -> None:
|
|
83
|
+
request = await stream.recv_message()
|
|
84
|
+
assert request is not None
|
|
85
|
+
response = await self.trigger(request)
|
|
86
|
+
await stream.send_message(response)
|
|
87
|
+
|
|
88
|
+
def __mapping__(self) -> "dict[str, grpclib.const.Handler]":
|
|
89
|
+
return {
|
|
90
|
+
"/quelware.trigger.v1.TriggerService/Trigger": grpclib.const.Handler(
|
|
91
|
+
self.__rpc_trigger,
|
|
92
|
+
grpclib.const.Cardinality.UNARY_UNARY,
|
|
93
|
+
TriggerRequest,
|
|
94
|
+
TriggerResponse,
|
|
95
|
+
),
|
|
96
|
+
}
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/worker/v1/__init__.py
RENAMED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
# This file has been @generated
|
|
5
5
|
|
|
6
6
|
__all__ = (
|
|
7
|
+
"GetClockSnapshotRequest",
|
|
8
|
+
"GetClockSnapshotResponse",
|
|
7
9
|
"GetVersionRequest",
|
|
8
10
|
"GetVersionResponse",
|
|
9
11
|
"GetWorkerStatusRequest",
|
|
@@ -30,6 +32,28 @@ _COMPILER_VERSION = "0.9.0"
|
|
|
30
32
|
betterproto2.check_compiler_version(_COMPILER_VERSION)
|
|
31
33
|
|
|
32
34
|
|
|
35
|
+
@dataclass(eq=False, repr=False)
|
|
36
|
+
class GetClockSnapshotRequest(betterproto2.Message):
|
|
37
|
+
pass
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
default_message_pool.register_message(
|
|
41
|
+
"quelware.worker.v1", "GetClockSnapshotRequest", GetClockSnapshotRequest
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@dataclass(eq=False, repr=False)
|
|
46
|
+
class GetClockSnapshotResponse(betterproto2.Message):
|
|
47
|
+
current_count: "int" = betterproto2.field(1, betterproto2.TYPE_UINT64)
|
|
48
|
+
|
|
49
|
+
reference_count: "int" = betterproto2.field(2, betterproto2.TYPE_UINT64)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
default_message_pool.register_message(
|
|
53
|
+
"quelware.worker.v1", "GetClockSnapshotResponse", GetClockSnapshotResponse
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
33
57
|
@dataclass(eq=False, repr=False)
|
|
34
58
|
class GetVersionRequest(betterproto2.Message):
|
|
35
59
|
pass
|
|
@@ -115,6 +139,26 @@ class WorkerServiceStub(betterproto2_grpclib.ServiceStub):
|
|
|
115
139
|
metadata=metadata,
|
|
116
140
|
)
|
|
117
141
|
|
|
142
|
+
async def get_clock_snapshot(
|
|
143
|
+
self,
|
|
144
|
+
message: "GetClockSnapshotRequest | None" = None,
|
|
145
|
+
*,
|
|
146
|
+
timeout: "float | None" = None,
|
|
147
|
+
deadline: "Deadline | None" = None,
|
|
148
|
+
metadata: "MetadataLike | None" = None,
|
|
149
|
+
) -> "GetClockSnapshotResponse":
|
|
150
|
+
if message is None:
|
|
151
|
+
message = GetClockSnapshotRequest()
|
|
152
|
+
|
|
153
|
+
return await self._unary_unary(
|
|
154
|
+
"/quelware.worker.v1.WorkerService/GetClockSnapshot",
|
|
155
|
+
message,
|
|
156
|
+
GetClockSnapshotResponse,
|
|
157
|
+
timeout=timeout,
|
|
158
|
+
deadline=deadline,
|
|
159
|
+
metadata=metadata,
|
|
160
|
+
)
|
|
161
|
+
|
|
118
162
|
|
|
119
163
|
from ...models import v1 as __models__v1__
|
|
120
164
|
|
|
@@ -128,6 +172,11 @@ class WorkerServiceBase(betterproto2_grpclib.ServiceBase):
|
|
|
128
172
|
) -> "GetWorkerStatusResponse":
|
|
129
173
|
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
130
174
|
|
|
175
|
+
async def get_clock_snapshot(
|
|
176
|
+
self, message: "GetClockSnapshotRequest"
|
|
177
|
+
) -> "GetClockSnapshotResponse":
|
|
178
|
+
raise grpclib.GRPCError(grpclib.const.Status.UNIMPLEMENTED)
|
|
179
|
+
|
|
131
180
|
async def __rpc_get_version(
|
|
132
181
|
self, stream: "grpclib.server.Stream[GetVersionRequest, GetVersionResponse]"
|
|
133
182
|
) -> None:
|
|
@@ -145,6 +194,15 @@ class WorkerServiceBase(betterproto2_grpclib.ServiceBase):
|
|
|
145
194
|
response = await self.get_worker_status(request)
|
|
146
195
|
await stream.send_message(response)
|
|
147
196
|
|
|
197
|
+
async def __rpc_get_clock_snapshot(
|
|
198
|
+
self,
|
|
199
|
+
stream: "grpclib.server.Stream[GetClockSnapshotRequest, GetClockSnapshotResponse]",
|
|
200
|
+
) -> None:
|
|
201
|
+
request = await stream.recv_message()
|
|
202
|
+
assert request is not None
|
|
203
|
+
response = await self.get_clock_snapshot(request)
|
|
204
|
+
await stream.send_message(response)
|
|
205
|
+
|
|
148
206
|
def __mapping__(self) -> "dict[str, grpclib.const.Handler]":
|
|
149
207
|
return {
|
|
150
208
|
"/quelware.worker.v1.WorkerService/GetVersion": grpclib.const.Handler(
|
|
@@ -159,4 +217,10 @@ class WorkerServiceBase(betterproto2_grpclib.ServiceBase):
|
|
|
159
217
|
GetWorkerStatusRequest,
|
|
160
218
|
GetWorkerStatusResponse,
|
|
161
219
|
),
|
|
220
|
+
"/quelware.worker.v1.WorkerService/GetClockSnapshot": grpclib.const.Handler(
|
|
221
|
+
self.__rpc_get_clock_snapshot,
|
|
222
|
+
grpclib.const.Cardinality.UNARY_UNARY,
|
|
223
|
+
GetClockSnapshotRequest,
|
|
224
|
+
GetClockSnapshotResponse,
|
|
225
|
+
),
|
|
162
226
|
}
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/result/__init__.py
RENAMED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
from typing import cast
|
|
2
|
-
|
|
3
1
|
import betterproto2
|
|
4
2
|
|
|
5
3
|
import quelware_core.pb.quelware.models.v1 as pb_models
|
|
6
4
|
from quelware_core.entities.result import ResultContainer
|
|
7
|
-
from quelware_core.entities.waveform.sampled import IqWaveform
|
|
8
5
|
from quelware_core.pb_converter.directive import (
|
|
9
6
|
iq_waveform_from_pb,
|
|
10
7
|
iq_waveform_to_pb,
|
|
@@ -22,26 +19,20 @@ def _pb_point_to_complex(pb: pb_models.IqPoint) -> complex:
|
|
|
22
19
|
def result_container_to_pb(entity: ResultContainer) -> pb_models.ResultContainer:
|
|
23
20
|
pb = pb_models.ResultContainer()
|
|
24
21
|
|
|
25
|
-
for name,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
first_item = data[0]
|
|
31
|
-
if isinstance(first_item, IqWaveform):
|
|
32
|
-
waveforms_pb = [iq_waveform_to_pb(cast(IqWaveform, wf)) for wf in data]
|
|
33
|
-
pb.iq_result[name] = pb_models.IqResult(
|
|
34
|
-
waveforms=pb_models.WaveformList(
|
|
35
|
-
waveforms=[w.sampled for w in waveforms_pb if w.sampled]
|
|
36
|
-
)
|
|
22
|
+
for name, waves in entity.iq_waveform_result.items():
|
|
23
|
+
waveforms_pb = [iq_waveform_to_pb(w) for w in waves]
|
|
24
|
+
pb.iq_result[name] = pb_models.IqResult(
|
|
25
|
+
waveforms=pb_models.WaveformList(
|
|
26
|
+
waveforms=[w.sampled for w in waveforms_pb if w.sampled]
|
|
37
27
|
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
for name, points in entity.iq_point_result.items():
|
|
31
|
+
pb.iq_result[name] = pb_models.IqResult(
|
|
32
|
+
iq_points=pb_models.IqPointList(
|
|
33
|
+
iq_points=[_complex_to_pb_point(p) for p in points]
|
|
42
34
|
)
|
|
43
|
-
|
|
44
|
-
raise ValueError(f"Unsupported data type in iq_result: {type(first_item)}")
|
|
35
|
+
)
|
|
45
36
|
|
|
46
37
|
for name, int_data in entity.integer_result.items():
|
|
47
38
|
pb.integer_result[name] = pb_models.IntegerResult(integers=int_data)
|
|
@@ -54,19 +45,16 @@ def result_container_from_pb(pb: pb_models.ResultContainer) -> ResultContainer:
|
|
|
54
45
|
|
|
55
46
|
for name, iq_res_pb in pb.iq_result.items():
|
|
56
47
|
_, val = betterproto2.which_one_of(iq_res_pb, "result")
|
|
57
|
-
|
|
58
48
|
match val:
|
|
59
49
|
case pb_models.WaveformList():
|
|
60
|
-
entity.
|
|
50
|
+
entity.iq_waveform_result[name] = [
|
|
61
51
|
iq_waveform_from_pb(pb_models.Waveform(sampled=wf))
|
|
62
52
|
for wf in val.waveforms
|
|
63
53
|
]
|
|
64
54
|
case pb_models.IqPointList():
|
|
65
|
-
entity.
|
|
55
|
+
entity.iq_point_result[name] = [
|
|
66
56
|
_pb_point_to_complex(pt) for pt in val.iq_points
|
|
67
57
|
]
|
|
68
|
-
case _:
|
|
69
|
-
entity.iq_result[name] = []
|
|
70
58
|
|
|
71
59
|
for name, int_res_pb in pb.integer_result.items():
|
|
72
60
|
entity.integer_result[name] = list(int_res_pb.integers)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import numpy as np
|
|
2
|
-
import pytest
|
|
3
2
|
|
|
4
3
|
from quelware_core.entities.result import ResultContainer
|
|
5
4
|
from quelware_core.entities.waveform.sampled import IqWaveform
|
|
@@ -19,22 +18,18 @@ def test_result_container_waveforms_roundtrip():
|
|
|
19
18
|
iq_array=np.array([0.0 + 0.0j], dtype=np.complex128),
|
|
20
19
|
)
|
|
21
20
|
|
|
22
|
-
original = ResultContainer(
|
|
23
|
-
iq_result={"readout_0": [wave1, wave2]}, integer_result={}
|
|
24
|
-
)
|
|
21
|
+
original = ResultContainer(iq_waveform_result={"readout_0": [wave1, wave2]})
|
|
25
22
|
|
|
26
23
|
pb = result_container_to_pb(original)
|
|
27
24
|
recovered = result_container_from_pb(pb)
|
|
28
25
|
|
|
29
|
-
assert "readout_0" in recovered.
|
|
30
|
-
recovered_waves = recovered.
|
|
26
|
+
assert "readout_0" in recovered.iq_waveform_result
|
|
27
|
+
recovered_waves = recovered.iq_waveform_result["readout_0"]
|
|
31
28
|
assert len(recovered_waves) == 2
|
|
32
29
|
|
|
33
|
-
assert isinstance(recovered_waves[0], IqWaveform)
|
|
34
30
|
assert recovered_waves[0].sampling_period_fs == 1_000_000
|
|
35
31
|
np.testing.assert_array_equal(recovered_waves[0].iq_array, wave1.iq_array)
|
|
36
32
|
|
|
37
|
-
assert isinstance(recovered_waves[1], IqWaveform)
|
|
38
33
|
assert recovered_waves[1].sampling_period_fs == 2_000_000
|
|
39
34
|
np.testing.assert_array_equal(recovered_waves[1].iq_array, wave2.iq_array)
|
|
40
35
|
|
|
@@ -42,27 +37,22 @@ def test_result_container_waveforms_roundtrip():
|
|
|
42
37
|
def test_result_container_complex_points_roundtrip():
|
|
43
38
|
original_points = [1.0 + 2.0j, -3.0 - 4.0j, 0.0 + 0.0j]
|
|
44
39
|
|
|
45
|
-
original = ResultContainer(
|
|
46
|
-
iq_result={"readout_1": original_points}, integer_result={}
|
|
47
|
-
)
|
|
40
|
+
original = ResultContainer(iq_point_result={"readout_1": original_points})
|
|
48
41
|
|
|
49
42
|
pb = result_container_to_pb(original)
|
|
50
43
|
recovered = result_container_from_pb(pb)
|
|
51
44
|
|
|
52
|
-
assert "readout_1" in recovered.
|
|
53
|
-
recovered_points = recovered.
|
|
45
|
+
assert "readout_1" in recovered.iq_point_result
|
|
46
|
+
recovered_points = recovered.iq_point_result["readout_1"]
|
|
54
47
|
|
|
55
48
|
assert len(recovered_points) == 3
|
|
56
|
-
assert isinstance(recovered_points[0], complex)
|
|
57
49
|
assert recovered_points == original_points
|
|
58
50
|
|
|
59
51
|
|
|
60
52
|
def test_result_container_integers_roundtrip():
|
|
61
53
|
original_ints = [100, 200, 0, -1]
|
|
62
54
|
|
|
63
|
-
original = ResultContainer(
|
|
64
|
-
iq_result={}, integer_result={"counter_0": original_ints}
|
|
65
|
-
)
|
|
55
|
+
original = ResultContainer(integer_result={"counter_0": original_ints})
|
|
66
56
|
|
|
67
57
|
pb = result_container_to_pb(original)
|
|
68
58
|
recovered = result_container_from_pb(pb)
|
|
@@ -71,13 +61,10 @@ def test_result_container_integers_roundtrip():
|
|
|
71
61
|
assert recovered.integer_result["counter_0"] == original_ints
|
|
72
62
|
|
|
73
63
|
|
|
74
|
-
def
|
|
64
|
+
def test_result_container_mixed_roundtrip():
|
|
75
65
|
original = ResultContainer(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"point_ch": [1 + 1j],
|
|
79
|
-
"empty_ch": [],
|
|
80
|
-
},
|
|
66
|
+
iq_waveform_result={"wave_ch": [IqWaveform(100, np.array([1j]))]},
|
|
67
|
+
iq_point_result={"point_ch": [1 + 1j]},
|
|
81
68
|
integer_result={
|
|
82
69
|
"int_ch": [123],
|
|
83
70
|
"empty_int_ch": [],
|
|
@@ -87,23 +74,9 @@ def test_result_container_mixed_and_empty_roundtrip():
|
|
|
87
74
|
pb = result_container_to_pb(original)
|
|
88
75
|
recovered = result_container_from_pb(pb)
|
|
89
76
|
|
|
90
|
-
assert len(recovered.
|
|
91
|
-
assert
|
|
92
|
-
|
|
93
|
-
assert len(recovered.iq_result["point_ch"]) == 1
|
|
94
|
-
assert isinstance(recovered.iq_result["point_ch"][0], complex)
|
|
95
|
-
|
|
96
|
-
assert recovered.iq_result["empty_ch"] == []
|
|
77
|
+
assert len(recovered.iq_waveform_result["wave_ch"]) == 1
|
|
78
|
+
assert len(recovered.iq_point_result["point_ch"]) == 1
|
|
79
|
+
assert recovered.iq_point_result["point_ch"][0] == 1 + 1j
|
|
97
80
|
|
|
98
81
|
assert recovered.integer_result["int_ch"] == [123]
|
|
99
82
|
assert recovered.integer_result["empty_int_ch"] == []
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
def test_invalid_type_raises_error():
|
|
103
|
-
original = ResultContainer(
|
|
104
|
-
iq_result={"invalid": ["invalid_string_data"]}, # type: ignore
|
|
105
|
-
integer_result={},
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
with pytest.raises(ValueError, match="Unsupported data type"):
|
|
109
|
-
result_container_to_pb(original)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/directives/__init__.py
RENAMED
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/instrument/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/entities/waveform/sampled/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/diagnostics/v1/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/instrument/v1/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/models/v1/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/resource/v1/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/session/v1/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3/tests → quelware_core-0.2.0/src/quelware_core/pb/quelware/user}/__init__.py
RENAMED
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb/quelware/user/v1/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/directive/__init__.py
RENAMED
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/instrument/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/resource/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{quelware_core-0.1.3 → quelware_core-0.2.0}/src/quelware_core/pb_converter/worker/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|