Loading lib/galaxy/managers/jobs.py +25 −13 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ from galaxy.util.search import ( log = logging.getLogger(__name__) STDOUT_LOCATION = "outputs/tool_stdout" STDERR_LOCATION = "outputs/tool_stderr" class JobLock(BaseModel): active: bool = Field(title="Job lock status", description="If active, jobs will not dispatch") Loading Loading @@ -226,7 +228,7 @@ class JobManager: ) return self.job_lock() def get_accessible_job(self, trans, decoded_job_id, stdout_position=-1, stdout_length=0): def get_accessible_job(self, trans, decoded_job_id, stdout_position=-1, stdout_length=0, stderr_position=-1, stderr_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() Loading @@ -245,18 +247,28 @@ class JobManager: trans.sa_session.refresh(job) # 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: if job.state == job.states.RUNNING: 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" if stdout_length > 0 and stdout_position > -1: try: stdout_path = Path(working_directory) / STDOUT_LOCATION stdout_file = open(stdout_path, "r") 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) if stderr_length > 0 and stderr_position > -1: try: stderr_path = Path(working_directory) / STDERR_LOCATION stderr_file = open(stderr_path, "r") stderr_file.seek(stderr_position) job.job_stderr = stderr_file.read(stderr_length) job.tool_stderr = job.job_stderr except Exception as e: log.error("Could not read STDERR: %s", e) return job def stop(self, job, message=None): Loading lib/galaxy/webapps/galaxy/api/jobs.py +4 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,8 @@ class FastAPIJobs: full: Optional[bool] = False, stdout_position: Optional[int] = None, stdout_length: Optional[int] = None, stderr_position: Optional[int] = None, stderr_length: Optional[int] = None, ) -> Dict[str, Any]: """ Return dictionary containing description of job data Loading @@ -196,6 +198,8 @@ class FastAPIJobs: bool(full), int(stdout_position) if stdout_position else 0, int(stdout_length) if stdout_length else 0, int(stderr_position) if stderr_position else 0, int(stderr_length) if stderr_length else 0, ) @router.get("/api/jobs") Loading lib/galaxy/webapps/galaxy/services/jobs.py +3 −1 Original line number Diff line number Diff line Loading @@ -50,8 +50,10 @@ class JobsService: full: bool = False, stdout_position: int = 0, stdout_length: int = 0, stderr_position: int = 0, stderr_length: int = 0, ) -> Dict[str, Any]: job = self.job_manager.get_accessible_job(trans, id, stdout_position, stdout_length) job = self.job_manager.get_accessible_job(trans, id, stdout_position, stdout_length, stderr_position, stderr_length) return view_show_job(trans, job, bool(full)) def index( Loading Loading
lib/galaxy/managers/jobs.py +25 −13 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ from galaxy.util.search import ( log = logging.getLogger(__name__) STDOUT_LOCATION = "outputs/tool_stdout" STDERR_LOCATION = "outputs/tool_stderr" class JobLock(BaseModel): active: bool = Field(title="Job lock status", description="If active, jobs will not dispatch") Loading Loading @@ -226,7 +228,7 @@ class JobManager: ) return self.job_lock() def get_accessible_job(self, trans, decoded_job_id, stdout_position=-1, stdout_length=0): def get_accessible_job(self, trans, decoded_job_id, stdout_position=-1, stdout_length=0, stderr_position=-1, stderr_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() Loading @@ -245,18 +247,28 @@ class JobManager: trans.sa_session.refresh(job) # 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: if job.state == job.states.RUNNING: 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" if stdout_length > 0 and stdout_position > -1: try: stdout_path = Path(working_directory) / STDOUT_LOCATION stdout_file = open(stdout_path, "r") 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) if stderr_length > 0 and stderr_position > -1: try: stderr_path = Path(working_directory) / STDERR_LOCATION stderr_file = open(stderr_path, "r") stderr_file.seek(stderr_position) job.job_stderr = stderr_file.read(stderr_length) job.tool_stderr = job.job_stderr except Exception as e: log.error("Could not read STDERR: %s", e) return job def stop(self, job, message=None): Loading
lib/galaxy/webapps/galaxy/api/jobs.py +4 −0 Original line number Diff line number Diff line Loading @@ -180,6 +180,8 @@ class FastAPIJobs: full: Optional[bool] = False, stdout_position: Optional[int] = None, stdout_length: Optional[int] = None, stderr_position: Optional[int] = None, stderr_length: Optional[int] = None, ) -> Dict[str, Any]: """ Return dictionary containing description of job data Loading @@ -196,6 +198,8 @@ class FastAPIJobs: bool(full), int(stdout_position) if stdout_position else 0, int(stdout_length) if stdout_length else 0, int(stderr_position) if stderr_position else 0, int(stderr_length) if stderr_length else 0, ) @router.get("/api/jobs") Loading
lib/galaxy/webapps/galaxy/services/jobs.py +3 −1 Original line number Diff line number Diff line Loading @@ -50,8 +50,10 @@ class JobsService: full: bool = False, stdout_position: int = 0, stdout_length: int = 0, stderr_position: int = 0, stderr_length: int = 0, ) -> Dict[str, Any]: job = self.job_manager.get_accessible_job(trans, id, stdout_position, stdout_length) job = self.job_manager.get_accessible_job(trans, id, stdout_position, stdout_length, stderr_position, stderr_length) return view_show_job(trans, job, bool(full)) def index( Loading