MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / SandboxSession

Class SandboxSession

python/openshell/sandbox.py:165–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163
164
165class SandboxSession:
166 def __init__(self, client: SandboxClient, sandbox: SandboxRef) -> None:
167 self._client = client
168 self.sandbox = sandbox
169
170 @property
171 def id(self) -> str:
172 return self.sandbox.id
173
174 def exec(
175 self,
176 command: Sequence[str],
177 *,
178 stream_output: bool = False,
179 workdir: str | None = None,
180 env: Mapping[str, str] | None = None,
181 stdin: bytes | None = None,
182 timeout_seconds: int | None = None,
183 ) -> ExecResult:
184 return self._client.exec(
185 self.sandbox.id,
186 command,
187 stream_output=stream_output,
188 workdir=workdir,
189 env=env,
190 stdin=stdin,
191 timeout_seconds=timeout_seconds,
192 )
193
194 def exec_python(
195 self,
196 function: Callable[..., object],
197 *,
198 args: Sequence[object] = (),
199 kwargs: Mapping[str, object] | None = None,
200 stream_output: bool = False,
201 workdir: str | None = None,
202 env: Mapping[str, str] | None = None,
203 timeout_seconds: int | None = None,
204 ) -> ExecResult:
205 return self._client.exec_python(
206 self.sandbox.id,
207 function,
208 args=args,
209 kwargs=kwargs,
210 stream_output=stream_output,
211 workdir=workdir,
212 env=env,
213 timeout_seconds=timeout_seconds,
214 )
215
216 def delete(self) -> bool:
217 return self._client.delete(self.sandbox.name)
218
219
220class SandboxClient:

Callers 3

create_sessionMethod · 0.85
get_sessionMethod · 0.85
__enter__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected