|
2 | 2 | import uuid |
3 | 3 | import logging |
4 | 4 | import requests |
| 5 | +import json |
5 | 6 | from celery import shared_task |
6 | 7 | from django.conf import settings |
7 | 8 | from runner.run.objects.run_object import RunObject |
@@ -95,6 +96,9 @@ def process_triggers(): |
95 | 96 | @shared_task |
96 | 97 | def create_run_task(run_id, inputs, output_directory=None): |
97 | 98 | logger.info("Creating and validating Run") |
| 99 | + if settings.DUMP_JSON: |
| 100 | + output_file_name = "{}.job.inputs.json".format(run_id) |
| 101 | + print(json.dumps(inputs, indent = 4), file = open(output_file_name, "w")) |
98 | 102 | try: |
99 | 103 | run = RunObject.from_cwl_definition(run_id, inputs) |
100 | 104 | run.ready() |
@@ -125,13 +129,23 @@ def submit_job(run_id, output_directory=None): |
125 | 129 | inputs = dict() |
126 | 130 | for port in run.port_set.filter(port_type=PortType.INPUT).all(): |
127 | 131 | inputs[port.name] = port.value |
| 132 | + |
| 133 | + if settings.DUMP_JSON: |
| 134 | + output_file_name = "{}.job.inputs-cwl.json".format(run_id) |
| 135 | + print(json.dumps(inputs, indent = 4), file = open(output_file_name, "w")) |
| 136 | + |
128 | 137 | if not output_directory: |
129 | 138 | output_directory = os.path.join(run.app.output_directory, str(run_id)) |
130 | 139 | job = { |
131 | 140 | 'app': app, |
132 | 141 | 'inputs': inputs, |
133 | 142 | 'root_dir': output_directory |
134 | 143 | } |
| 144 | + |
| 145 | + if settings.DUMP_JSON: |
| 146 | + output_file_name = "{}.job.json".format(run_id) |
| 147 | + print(json.dumps(job, indent = 4), file = open(output_file_name, "w")) |
| 148 | + |
135 | 149 | logger.info("Job %s ready for submitting" % run_id) |
136 | 150 | response = requests.post(settings.RIDGEBACK_URL + '/v0/jobs/', json=job) |
137 | 151 | if response.status_code == 201: |
|
0 commit comments