auto-trainer-api 0.10.3__tar.gz → 0.11.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.
Files changed (43) hide show
  1. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/PKG-INFO +1 -1
  2. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/__init__.py +1 -0
  3. auto_trainer_api-0.11.0/src/autotrainer/api/api_emergency_stop.py +17 -0
  4. auto_trainer_api-0.11.0/src/autotrainer/api/command/api_command.py +105 -0
  5. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/event/api_event_kind.py +1 -1
  6. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/event/api_event_payloads.py +25 -2
  7. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/event/build_event.py +1 -1
  8. auto_trainer_api-0.10.3/src/autotrainer/api/command/api_command.py +0 -54
  9. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/.gitignore +0 -0
  10. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/README.md +0 -0
  11. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/publish-testpypi.py +0 -0
  12. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/pyproject.toml +0 -0
  13. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/api_alarm_kind.py +0 -0
  14. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/api_application_mode.py +0 -0
  15. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/api_detector_kind.py +0 -0
  16. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/api_options.py +0 -0
  17. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/api_system_configuration.py +0 -0
  18. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/api_system_status.py +0 -0
  19. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/api_training_mode.py +0 -0
  20. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/bridge/__init__.py +0 -0
  21. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/bridge/__main__.py +0 -0
  22. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/bridge/bridge_app.py +0 -0
  23. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/bridge/bridge_service.py +0 -0
  24. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/command/__init__.py +0 -0
  25. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/command/api_command_request.py +0 -0
  26. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/command/api_command_request_response.py +0 -0
  27. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/command/api_command_request_result.py +0 -0
  28. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/command/command_request_delegate.py +0 -0
  29. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/event/__init__.py +0 -0
  30. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/event/api_event.py +0 -0
  31. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/rpc_service.py +0 -0
  32. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/telemetry/__init__.py +0 -0
  33. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/telemetry/open_telemetry_service.py +0 -0
  34. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/util.py +0 -0
  35. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/zeromq/__init__.py +0 -0
  36. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/src/autotrainer/api/zeromq/zeromq_api_service.py +0 -0
  37. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/tests/test_api_basics.py +0 -0
  38. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/tests/test_api_event.py +0 -0
  39. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/tests/test_bridge_service.py +0 -0
  40. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/tests/test_build_event.py +0 -0
  41. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/tests/test_resolve_enum.py +0 -0
  42. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/tests/test_util.py +0 -0
  43. {auto_trainer_api-0.10.3 → auto_trainer_api-0.11.0}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: auto-trainer-api
3
- Version: 0.10.3
3
+ Version: 0.11.0
4
4
  Summary: API for interfacing with the core acquisition process via platform and language agnostic message queues.
5
5
  License: AGPL-3.0-only
6
6
  Classifier: Operating System :: OS Independent
@@ -12,6 +12,7 @@ from .api_system_status import ApiSystemStatus, ApiPelletDeviceStatus, ApiTunnel
12
12
  ApiAlarmStatus, ApiProjectStatus, ApiAnimalStatus
13
13
  from .api_alarm_kind import ApiAlarmKind
14
14
  from .api_detector_kind import ApiDetectorKind
15
+ from .api_emergency_stop import ApiEmergencyStopReason, ApiEmergencyResumeReason
15
16
  from .api_system_configuration import ApiSystemConfiguration
16
17
  from .command import ApiCommand, ApiCommandRequestResponse, ApiCommandRequestResult, ApiCommandRequest
17
18
  from .rpc_service import ApiTopic, ApiCommandRequestErrorKind, RpcService
