def delete_job(job_id): # noqa r"""Delete a given job. --- delete: summary: Deletes a given job. description: >- This resource expects the `job_id` of the job to be deleted. operationId: delete_job consumes: - application/json produces: - application/json parameters: - name: job_id in: path description: Required. ID of the job to be deleted. required: true type: string responses: 204: description: >- Request accepted. A request to delete the job has been sent to the computing backend. 404: description: Request failed. The given job ID does not seem to exist. examples: application/json: "message": >- The job cdcf48b1-c2f3-4693-8230-b066e088444c doesn't exist 502: description: >- Request failed. Something went wrong while calling the computing backend. examples: application/json: "message": >- Connection to computing backend failed: [reason] """ if job_exists(job_id): try: backend_job_id = retrieve_backend_job_id(job_id) #KubernetesJobManager.stop(backend_job_id) HTCondorJobManager.stop(backend_job_id) return jsonify(), 204 except ComputingBackendSubmissionError as e: return jsonify({ 'message': 'Connection to computing backend failed:\n{}'.format(e) }), 502 else: return jsonify({'message': 'The job {} doesn\'t exist'.format(job_id)}), 404
def delete_job(job_id): # noqa r"""Delete a given job. --- delete: summary: Deletes a given job. description: >- This resource expects the `job_id` of the job to be deleted. operationId: delete_job consumes: - application/json produces: - application/json parameters: - name: job_id in: path description: Required. ID of the job to be deleted. required: true type: string - name: compute_backend in: query description: Job compute backend. required: false type: string responses: 204: description: >- Request accepted. A request to delete the job has been sent to the compute backend. 404: description: Request failed. The given job ID does not seem to exist. examples: application/json: "message": >- The job cdcf48b1-c2f3-4693-8230-b066e088444c doesn't exist 502: description: >- Request failed. Something went wrong while calling the compute backend. examples: application/json: "message": >- Connection to compute backend failed: [reason] """ if job_exists(job_id): try: compute_backend = request.args.get( "compute_backend", current_app.config["DEFAULT_COMPUTE_BACKEND"] ) backend_job_id = retrieve_backend_job_id(job_id) job_manager_cls = current_app.config["COMPUTE_BACKENDS"][compute_backend]() job_manager_cls.stop(backend_job_id) return jsonify(), 204 except ComputingBackendSubmissionError as e: return ( jsonify( {"message": "Connection to compute backend failed:\n{}".format(e)} ), 502, ) else: return jsonify({"message": "The job {} doesn't exist".format(job_id)}), 404