From 7468a0652e925add3abb5d104b0fde9b977d25e4 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 25 May 2020 20:12:36 -0400 Subject: [PATCH 1/3] ENH: provide "datalad" module as a name, and why into msg of MissingExternalDependency Otherwise str() of that exception looks like DataLad is required for orchestrator datalad-pair-run is missing. and it is impossible to obtain the "name" of the missing external module. Well, ideally this exception should have kept msg as the first arg instead of making it into the "name", but oh well -- that is how it is now --- reproman/support/jobs/orchestrators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/reproman/support/jobs/orchestrators.py b/reproman/support/jobs/orchestrators.py index 1b163a4a7..a7339c1ef 100644 --- a/reproman/support/jobs/orchestrators.py +++ b/reproman/support/jobs/orchestrators.py @@ -486,7 +486,8 @@ def __init__(self, resource, submission_type, job_spec=None, resurrection=False): if not external_versions["datalad"]: raise MissingExternalDependency( - "DataLad is required for orchestrator '{}'".format(self.name)) + "datalad", + msg="Required for orchestrator '{}'".format(self.name)) super(DataladOrchestrator, self).__init__( resource, submission_type, job_spec, resurrection=resurrection) From f7d6c3c2691491eedce6a5d2d6c56f1700c0303f Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 25 May 2020 20:14:17 -0400 Subject: [PATCH 2/3] ENH: allow for jobs -s to report NA status whenever needed external is mising Instead of crashing altogether demanding to install the needed dependency. Since it is just a show_oneline, and not programmable interface, I thought it would be better to report that something is missing but continue otherwise so other jobs statuses could be seen --- reproman/interface/jobs.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/reproman/interface/jobs.py b/reproman/interface/jobs.py index 7a104e76e..cb97f5f58 100644 --- a/reproman/interface/jobs.py +++ b/reproman/interface/jobs.py @@ -16,6 +16,7 @@ from reproman.dochelpers import exc_str from reproman.interface.base import Interface +from reproman.support.external_versions import MissingExternalDependency from reproman.support.jobs.local_registry import LocalRegistry from reproman.support.jobs.orchestrators import ORCHESTRATORS from reproman.resource import get_manager @@ -97,11 +98,15 @@ def show_oneline(job, status=False): """ fmt = "{status}{j[_jobid]} on {j[resource_name]} via {j[submitter]}$ {cmd}" if status: - orc = _resurrect_orc(job) - orc_status = orc.status - _, queried_status = orc.submitter.status - if orc_status == queried_status: - # Drop repeated status (e.g., our and condor's "running"). + try: + orc = _resurrect_orc(job) + orc_status = orc.status + _, queried_status = orc.submitter.status + if orc_status == queried_status: + # Drop repeated status (e.g., our and condor's "running"). + queried_status = None + except MissingExternalDependency as exc: + orc_status = "N/A - needs {}".format(exc.name) queried_status = None stat = "[status: {}{}] ".format( orc_status, From fb4e2a680a37c1fe660948263d554df1019ea109 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 25 May 2020 20:32:43 -0400 Subject: [PATCH 3/3] RF: just catch (and warn) on all exceptions That would make it obvious although not as pretty, but would not require each and other exception differential handling examples: $> reproman --dbg jobs -s 2020-05-25 20:31:09,793 [WARNING] datalad is missing. Required for orchestrator 'datalad-pair-run' [orchestrators.py:__init__:488] [status: N/A] 20200107-213600-f814 on smaug via condor$ '{inputs}' '{outputs}' participant --participan... $> reproman --dbg jobs -s [status: succeeded] 20200108-124152-a708 on smaug via condor$ '{inputs}' '{outputs}' participant --participan... 2020-05-25 20:32:59,254 [WARNING] [Errno 2] No such file or directory: '/home/yoh/.reproman/run-root/07ce9f04-9eb5-11ea-be9b-ff519d1f6bc9' [subprocess.py:_execute_child:1702] [status: N/A] 20200525-142526-10f0 on local via local$ '{inputs}' '{outputs}' participant --participan... --- reproman/interface/jobs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/reproman/interface/jobs.py b/reproman/interface/jobs.py index cb97f5f58..e711bf5f8 100644 --- a/reproman/interface/jobs.py +++ b/reproman/interface/jobs.py @@ -105,8 +105,9 @@ def show_oneline(job, status=False): if orc_status == queried_status: # Drop repeated status (e.g., our and condor's "running"). queried_status = None - except MissingExternalDependency as exc: - orc_status = "N/A - needs {}".format(exc.name) + except Exception as exc: + lgr.warning(exc_str(exc)) + orc_status = "N/A" queried_status = None stat = "[status: {}{}] ".format( orc_status,