@@ -0,0 +1,17 @@
1
+ from enum import IntEnum
2
+
3
+
4
+ class ApiEmergencyStopReason(IntEnum):
5
+ unknown = 0
6
+ alarm_monitor = 101
7
+ diamond_coord_check = 201
8
+ user_button = 301
9
+ rpc_service = 401
10
+
11
+
12
+ class ApiEmergencyResumeReason(IntEnum):
13
+ unknown = 0
14
+ alarm_monitor_resume = 101
15
+ alarm_monitor_status_change = 201 # "alarm-monitor-no-valid-condition-remaining" reason
16
+ user_button = 301
17
+ rpc_service = 401
@@ -0,0 +1,105 @@
1
+ from enum import IntEnum
2
+
3
+
4
+ class ApiCommand(IntEnum):
5
+ """
6
+ A command value is required for all command requests.
7
+
8
+ Each member documents its request payload (`data` on the request), its response payload (`data` on the
9
+ `ApiCommandRequestResponse`), and the `ApiCommandRequestResult` a receiver is expected to return. The
10
+ `GET_*` commands are queries: they must not change any state or publish any event. A command that changes
11
+ state is expected to publish the event that a state change of that kind normally publishes, so subscribers
12
+ see the same thing whether the change came from a command or from the application itself.
13
+ """
14
+ NONE = 0
15
+ """No command. Can be used to verify connection or that the receiver is configured to receive commands.
16
+
17
+ Changes no state and publishes no event.
18
+ Response Payload: None
19
+ Result: SUCCESS
20
+ """
21
+
22
+ START_ACQUISITION = 50
23
+ """ Obsolete
24
+
25
+ Result: UNRECOGNIZED
26
+ """
27
+
28
+ STOP_ACQUISITION = 55
29
+ """ Obsolete
30
+
31
+ Result: UNRECOGNIZED
32
+ """
33
+
34
+ SET_APPLICATION_MODE = 120
35
+ """
36
+ Payload: {mode: ApiApplicationMode}
37
+ The response is application mode after attempting to set. Typically the same as the payload, but if for some reason
38
+ the mode is invalid in the current context, it should return the actual mode.
39
+ Response Payload: {mode: ApiApplicationMode}
40
+
41
+ Publishes applicationModeChanged only when the mode actually changes.
42
+
43
+ Result: SUCCESS when the mode was set (or already had that value); UNAVAILABLE when the mode is a valid
44
+ ApiApplicationMode the receiver does not support at this time; FAILED when the value is not a valid
45
+ ApiApplicationMode at all. In every case the response payload carries the mode actually in effect, so a
46
+ non-success response reports the unchanged current mode.
47
+ """
48
+
49
+ SET_TRAINING_MODE = 130
50
+ """
51
+ Payload: {mode: ApiTrainingMode}
52
+ The response is training mode after attempting to set. Typically the same as the payload, but if for some reason
53
+ the mode is invalid in the current context, it should return the actual mode.
54
+ Response Payload: {mode: ApiTrainingMode}
55
+
56
+ Publishes trainingModeChanged only when the mode actually changes.
57
+
58
+ Result: as for SET_APPLICATION_MODE, with the response payload always carrying the mode in effect.
59
+ """
60
+
61
+ EMERGENCY_STOP = 200
62
+ """Response Payload: None
63
+
64
+ Idempotent: a stop received while already stopped is still SUCCESS and still publishes emergencyStop,
65
+ carrying the alarms active at that moment. The event announces the condition rather than a transition, so
66
+ it is not suppressed on a repeat.
67
+
68
+ Result: SUCCESS
69
+ """
70
+
71
+ EMERGENCY_RESUME = 210
72
+ """Response Payload: None
73
+
74
+ Result: SUCCESS when the receiver was stopped, publishing emergencyResume; FAILED when it was not stopped,
75
+ in which case no event is published.
76
+ """
77
+
78
+ GET_CONFIGURATION = 300
79
+ """Response Payload: ApiSystemConfiguration"""
80
+
81
+ GET_STATUS = 400
82
+ """Response Payload: ApiSystemStatus"""
83
+
84
+ GET_ANIMALS = 500
85
+ """Response Payload: List[ApiAnimalStatus]
86
+
87
+ The order of the list is not defined. An empty list is a valid result: a receiver with no animal location
88
+ configured, or one whose location holds no animals, responds SUCCESS with [] rather than failing.
89
+
90
+ Result: SUCCESS
91
+ """
92
+
93
+ USER_DEFINED = 99999
94
+ """A custom command defined between a particular commander and receiver. Additional information can be
95
+ defined in the `data` field.
96
+
97
+ Also the value a request carries when its command is not a member of this enum (see
98
+ `ApiCommandRequest.parse_object`).
99
+
100
+ Result: UNRECOGNIZED unless the receiver defines handling for the specific custom command.
101
+ """
102
+
103
+ @classmethod
104
+ def is_member(cls, value):
105
+ return value in cls._value2member_map_
@@ -28,7 +28,7 @@ class ApiEventKind(IntEnum):
28
28
  emergencyStop = 101
29
29
  """Payload: EmergencyStopContext"""
30
30
  emergencyResume = 102
31
- """Payload: ReasonContext"""
31
+ """Payload: EmergencyResumeContext"""
32
32
 
33
33
  applicationLaunched = 201
34
34
  """Payload: VersionContext"""
@@ -30,6 +30,7 @@ from uuid import UUID
30
30
 
31
31
  from ..api_alarm_kind import ApiAlarmKind
32
32
  from ..api_application_mode import ApiApplicationMode
33
+ from ..api_emergency_stop import ApiEmergencyResumeReason, ApiEmergencyStopReason
33
34
  from ..api_training_mode import ApiTrainingMode
34
35
  from .api_event_kind import ApiPelletShiftSource
35
36
 
