@@ -25,30 +25,30 @@ def _run_id(job_key: str, resume_version: int | None) -> str:
2525
2626@dataclass
2727class PythonServerRunRequest :
28- """PascalCase fields match the wire keys."""
28+ """camelCase fields match the wire keys."""
2929
30- JobKey : str = ""
31- ResumeVersion : int | None = None
32- Command : str = ""
30+ jobKey : str = ""
31+ resumeVersion : int | None = None
32+ command : str = ""
3333 # The peer sends a single string; HTTP callers and tests may pass a
3434 # pre-split list. parse_args accepts both.
35- Args : str | list [str ] | None = None
36- WorkingDirectory : str | None = None
37- EnvironmentVariables : dict [str , str ] = field (default_factory = dict )
38- StreamOutputOverIpc : bool = False
35+ args : str | list [str ] | None = None
36+ workingDirectory : str | None = None
37+ environmentVariables : dict [str , str ] = field (default_factory = dict )
38+ streamOutputOverIpc : bool = False
3939
4040
4141@dataclass
4242class PythonServerStopJobRequest :
43- JobKey : str = ""
44- ResumeVersion : int | None = None
45- ForceStop : bool = False
43+ jobKey : str = ""
44+ resumeVersion : int | None = None
45+ forceStop : bool = False
4646
4747
4848@dataclass
4949class PythonServerRunJobResult :
50- ExitCode : int = 0
51- Error : str | None = None
50+ exitCode : int = 0
51+ error : str | None = None
5252
5353
5454class IPythonRuntimeServer (ABC ):
@@ -62,7 +62,7 @@ async def Register(self, message: "Message[None]") -> bool:
6262 async def RunJob (
6363 self , request : PythonServerRunRequest , * , message : "Message[None] | None" = None
6464 ) -> PythonServerRunJobResult :
65- """Run a job → PythonServerRunJobResult(ExitCode, Error ).
65+ """Run a job → PythonServerRunJobResult(exitCode, error ).
6666
6767 ``message`` is injected by the dispatcher, which reads this contract — not the impl.
6868 """
@@ -82,28 +82,28 @@ async def Register(self, message: "Message[None]") -> bool:
8282 async def RunJob (
8383 self , request : PythonServerRunRequest , * , message : "Message[None] | None" = None
8484 ) -> PythonServerRunJobResult :
85- command_name = request .Command
85+ command_name = request .command
8686 if not isinstance (command_name , str ) or not command_name :
8787 return PythonServerRunJobResult (
88- ExitCode = 1 , Error = "Missing or invalid field: 'Command '"
88+ exitCode = 1 , error = "Missing or invalid field: 'command '"
8989 )
9090
9191 cmd = COMMANDS .get (command_name )
9292 if cmd is None :
9393 return PythonServerRunJobResult (
94- ExitCode = 1 , Error = f"Unknown command: { command_name } "
94+ exitCode = 1 , error = f"Unknown command: { command_name } "
9595 )
9696
97- args = parse_args (request .Args )
97+ args = parse_args (request .args )
9898
9999 console .info (
100- f"Running job { _run_id (request .JobKey , request .ResumeVersion )} : { command_name } { args } "
100+ f"Running job { _run_id (request .jobKey , request .resumeVersion )} : { command_name } { args } "
101101 )
102102
103103 on_run_start : "Any" = None
104104 on_run_end : "Any" = None
105105 installed : "list[Any]" = []
106- if request .StreamOutputOverIpc :
106+ if request .streamOutputOverIpc :
107107 # Never stored: a captured callback goes stale on reconnect/restart.
108108 from ._job_api import (
109109 IPythonJobApi ,
@@ -112,25 +112,25 @@ async def RunJob(
112112 is_wire_job_key ,
113113 )
114114
115- if not is_wire_job_key (request .JobKey ):
115+ if not is_wire_job_key (request .jobKey ):
116116 return PythonServerRunJobResult (
117- ExitCode = 1 ,
118- Error = f"StreamOutputOverIpc needs a 'JobKey ' that is a job key (Guid); got { request .JobKey !r} " ,
117+ exitCode = 1 ,
118+ error = f"streamOutputOverIpc needs a 'jobKey ' that is a job key (Guid); got { request .jobKey !r} " ,
119119 )
120120
121121 if message is None or message .client is None :
122122 return PythonServerRunJobResult (
123- ExitCode = 1 ,
124- Error = "StreamOutputOverIpc is only available when RunJob is invoked over IPC" ,
123+ exitCode = 1 ,
124+ error = "streamOutputOverIpc is only available when RunJob is invoked over IPC" ,
125125 )
126126
127127 # get_callback only wraps the connection, so this cannot tell us whether the peer
128128 # actually hosts the contract; a peer that doesn't shows up as a failing send.
129129 callback = message .client .get_callback (IPythonJobApi ) # type: ignore[type-abstract]
130130
131131 loop = asyncio .get_running_loop ()
132- job_key = request .JobKey
133- resume_version = request .ResumeVersion
132+ job_key = request .jobKey
133+ resume_version = request .resumeVersion
134134
135135 def _install () -> None :
136136 installed .append (
@@ -143,8 +143,8 @@ def _install() -> None:
143143 result = await _run_command_isolated (
144144 cmd ,
145145 args ,
146- request .EnvironmentVariables ,
147- request .WorkingDirectory ,
146+ request .environmentVariables ,
147+ request .workingDirectory ,
148148 on_run_start = on_run_start ,
149149 on_run_end = on_run_end ,
150150 )
@@ -154,15 +154,15 @@ def _install() -> None:
154154 if handler is not None :
155155 await handler .aflush_pending ()
156156
157- # IPC contract (PythonServerRunJobResult) carries only ExitCode + Error .
157+ # IPC contract (PythonServerRunJobResult) carries only exitCode + error .
158158 return PythonServerRunJobResult (
159- ExitCode = result ["ExitCode" ], Error = result ["Error" ]
159+ exitCode = result ["ExitCode" ], error = result ["Error" ]
160160 )
161161
162162 async def StopJob (self , request : PythonServerStopJobRequest ) -> bool :
163163 console .info (
164- f"StopJob requested for { _run_id (request .JobKey , request .ResumeVersion )} "
165- f"(force={ request .ForceStop } ) (no-op)"
164+ f"StopJob requested for { _run_id (request .jobKey , request .resumeVersion )} "
165+ f"(force={ request .forceStop } ) (no-op)"
166166 )
167167 return True
168168
0 commit comments