cylc-ui
cylc-ui copied to clipboard
log view: set default log file by job outcome
Describe exactly what you would like to see in an upcoming release The default log file selected should depend on the outcome of a job:
Outcome | Default File |
---|---|
submitted, running & succeeded | job.out |
failed | job.err |
submit-failed | job-activity.log |
Pull requests welcome!
I'd like to see it implemented.
Would the following chunck be the only one to change? I don't speak le Javascript but I can learn. Maybe.
/**
* The preferred file to start with as a list of patterns.
* The first pattern with a matching file name will be chosen.
*/
const LOG_FILE_DEFAULTS = [
// job stdout
/^job\.out$/,
// job script (e.g. on job submission failure)
/^job$/,
// scheduler log (lexographical sorting ensures the latest log)
/^scheduler\/*/
]
/**
* Return the default log file from the given log filenames, if there is a
* matching filename. Relies on the filenames having been sorted in descending
* order.
*
* @param {string[]} logFiles - list of available log filenames
* @returns {?string}
*/
export const getDefaultFile = (logFiles) => {
if (logFiles.length) {
for (const filePattern of LOG_FILE_DEFAULTS) {
for (const fileName of logFiles) {
if (filePattern.exec(fileName)) {
return fileName
}
}
}
}
return null // rather than undefined
}
It looks like in its current iteration, the log view only query files, but doesn't speak to the scheduler to find tasks' state.
Would it be best to instead make the commandMenu send a file
in initialOptions ?
if (mutation.name === 'log') {
// Navigate to the corresponding workflow then open the log view
// (no nav occurs if already on the correct workflow page)
this.$router.push({
name: 'Workspace',
params: {
workflowName: this.node.tokens.workflow
}
}).then(() => {
eventBus.emit(
'add-view',
{
name: 'Log',
initialOptions: {
relativeID: this.node.tokens.relativeID || null,
file: this.node.somethingsomething.task.state
}
}
)
})
}