@@ -37,7 +38,8 @@ __all__ = [
37
38
  "Vector3Context", "SessionTrialContext", "AnalysisTrialContext", "TrialSeenContext", "ReasonContext",
38
39
  "CommandContext", "IsEnabledContext",
39
40
  "IsEngagedContext", "IntensityContext", "CountChangeContext", "TrainingPhaseContext",
40
- "EmergencyStopContext", "VersionContext", "ApplicationModeContext", "PropertyChangedContext",
41
+ "EmergencyStopContext", "EmergencyResumeContext",
42
+ "VersionContext", "ApplicationModeContext", "PropertyChangedContext",
41
43
  "ProjectChangedContext", "ProjectTrialChangedContext", "PelletHomeResetContext",
42
44
  "PelletDriftResetContext", "SessionStartedContext", "SessionEndedContext", "TrialStartedContext",
43
45
  "TrialEndedContext", "CaptureAnalysisResultLike", "BatchAnalysisStartedContext", "BatchAnalysisEndedContext",
@@ -173,15 +175,36 @@ class TrainingPhaseContext(TypedDict):
173
175
 
174
176
  class EmergencyStopContext(TypedDict):
175
177
  """Fields:
176
- reason: Why the stop occurred.
178
+ reason: Why the stop occurred. Free text, and unchanged: ``reason_code`` classifies the same stop,
179
+ it does not replace this.
180
+ reason_code: What stopped the run, as an :class:`ApiEmergencyStopReason` — the machine-readable
181
+ companion to ``reason``. Use ``unknown`` when the source does not match a known member.
177
182
  active_alarms: The active and enabled alarms. This can include alarms that may not be the initial
178
183
  cause of the stop, so long as they are active and enabled (must be enabled). May be empty when
179
184
  the source of the stop is the user button, rpc service, etc.
180
185
  """
181
186
  reason: str
187
+ reason_code: ApiEmergencyStopReason
182
188
  active_alarms: List[ApiAlarmKind]
183
189
 
184
190
 
191
+ class EmergencyResumeContext(ReasonContext):
192
+ """The ``emergencyResume`` payload. Extends :class:`ReasonContext` (free-text ``reason``) with the
193
+ machine-readable cause; the two are additive, not alternatives.
194
+
195
+ Fields:
196
+ reason: Why the resume occurred. Free text, and unchanged.
197
+ reason_code: What resumed the run, as an :class:`ApiEmergencyResumeReason`. Use ``unknown`` when the
198
+ source does not match a known member.
199
+ resumed_alarms: The alarms the resume applies to. Always present — send ``[]`` when there are none,
200
+ so consumers can read it unconditionally rather than defaulting a missing key. Only
201
+ ``alarm_monitor_resume`` is expected to be non-empty (the alarms the monitor resumed from); for
202
+ every other ``reason_code`` it is an empty list.
203
+ """
204
+ reason_code: ApiEmergencyResumeReason
205
+ resumed_alarms: List[ApiAlarmKind]
206
+
207
+
185
208
  class VersionContext(TypedDict):
186
209
  """Fields:
187
210
  version: The application version string.
@@ -59,7 +59,7 @@ def build_event(kind: Literal[ApiEventKind.unknown]) -> ApiEventDict: ...
59
59
  @overload
60
60
  def build_event(kind: Literal[ApiEventKind.emergencyStop], context: p.EmergencyStopContext) -> ApiEventDict: ...
61
61
  @overload
62
- def build_event(kind: Literal[ApiEventKind.emergencyResume], context: p.ReasonContext) -> ApiEventDict: ...
62
+ def build_event(kind: Literal[ApiEventKind.emergencyResume], context: p.EmergencyResumeContext) -> ApiEventDict: ...
63
63
  @overload
64
64
  def build_event(kind: Literal[ApiEventKind.applicationLaunched], context: p.VersionContext) -> ApiEventDict: ...
65
65
  @overload
@@ -1,54 +0,0 @@
1
- from enum import IntEnum
2
-
3
-
4
- class ApiCommand(IntEnum):
5
- """
6
- A command value is required for all command requests.
7
- """
8
- NONE = 0
9
- """No command. Can be used to verify connection or that the receiver is configured to receive commands."""
10
-
11
- START_ACQUISITION = 50
12
- """ Obsolete"""
13
-
14
- STOP_ACQUISITION = 55
15
- """ Obsolete"""
16
-
17
- SET_APPLICATION_MODE = 120
18
- """
19
- Payload: {mode: ApiApplicationMode}
20
- The response is application mode after attempting to set. Typically the same as the payload, but if for some reason
21
- the mode is invalid in the current context, it should return the actual mode.
22
- Response Payload: {mode: ApiApplicationMode}
23
- """
24
-
25
- SET_TRAINING_MODE = 130
26
- """
27
- Payload: {mode: ApiTrainingMode}
28
- The response is training mode after attempting to set. Typically the same as the payload, but if for some reason
29
- the mode is invalid in the current context, it should return the actual mode.
30
- Response Payload: {mode: ApiTrainingMode}
31
- """
32
-
33
- EMERGENCY_STOP = 200
34
- """Response Payload: None"""
35
-
36
- EMERGENCY_RESUME = 210
37
- """Response Payload: None"""
38
-
39
- GET_CONFIGURATION = 300
40
- """Response Payload: ApiSystemConfiguration"""
41
-
42
- GET_STATUS = 400
43
- """Response Payload: ApiSystemStatus"""
44
-
45
- GET_ANIMALS = 500
46
- """Response Payload: List[ApiAnimalStatus]"""
47
-
48
- USER_DEFINED = 99999
49
- """A custom command defined between a particular commander and receiver. Additional information can be
50
- defined in the `data` field."""
51
-
52
- @classmethod
53
- def is_member(cls, value):
54
- return value in cls._value2member_map_