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

log view: set default log file by job outcome #1241

Open
wxtim opened this issue Feb 20, 2023 · 3 comments
Open

log view: set default log file by job outcome #1241

wxtim opened this issue Feb 20, 2023 · 3 comments
Assignees
Milestone

Comments

@wxtim
Copy link
Member

wxtim commented Feb 20, 2023

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!

@wxtim wxtim modified the milestones: 1.6.0, Pending Feb 20, 2023
@MetRonnie MetRonnie changed the title log: set default log file by job outcome log view: set default log file by job outcome Jun 17, 2024
@elliotfontaine
Copy link

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.

cylc-ui/src/views/Log.vue

/**
 * 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
              }
            }
          )
        })
      }

@markgrahamdawson markgrahamdawson self-assigned this Dec 9, 2024
@markgrahamdawson
Copy link
Contributor

markgrahamdawson commented Dec 9, 2024

Whats the best way of getting the workflow status in the views/Log.vue?

Its available in the GScan component...
GScanTreeItem accepts a node which is passed through a method called traverseChildren to give the computed prop descendantTaskInfo this returns an object with a key of latestTasks which looks like this...

{
"failed": ["1/hello"],
"submit-failed": [],
"submitted": [],
"running": []
}

can a similar approach be used for the Log view?

@markgrahamdawson
Copy link
Contributor

markgrahamdawson commented Dec 10, 2024

This works I think...
#2025
Not sure if its the best solution?

...also nice number pr to go into the new year

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

No branches or pull requests

4 participants