MCPcopy Create free account
hub / github.com/METR/vivaria / execPython

Method execPython

server/src/docker/docker.ts:323–332  ·  view source on GitHub ↗
(
    containerName: string,
    code: string,
    opts: ExecOptions & { pythonArgs?: string[] } = {},
  )

Source from the content-addressed store, hash-verified

321 }
322
323 async execPython(
324 containerName: string,
325 code: string,
326 opts: ExecOptions & { pythonArgs?: string[] } = {},
327 ): Promise<ExecResult> {
328 // Arguments after the python script will be read by the script as sys.argv and never as
329 // arguments to docker container exec itself, so the usage of `dangerouslyTrust` is fine.
330 const args = (opts.pythonArgs ?? []).map(dangerouslyTrust)
331 return await this.exec(containerName, ['python', trustedArg`-c`, code, ...args], opts)
332 }
333
334 async execBash(containerName: string, code: string, opts: ExecOptions = {}): Promise<ExecResult> {
335 return await this.exec(containerName, ['bash', trustedArg`-c`, code], opts)

Callers 4

createDriverMethod · 0.80
raw_routes.tsFile · 0.80

Calls 2

execMethod · 0.95
trustedArgFunction · 0.90

Tested by

no test coverage detected