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

Method getTaskSetupData

server/src/docker/tasks.ts:44–67  ·  view source on GitHub ↗

gets from variant from db if stored. stores if not.

(
    host: Host,
    ti: TaskInfo,
    opts: { forRun: boolean; aspawnOptions?: AspawnOptions; create?: boolean },
  )

Source from the content-addressed store, hash-verified

42
43 /** gets from variant from db if stored. stores if not. */
44 async getTaskSetupData(
45 host: Host,
46 ti: TaskInfo,
47 opts: { forRun: boolean; aspawnOptions?: AspawnOptions; create?: boolean },
48 ): Promise<TaskSetupData> {
49 if (!opts?.forRun) {
50 // TODO(maksym): Cache plain `viv task start` task setup datas too.
51 return this.getTaskSetupDataRaw(host, ti, opts)
52 }
53
54 const commitOrSourceHash = ti.source.type === 'gitRepo' ? ti.source.commitId : hashTaskOrAgentSource(ti.source)
55 const stored = await this.dbTaskEnvironments.getTaskSetupData(ti.id, commitOrSourceHash)
56 if (stored != null) {
57 return stored
58 } else if (!(opts.create ?? true)) {
59 throw new TaskSetupDataNotFoundError(
60 `Task setup data not found for ${ti.id} with commit or source hash ${commitOrSourceHash}`,
61 )
62 }
63
64 const taskSetupData = await this.getTaskSetupDataRaw(host, ti, opts)
65 await this.dbTaskEnvironments.insertTaskSetupData(ti.id, commitOrSourceHash, taskSetupData)
66 return taskSetupData
67 }
68
69 async getTaskInstructions(host: Host, ti: TaskInfo, opts: { forRun: boolean }): Promise<TaskInstructions> {
70 const taskSetupData = await this.getTaskSetupData(host, ti, opts)

Callers 7

getTaskInstructionsMethod · 0.95
getInspectJsonForBranchFunction · 0.45
agents.test.tsFile · 0.45
setupTaskContainerMethod · 0.45
tasks.test.tsFile · 0.45

Calls 3

getTaskSetupDataRawMethod · 0.95
hashTaskOrAgentSourceFunction · 0.90
insertTaskSetupDataMethod · 0.80

Tested by

no test coverage detected