diff --git a/.travis.yml b/.travis.yml index fd26fed..d5b914b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,9 +7,6 @@ matrix: - name: Check black formatting python: 3.7 env: TOXENV=black - - name: Check flake8 on Python 2 - python: 2.7 - env: TOXENV=flake8 - name: Check flake8 on Python 3 python: 3.7 env: TOXENV=flake8 diff --git a/faculty_distributed/manager.py b/faculty_distributed/manager.py index 1ee3c1e..98c321e 100644 --- a/faculty_distributed/manager.py +++ b/faculty_distributed/manager.py @@ -8,6 +8,14 @@ from faculty import client +class JobOutputNotFoundError(Exception): + """Raised when the output of a job has not been saved. This error is likely + to have been raised due to a failed job. + """ + + pass + + class FacultyJobExecutor: """ Run generic python function in parallel on Faculty Jobs @@ -107,11 +115,16 @@ def _collect_output(self, args_sequence): """ out = [] for i in range(len(args_sequence)): - with open( - os.path.join(self.tmpdir, "output/out_{}.pkl".format(i)), "rb" - ) as f: - out.append(cloudpickle.load(f)) - + filepath = os.path.join(self.tmpdir, "output/out_{}.pkl".format(i)) + try: + with open(filepath, "rb",) as f: + out.append(cloudpickle.load(f)) + except FileNotFoundError: + raise JobOutputNotFoundError( + "No such file: '{}'. This error is likely to have been " + "raised due to a failed job. Check the Jobs history for " + "further details.".format(filepath) + ) return out def _make_dirs(self): diff --git a/tox.ini b/tox.ini index 563b64d..e9accf5 100644 --- a/tox.ini +++ b/tox.ini @@ -11,6 +11,6 @@ commands = [testenv:black] skip_install = True deps = - black==19.3b0 + black==19.10b0 commands = black {posargs:--check .}