Skip to content

Commit

Permalink
set default log file by job outcome
Browse files Browse the repository at this point in the history
  • Loading branch information
markgrahamdawson committed Dec 10, 2024
1 parent eff665f commit dfe8147
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/views/Log.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<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 @@ -240,6 +240,10 @@ query LogFiles($id: ID!) {
* The first pattern with a matching file name will be chosen.
*/
const LOG_FILE_DEFAULTS = [
// job error
/^job\.err$/,
// job submit-failed
/^job-activity\.log$/,
// job stdout
/^job\.out$/,
// job script (e.g. on job submission failure)
Expand All @@ -258,7 +262,9 @@ const LOG_FILE_DEFAULTS = [
*/
export const getDefaultFile = (logFiles) => {
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
Expand Down Expand Up @@ -454,11 +460,18 @@ export default {
)
},

computed: {
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 +487,18 @@ export default {
}
}
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

0 comments on commit dfe8147

Please sign in to comment.