diff --git a/src/combination/list/main.js b/src/combination/list/main.js index b83ee5ec7..cc5cbb18a 100644 --- a/src/combination/list/main.js +++ b/src/combination/list/main.js @@ -28,13 +28,16 @@ export const listCombinations = async function ({ } // Get cartesian product of all combinations +// `taskPath` is not set in `dimensions.task.path` because it used by the `init` +// stage before task dimension ids are known. const getCombinationsProduct = function ({ tasks, inputs, systemId }) { if (tasks.length === 0) { throw new UserError(`Please specify some "tasks".`) } - return tasks.map(({ id, path, runner }) => ({ - dimensions: { task: { id, path }, runner, system: { id: systemId } }, + return tasks.map(({ id, taskPath, runner }) => ({ + dimensions: { task: { id }, runner, system: { id: systemId } }, + taskPath, inputs, stats: {}, })) diff --git a/src/combination/tasks/find.js b/src/combination/tasks/find.js index f7b08d605..1779cfb6b 100644 --- a/src/combination/tasks/find.js +++ b/src/combination/tasks/find.js @@ -10,25 +10,25 @@ import { measureCombinations } from '../../run/measure/main.js' // to several tasks competing for optimization in the same process // So we spawn a single process for all of them, to retrieve the task and step // identifiers. -export const findTasks = async function (path, cwd, runner) { - await validateTask(path) +export const findTasks = async function (taskPath, cwd, runner) { + await validateTask(taskPath) try { const [{ taskIds: ids }] = await measureCombinations( - [{ dimensions: { task: { path }, runner }, inputs: [] }], + [{ dimensions: { runner }, taskPath, inputs: [] }], { precisionTarget: 0, cwd, previewState: { quiet: true }, stage: 'init' }, ) validateDuplicateTaskIds(ids) - return ids.map((id) => ({ id, path, runner })) + return ids.map((id) => ({ id, taskPath, runner })) } catch (error) { - error.message = `In tasks file "${path}" (runner "${runner.id}")\n${error.message}` + error.message = `In tasks file "${taskPath}":\n${error.message}` throw error } } -const validateTask = async function (path) { - if (!(await isFile(path))) { - throw new UserError(`Tasks file does not exist: ${path}`) +const validateTask = async function (taskPath) { + if (!(await isFile(taskPath))) { + throw new UserError(`Tasks file does not exist: ${taskPath}`) } } diff --git a/src/run/measure/events.js b/src/run/measure/events.js index f22c07def..4025b6904 100644 --- a/src/run/measure/events.js +++ b/src/run/measure/events.js @@ -19,13 +19,15 @@ export const runEvents = async function ({ combination, ...args }) { } // Start combination, i.e. make it load the combination and run any -// runner-defined start logic +// runner-defined start logic. +// `task.id` is `undefined` during `init` stage. const startCombination = async function ( { dimensions: { - task: { id, path }, + task: { id } = {}, runner: { config }, }, + taskPath, inputs, }, server, @@ -36,7 +38,7 @@ const startCombination = async function ( event: 'start', runnerConfig: config, taskId: id, - taskPath: path, + taskPath, inputs: inputsObj, }, server, diff --git a/src/run/measure/single.js b/src/run/measure/single.js index adb1761fd..ccf49f7c9 100644 --- a/src/run/measure/single.js +++ b/src/run/measure/single.js @@ -100,18 +100,18 @@ const handleErrorsAndMeasure = async function ({ throwIfStopped(stopState) return returnValue } catch (error) { - prependCombinationPrefix(error, args.combination, args.stage) + prependCombinationPrefix(error, args.combination) throw error } } -const prependCombinationPrefix = function (error, combination, stage) { - if (stage === 'init' || error.name === 'StopError') { +const prependCombinationPrefix = function (error, combination) { + if (error.name === 'StopError') { return } const combinationPrefix = getCombinationPrefix(combination) - error.message = `In ${combinationPrefix}\n${error.message}` + error.message = `In ${combinationPrefix}:\n${error.message}` } const getCombinationPrefix = function (combination) {