decthings_api/client/rpc/debug/
request.rs

1use serde::Serialize;
2
3use crate::client::{rpc::ExecutionLocationProvider, DecthingsParameterProvider};
4
5#[derive(Debug, Clone, Serialize)]
6#[serde(rename_all = "camelCase")]
7pub struct DebugSessionOptions {
8    /// Will automatically terminate the session if no method is called on the debug session for this amount of time.
9    /// Default: 1800.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub terminate_after_inactive_seconds: Option<u32>,
12    /// Whether to run the process in remote debugger mode, allowing you to place breakpoints and step through the
13    /// code. Default: true.
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub remote_inspector: Option<bool>,
16}
17
18#[derive(Debug, Clone, Serialize)]
19#[serde(rename_all = "camelCase")]
20pub struct LaunchDebugSessionParams<'a> {
21    /// The model's id.
22    pub model_id: &'a str,
23    /// Which launcher to use for running the session.
24    pub execution_location: ExecutionLocationProvider<'a>,
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub options: Option<DebugSessionOptions>,
27    /// If true, immediately subscribes you to events "exit", "stdout", "stderr", "initialized" and
28    /// "remoteInspectorData" for the debug session. Default: true.
29    #[cfg(feature = "events")]
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub subscribe_to_events: Option<bool>,
32}
33
34#[derive(Debug, Clone, Serialize)]
35#[serde(rename_all = "camelCase")]
36pub struct GetDebugSessionsParams<'a, S: AsRef<str>> {
37    /// Which sessions to fetch. If unspecified, all sessions will be fetched.
38    #[serde(serialize_with = "super::super::serialize_option_asref_str_seq")]
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub debug_session_ids: Option<&'a [S]>,
41}
42
43#[derive(Debug, Clone, Serialize)]
44#[serde(rename_all = "camelCase")]
45pub struct TerminateDebugSessionParams<'a> {
46    /// The debug session's id.
47    pub debug_session_id: &'a str,
48}
49
50#[derive(Debug, Clone, Serialize)]
51#[serde(rename_all = "camelCase")]
52pub struct CallCreateModelStateParams<'a> {
53    /// The debug session's id.
54    pub debug_session_id: &'a str,
55    /// Parameters to provide to the function.
56    pub params: Vec<DecthingsParameterProvider<'a>>,
57}
58
59#[derive(Debug, Clone)]
60pub struct StateData<'a, D: AsRef<[u8]>> {
61    pub key: &'a str,
62    pub data: D,
63}
64
65#[derive(Debug, Clone, Serialize)]
66#[serde(rename_all = "camelCase", tag = "type")]
67pub enum StateDataProvider<'a, D: AsRef<[u8]>> {
68    #[serde(rename_all = "camelCase")]
69    Data {
70        #[serde(skip_serializing)]
71        data: &'a [StateData<'a, D>],
72    },
73    #[serde(rename_all = "camelCase")]
74    DataId { data_id: &'a str },
75}
76
77#[derive(Debug, Clone, Serialize)]
78#[serde(rename_all = "camelCase")]
79#[serde(bound(serialize = ""))]
80pub struct CallInstantiateModelParams<'a, D: AsRef<[u8]>> {
81    /// The debug session's id.
82    pub debug_session_id: &'a str,
83    /// Data to use as model state.
84    pub state_data: StateDataProvider<'a, D>,
85}
86
87#[derive(Debug, Clone, Serialize)]
88#[serde(rename_all = "camelCase")]
89pub struct CallTrainParams<'a> {
90    /// The debug session's id.
91    pub debug_session_id: &'a str,
92    /// Identifier of the instantiated model to use, as returned by the 'callInstantiateModel' function.
93    pub instantiated_model_id: &'a str,
94    /// Parameters to provide to the function.
95    pub params: Vec<DecthingsParameterProvider<'a>>,
96}
97
98#[derive(Debug, Clone, Serialize)]
99#[serde(rename_all = "camelCase")]
100pub struct DebugGetTrainingStatusParams<'a> {
101    /// The debug session's id.
102    pub debug_session_id: &'a str,
103    /// Training session identifier, as returned by the 'callTrain' function.
104    pub training_session_id: &'a str,
105}
106
107#[derive(Debug, Clone, Serialize)]
108#[serde(rename_all = "camelCase")]
109pub struct DebugTrainingMetricsToFetch<'a> {
110    pub name: &'a str,
111    pub start_index: u32,
112    pub amount: u32,
113}
114
115#[derive(Debug, Clone, Serialize)]
116#[serde(rename_all = "camelCase")]
117pub struct DebugGetTrainingMetricsParams<'a> {
118    /// The debug session's id.
119    pub debug_session_id: &'a str,
120    /// Training session identifier, as returned by the 'callTrain' function.
121    pub training_session_id: &'a str,
122    /// Which metrics to fetch.
123    pub metrics: &'a [DebugTrainingMetricsToFetch<'a>],
124}
125
126#[derive(Debug, Clone, Serialize)]
127#[serde(rename_all = "camelCase")]
128pub struct DebugCancelTrainingSessionParams<'a> {
129    /// The debug session's id.
130    pub debug_session_id: &'a str,
131    /// Training session identifier, as returned by the 'callTrain' function.
132    pub training_session_id: &'a str,
133}
134
135#[derive(Debug, Clone, Serialize)]
136#[serde(rename_all = "camelCase")]
137pub struct CallEvaluateParams<'a> {
138    /// The debug session's id.
139    pub debug_session_id: &'a str,
140    /// Identifier of the instantiated model to use, as returned by the 'callInstantiateModel' function.
141    pub instantiated_model_id: &'a str,
142    /// Parameters to provide to the function.
143    pub params: Vec<DecthingsParameterProvider<'a>>,
144}
145
146#[derive(Debug, Clone, Serialize)]
147#[serde(rename_all = "camelCase")]
148pub struct CallGetModelStateParams<'a> {
149    /// The debug session's id.
150    pub debug_session_id: &'a str,
151    /// Identifier of the instantiated model to use, as returned by the 'callInstantiateModel' function.
152    pub instantiated_model_id: &'a str,
153}
154
155#[derive(Debug, Clone, Serialize)]
156#[serde(rename_all = "camelCase")]
157pub struct DownloadStateDataParams<'a, S: AsRef<str>> {
158    /// The debug session's id.
159    pub debug_session_id: &'a str,
160    /// The data's id, as returned by 'callCreateModelState' or 'callGetModelState'.
161    pub data_id: &'a str,
162    /// Which state keys to fetch. Defaults to all keys.
163    #[serde(serialize_with = "super::super::serialize_option_asref_str_seq")]
164    #[serde(skip_serializing_if = "Option::is_none")]
165    pub keys: Option<&'a [S]>,
166}
167
168#[derive(Debug, Clone, Serialize)]
169#[serde(rename_all = "camelCase")]
170pub struct SendToRemoteInspectorParams<'a, T: AsRef<[u8]>> {
171    /// The debug session's id.
172    pub debug_session_id: &'a str,
173    #[serde(skip_serializing)]
174    pub data: T,
175}
176
177#[cfg(feature = "events")]
178#[derive(Debug, Clone, Serialize)]
179#[serde(rename_all = "camelCase")]
180pub struct DebugSubscribeToEventsParams<'a> {
181    /// The debug session's id.
182    pub debug_session_id: &'a str,
183}
184
185#[cfg(feature = "events")]
186#[derive(Debug, Clone, Serialize)]
187#[serde(rename_all = "camelCase")]
188pub struct DebugUnsubscribeFromEventsParams<'a> {
189    /// The debug session's id.
190    pub debug_session_id: &'a str,
191}