예제 #1
0
    def catch_api_proxy_jobs_cleanup(job_uuid):
        try:
            # Get data before issuing deletion to the orchest-api. This
            # is needed to retrieve the job pipeline uuid and project
            # uuid. TODO: if the caller of the job knows about those
            # ids, we could avoid making a request to the orchest-api.
            resp = requests.get(
                (f'http://{current_app.config["ORCHEST_API_ADDRESS"]}/api'
                 f"/jobs/{job_uuid}"))
            data = resp.json()

            if resp.status_code == 200:
                pipeline_uuid = data["pipeline_uuid"]
                project_uuid = data["project_uuid"]

                # Tell the orchest-api that the job does not exist
                # anymore, will be stopped if necessary then cleaned up
                # from the orchest-api db.
                resp = requests.delete(
                    f"http://{current_app.config['ORCHEST_API_ADDRESS']}/api/"
                    f"jobs/cleanup/{job_uuid}")

                remove_job_directory(job_uuid, pipeline_uuid, project_uuid)
                analytics.send_job_delete(app, job_uuid)
                return resp.content, resp.status_code, resp.headers.items()

            elif resp.status_code == 404:
                raise ValueError(f"Job {job_uuid} does not exist.")
            else:
                raise Exception(f"{data}, {resp.status_code}")

        except Exception as e:
            msg = f"Error during job deletion:{e}"
            return {"message": msg}, 500
예제 #2
0
    def _collateral(self, exp_uuid: str, pipeline_uuid: str, project_uuid: str):
        if exp_uuid:
            # Tell the orchest-api that the job does not exist
            # anymore, will be stopped if necessary then cleaned up from
            # the orchest-api db.
            url = (
                f"http://{current_app.config['ORCHEST_API_ADDRESS']}/api/"
                f"jobs/cleanup/{exp_uuid}"
            )
            current_app.config["SCHEDULER"].add_job(requests.delete, args=[url])

            # Remove from the filesystem.
            remove_job_directory(exp_uuid, pipeline_uuid, project_uuid)