Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set default log file by job outcome #2025

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 50 additions & 23 deletions src/views/Log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
:size="toolbarBtnSize"
/>
</v-col>
</v-row>

Check failure on line 56 in src/views/Log.vue

View workflow job for this annotation

GitHub Actions / unit-test-and-build

Unhandled error

TypeError: Cannot read properties of undefined (reading 'node') ❯ Proxy.workflowStatus src/views/Log.vue:56:15 ❯ ReactiveEffect.fn node_modules/@vue/reactivity/dist/reactivity.cjs.js:991:13 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:179:19 ❯ ComputedRefImpl.get value [as value] node_modules/@vue/reactivity/dist/reactivity.cjs.js:1002:68 ❯ Object.get [as workflowStatus] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3514:22 ❯ Object.workflowStatus [as get] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3074:19 ❯ Proxy.getDefaultFile src/views/Log.vue:1:1 ❯ Proxy.updateLogFileList src/views/Log.vue:4695:28 ❯ processTicksAndRejections node:internal/process/task_queues:105:5 ❯ Proxy.$watch.immediate src/views/Log.vue:608:1 This error originated in "tests/unit/views/log.vue.spec.js" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "tests/unit/views/log.vue.spec.js". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

Check failure on line 56 in src/views/Log.vue

View workflow job for this annotation

GitHub Actions / unit-test-and-build

Unhandled error

TypeError: Cannot read properties of undefined (reading 'node') ❯ Proxy.workflowStatus src/views/Log.vue:56:15 ❯ ReactiveEffect.fn node_modules/@vue/reactivity/dist/reactivity.cjs.js:991:13 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:179:19 ❯ ComputedRefImpl.get value [as value] node_modules/@vue/reactivity/dist/reactivity.cjs.js:1002:68 ❯ Object.get [as workflowStatus] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3514:22 ❯ Object.workflowStatus [as get] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:3074:19 ❯ Proxy.getDefaultFile src/views/Log.vue:1:1 ❯ Proxy.updateLogFileList src/views/Log.vue:4695:28 ❯ processTicksAndRejections node:internal/process/task_queues:105:5 ❯ Proxy.$watch.immediate src/views/Log.vue:608:1 This error originated in "tests/unit/views/log.vue.spec.js" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. The latest test that might've caused the error is "tests/unit/views/log.vue.spec.js". It might mean one of the following: - The error was thrown, while Vitest was running this test. - If the error occurred after the test had been completed, this was the last documented test before it was thrown.

<!-- the inputs -->
<v-row
Expand Down Expand Up @@ -180,7 +180,7 @@
<script>
import { ref, computed } from 'vue'
import { usePrevious, whenever } from '@vueuse/core'
import { useStore } from 'vuex'
import { useStore, mapGetters } from 'vuex'
import {
mdiClockOutline,
mdiFileAlertOutline,
Expand Down Expand Up @@ -248,27 +248,6 @@
/^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
}

class Results {
constructor () {
/** @type {string[]} */
Expand Down Expand Up @@ -455,10 +434,17 @@
},

computed: {
...mapGetters('workflows', ['getNodes']),
workflowTokens () {
// tokens for the workflow this view was opened for
return new Tokens(this.workflowId)
},
workflowIDs () {
return [this.workflowId]
},
workflows () {
return this.getNodes('workflow', this.workflowIDs)
},
id () {
// the ID of the workflow/task/job we are subscribed to
// OR null if not subscribed
Expand All @@ -474,6 +460,18 @@
}
}
return this.workflowId
},
workflowStatus () {
if (this.workflows[0].node.stateTotals.failed) {
return 'failed'
}
if (this.workflows[0].node.stateTotals.submitted | this.workflows[0].node.stateTotals.running | this.workflows[0].node.stateTotals.succeeded) {
return 'succeeded'
}
if (this.workflows[0].node.stateTotals['submit-failed']) {
return 'submit-failed'
}
return 0
}
},

Expand Down Expand Up @@ -503,6 +501,35 @@
/* isGlobalCallback */ false
)
},
/**
* 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}
*/
getDefaultFile (logFiles) {
if (this.workflowStatus === 'failed') {
return 'job.err'
}
if (this.workflowStatus === 'submit-failed') {
return 'job-activity.log'
}

if (logFiles.length) {
// loop through all the options in LOG_FILE_DEFAULTS
for (const filePattern of LOG_FILE_DEFAULTS) {
// Loop through all the filenames e.g.[job.out, job.status]
for (const fileName of logFiles) {
if (filePattern.exec(fileName)) {
return fileName
}
}
}
}
return null // rather than undefined
},
async updateLogFileList (reset = true) {
// if reset===true then the this.file will be reset
// otherwise it will be left alone
Expand Down Expand Up @@ -542,7 +569,7 @@
}
if (!this.file) {
// set the default log file if appropriate
this.file = getDefaultFile(logFiles)
this.file = this.getDefaultFile(logFiles)
}
}

Expand Down
Loading