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

Method getTaskSetupDataRaw

server/src/docker/tasks.ts:82–153  ·  view source on GitHub ↗
(
    host: Host,
    ti: TaskInfo,
    opts: { aspawnOptions?: AspawnOptions },
  )

Source from the content-addressed store, hash-verified

80 }
81
82 private async getTaskSetupDataRaw(
83 host: Host,
84 ti: TaskInfo,
85 opts: { aspawnOptions?: AspawnOptions },
86 ): Promise<TaskSetupData> {
87 const taskManifest = (await this.taskFetcher.fetch(ti))?.manifest?.tasks?.[ti.taskName]
88
89 const driver = new DriverImpl(
90 ti.taskFamilyName,
91 ti.taskName,
92 async ({ pythonCode, args, user, workdir }) => {
93 const result = await this.dockerFactory.getForHost(host).runContainer(ti.imageName, {
94 command: ['python', trustedArg`-c`, pythonCode, ...(args ?? [])],
95 containerName: `${ti.containerName}-${Math.random().toString(36).slice(2)}`,
96 user,
97 workdir,
98 cpus: this.config.cpuCountRequest(host) ?? 4,
99 memoryGb: this.config.ramGbRequest(host) ?? 4,
100 remove: true,
101 aspawnOptions: { ...opts.aspawnOptions, timeout: this.config.TASK_OPERATION_TIMEOUT_MS },
102 })
103
104 return {
105 stdout: result.stdout,
106 stderr: result.stderr,
107 exitStatus: result.exitStatus!,
108 }
109 },
110 this.dockerFactory.getCopyFn(this.dockerFactory.getForHost(host), ti.containerName),
111 getDefaultTaskHelperCode(),
112 )
113
114 const getTaskSetupDataResult = await driver.getTaskSetupData()
115 switch (getTaskSetupDataResult.status) {
116 case 'taskNotFound':
117 throw new TaskNotFoundError(ti.taskFamilyName, ti.taskName)
118 case 'parseFailed':
119 throw new Error(getTaskSetupDataResult.message)
120 case 'processFailed': {
121 const { exitStatus, stdout, stderr } = getTaskSetupDataResult.execResult
122 throw new Error(
123 `Error getting task setup data.\n\nExit status: ${exitStatus}\n\nStdout: ${stdout}\n\nStderr: ${stderr}`,
124 )
125 }
126 }
127
128 const taskSetupData = getTaskSetupDataResult.taskSetupData
129
130 let requiredEnvironmentVariables
131 if (ti.source.type === 'upload') {
132 // Require uploaded task families to specify all required environment variables instead of having some implicitly required.
133 requiredEnvironmentVariables = taskSetupData.requiredEnvironmentVariables
134 } else {
135 const nonUniqueRequiredEnvironmentVariables = [
136 // - Everything hard-coded in Vivaria
137 'OPENAI_API_BASE_URL',
138 // - Everything in taskExtracted.requiredEnvironmentVariables
139 ...taskSetupData.requiredEnvironmentVariables,

Callers 1

getTaskSetupDataMethod · 0.95

Calls 11

getTaskSetupDataMethod · 0.95
trustedArgFunction · 0.90
getDefaultTaskHelperCodeFunction · 0.90
getForHostMethod · 0.80
cpuCountRequestMethod · 0.80
ramGbRequestMethod · 0.80
getCopyFnMethod · 0.80
assertHasGpuSupportMethod · 0.80
fetchMethod · 0.45
runContainerMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected