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 3 commits into
base: master
Choose a base branch
from

Conversation

markgrahamdawson
Copy link
Contributor

@markgrahamdawson markgrahamdawson commented Dec 10, 2024

This pr now implements setting default log file by job outcome in two ways:

  1. If the user navigates to the log view through the node menu the job state is passed to the view as in this pr...
    master...MetRonnie:cylc-ui:menu-log-file

  2. If the user manually types in the path of the job via the input in the log view a new query is made as in this pr...
    offline data: enable querying failed jobs cylc-uiserver#657

Closes #1241

Check List

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.cfg (and conda-environment.yml if present).
  • Tests are included (or explain why tests are not needed).
  • Changelog entry included if this is a change that can affect users
  • Cylc-Doc pull request opened if required at cylc/cylc-doc/pull/XXXX.
  • If this is a bug fix, PR should be raised against the relevant ?.?.x branch.

Comment on lines 463 to 474
},
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow's stateTotals tells us how many tasks are in each state (e.g. if there are any failed tasks in the workflow), not the state of the particular job that we are requesting the log file for.

To get the job status, I think you want something along these lines:

if (this.jobLog) {
  // we are looking at a job log => pick the appropriate log file based on its state

  // get the job from the store
  this.$workflowService.$index[this.id]

  return ...
} else {
   // we are viewing the workflow log => always default to the latest log file

  return ...
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When navigating to the log view directly, e.g. #/log/one, there is no data on the workflow in the store, so I think the log view would have to issue a graphql query for the particular job status?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also another thing is what if the workflow is stopped? I guess we could add a query in the UIServer schema for getting the job state from the DB (like what the analysis view does)? Or is this more effort than it's worth?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dammit, good point, we could use an offline query, but I'm not sure if we can retrieve the status field without making changes to the backend.

Copy link
Member

@MetRonnie MetRonnie Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markgrahamdawson From discussing today, we'll settle on a live query, like this:

query JobState($id: ID!) {
  job (id: $id) {
    state
  }
}

(As I mentioned, we can skip the query if the file in intialOptions is pre-populated as in master...MetRonnie:cylc-ui:menu-log-file)

Comment on lines +531 to +537
if (result.data.jobs[0].state === 'failed') {
return 'job.err'
}
if (result.data.jobs[0].state === 'submit-failed') {
return 'job-activity.log'
}
return 'job.out' // rather than undefined
Copy link
Member

@MetRonnie MetRonnie Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use import { JobStateLogFileMap } from '@/model/JobState.model'

Suggested change
if (result.data.jobs[0].state === 'failed') {
return 'job.err'
}
if (result.data.jobs[0].state === 'submit-failed') {
return 'job-activity.log'
}
return 'job.out' // rather than undefined
return JobStateLogFileMap.get(result.data.jobs[0].state) || 'job.out'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

log view: set default log file by job outcome
3 participants