Commit f2c0f721 authored by Cage, Gregory's avatar Cage, Gregory
Browse files

Merge branch 'update-job-monitoring' into 'dev'

Make stdout monitoring variable names consistent

See merge request !53
parents fb32fded 293587c4
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
<template>
    <div>
        <job-details-provider auto-refresh :jobId="job_id" :stdout_start=stdout_position :stdout_char_count=stdout_char_count @update:result="updateJob" />
        <job-details-provider auto-refresh :jobId="job_id" :stdout_position=stdout_position :stdout_length=stdout_length @update:result="updateJob" />
        <h2 class="h-md">Job Information</h2>
        <table id="job-information" class="tabletip info_data_table">
            <tbody>
@@ -108,7 +108,7 @@ export default {
        return {
            job: null,
            stdout_position: 0,
            stdout_char_count: 50000,
            stdout_length: 50000,
            stdout_text: "",
        };
    },
@@ -127,9 +127,9 @@ export default {
            const stdout_block = document.querySelector("#stdout").querySelector(".code");
            // if user is scrolled above the bottom of the code element, then no need to update the stdout
            if (stdout_block.scrollTop <= stdout_block.scrollHeight - 3000) {
                this.stdout_char_count = 0;
                this.stdout_length = 0;
            } else {
                this.stdout_char_count = 50000;
                this.stdout_length = 50000;
            }
        } catch(exception) {
            console.log(exception);
+2 −2
Original line number Diff line number Diff line
@@ -5,8 +5,8 @@ import { rethrowSimple } from "utils/simple-error";
import { stateIsTerminal } from "./utils";
import { cleanPaginationParameters } from "./utils";

async function jobDetails({ jobId, stdout_start = 0, stdout_char_count = 0 }) {
    const url = `${getAppRoot()}api/jobs/${jobId}?full=True&stdout_start_pos=${stdout_start}&stdout_count=${stdout_char_count}`;
async function jobDetails({ jobId, stdout_position = 0, stdout_length = 0 }) {
    const url = `${getAppRoot()}api/jobs/${jobId}?full=True&stdout_position=${stdout_position}&stdout_length=${stdout_length}`;
    try {
        const { data } = await axios.get(url);
        return data;
+5 −5
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ class JobManager:
        )
        return self.job_lock()

    def get_accessible_job(self, trans, decoded_job_id, stdout_start_pos=-1, stdout_count=0):
    def get_accessible_job(self, trans, decoded_job_id, stdout_position=-1, stdout_length=0):
        job = trans.sa_session.query(trans.app.model.Job).filter(trans.app.model.Job.id == decoded_job_id).first()
        if job is None:
            raise ObjectNotFound()
@@ -240,16 +240,16 @@ class JobManager:
                    raise ItemAccessibilityException("You are not allowed to rerun this job.")
        trans.sa_session.refresh(job)

        # If stdout_count and stdout_start_pos are good values, then load standard out and add it to status
        if job.state == job.states.RUNNING and stdout_count > 0 and stdout_start_pos > -1:
        # If stdout_length and stdout_position are good values, then load standard out and add it to status
        if job.state == job.states.RUNNING and stdout_length > 0 and stdout_position > -1:
            try:
                working_directory = trans.app.object_store.get_filename(
                    job, base_dir="job_work", dir_only=True, obj_dir=True
                )
                stdout_path = Path(working_directory) / "outputs" / "tool_stdout"
                stdout_file = open(stdout_path, "r")
                stdout_file.seek(stdout_start_pos)
                job.job_stdout = stdout_file.read(stdout_count)
                stdout_file.seek(stdout_position)
                job.job_stdout = stdout_file.read(stdout_length)
                job.tool_stdout = job.job_stdout
            except Exception as e:
                log.error("Could not read STDOUT: %s", e)
+6 −6
Original line number Diff line number Diff line
@@ -178,8 +178,8 @@ class FastAPIJobs:
        id: DecodedDatabaseIdField,
        trans: ProvidesUserContext = DependsOnTrans,
        full: Optional[bool] = False,
        stdout_start_pos: Optional[int] = None,
        stdout_count: Optional[int] = None,
        stdout_position: Optional[int] = None,
        stdout_length: Optional[int] = None,
    ) -> Dict[str, Any]:
        """
        Return dictionary containing description of job data
@@ -187,15 +187,15 @@ class FastAPIJobs:
        Parameters
        - id: ID of job to return
        - full: Return extra information ?
        - stdout_start_pos: The index of the character to begine reading stdout from
        - stdout_count: How many characters of stdout to read
        - stdout_position: The index of the character to begine reading stdout from
        - stdout_length: How many characters of stdout to read
        """
        return self.service.show(
            trans,
            id,
            bool(full),
            int(stdout_start_pos) if stdout_start_pos else 0,
            int(stdout_count) if stdout_count else 0,
            int(stdout_position) if stdout_position else 0,
            int(stdout_length) if stdout_length else 0,
        )

    @router.get("/api/jobs")
+3 −3
Original line number Diff line number Diff line
@@ -48,10 +48,10 @@ class JobsService:
        trans: ProvidesUserContext,
        id: DecodedDatabaseIdField,
        full: bool = False,
        stdout_start_pos: int = 0,
        stdout_count: int = 0,
        stdout_position: int = 0,
        stdout_length: int = 0,
    ) -> Dict[str, Any]:
        job = self.job_manager.get_accessible_job(trans, id, stdout_start_pos, stdout_count)
        job = self.job_manager.get_accessible_job(trans, id, stdout_position, stdout_length)
        return view_show_job(trans, job, bool(full))

    def index(