2222
2323"""Wrappers over AppUtilities gRPC service of Fluent."""
2424
25+ from dataclasses import dataclass
2526from enum import Enum
2627from typing import List , Tuple
2728
@@ -150,6 +151,25 @@ def set_working_directory(
150151 return self ._stub .SetWorkingDirectory (request , metadata = self ._metadata )
151152
152153
154+ @dataclass
155+ class ProcessInfo :
156+ """ProcessInfo dataclass to hold process information."""
157+
158+ process_id : int
159+ hostname : str
160+ working_directory : str
161+
162+
163+ @dataclass
164+ class BuildInfo :
165+ """BuildInfo dataclass to hold build information."""
166+
167+ build_time : str
168+ build_id : str
169+ vcs_revision : str
170+ vcs_branch : str
171+
172+
153173class AppUtilitiesOld :
154174 """AppUtilitiesOld."""
155175
@@ -167,34 +187,34 @@ def get_build_info(self) -> dict:
167187 build_id = self .scheme .eval ("(inquire-build-id)" )
168188 vcs_revision = self .scheme .eval ("(inquire-src-vcs-id)" )
169189 vcs_branch = self .scheme .eval ("(inquire-src-vcs-branch)" )
170- return {
171- " build_time" : build_time ,
172- " build_id" : build_id ,
173- " vcs_revision" : vcs_revision ,
174- " vcs_branch" : vcs_branch ,
175- }
190+ return BuildInfo (
191+ build_time = build_time ,
192+ build_id = build_id ,
193+ vcs_revision = vcs_revision ,
194+ vcs_branch = vcs_branch ,
195+ )
176196
177197 def get_controller_process_info (self ) -> dict :
178198 """Get controller process info."""
179199 cortex_host = self .scheme .eval ("(cx-cortex-host)" )
180200 cortex_pid = self .scheme .eval ("(cx-cortex-id)" )
181201 cortex_pwd = self .scheme .eval ("(cortex-pwd)" )
182- return {
183- "hostname" : cortex_host ,
184- "process_id" : cortex_pid ,
185- " working_directory" : cortex_pwd ,
186- }
202+ return ProcessInfo (
203+ process_id = cortex_pid ,
204+ hostname = cortex_host ,
205+ working_directory = cortex_pwd ,
206+ )
187207
188208 def get_solver_process_info (self ) -> dict :
189209 """Get solver process info."""
190210 fluent_host = self .scheme .eval ("(cx-client-host)" )
191211 fluent_pid = self .scheme .eval ("(cx-client-id)" )
192212 fluent_pwd = self .scheme .eval ("(cx-send '(cx-client-pwd))" )
193- return {
194- "hostname" : fluent_host ,
195- "process_id" : fluent_pid ,
196- " working_directory" : fluent_pwd ,
197- }
213+ return ProcessInfo (
214+ process_id = fluent_pid ,
215+ hostname = fluent_host ,
216+ working_directory = fluent_pwd ,
217+ )
198218
199219 def get_app_mode (self ) -> Enum :
200220 """Get app mode."""
@@ -312,32 +332,32 @@ def get_build_info(self) -> dict:
312332 """Get build info."""
313333 request = AppUtilitiesProtoModule .GetBuildInfoRequest ()
314334 response = self .service .get_build_info (request )
315- return {
316- " build_time" : response .build_time ,
317- " build_id" : response .build_id ,
318- " vcs_revision" : response .vcs_revision ,
319- " vcs_branch" : response .vcs_branch ,
320- }
335+ return BuildInfo (
336+ build_time = response .build_time ,
337+ build_id = response .build_id ,
338+ vcs_revision = response .vcs_revision ,
339+ vcs_branch = response .vcs_branch ,
340+ )
321341
322342 def get_controller_process_info (self ) -> dict :
323343 """Get controller process info."""
324344 request = AppUtilitiesProtoModule .GetControllerProcessInfoRequest ()
325345 response = self .service .get_controller_process_info (request )
326- return {
327- "hostname" : response .hostname ,
328- "process_id" : response .process_id ,
329- " working_directory" : response .working_directory ,
330- }
346+ return ProcessInfo (
347+ process_id = response .process_id ,
348+ hostname = response .hostname ,
349+ working_directory = response .working_directory ,
350+ )
331351
332352 def get_solver_process_info (self ) -> dict :
333353 """Get solver process info."""
334354 request = AppUtilitiesProtoModule .GetSolverProcessInfoRequest ()
335355 response = self .service .get_solver_process_info (request )
336- return {
337- "hostname" : response .hostname ,
338- "process_id" : response .process_id ,
339- " working_directory" : response .working_directory ,
340- }
356+ return ProcessInfo (
357+ process_id = response .process_id ,
358+ hostname = response .hostname ,
359+ working_directory = response .working_directory ,
360+ )
341361
342362 def get_app_mode (self ) -> Enum :
343363 """Get app mode.
0 commit comments