Skip to content

Commit 89d58b6

Browse files
committed
add job JSON dumping
1 parent b235fc6 commit 89d58b6

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ export DJANGO_RIDGEBACK_PORT:=7001
315315
export BEAGLE_RIDGEBACK_URL=http://$(DJANGO_RIDGEBACK_IP):$(DJANGO_RIDGEBACK_PORT)
316316
export DJ_DEBUG_LOG:=$(LOG_DIR_ABS)/dj.debug.log
317317
export BEAGLE_LOG_PATH:=$(LOG_DIR_ABS)/beagle-server.log
318+
export DUMP_JSON:=False
318319

319320
# initialize the Django app in the database
320321
# do this after setting up the db above

beagle/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,4 @@
316316
PROJECT_DIR = os.path.dirname(os.path.realpath(__file__))
317317
ROOT_DIR = os.path.dirname(PROJECT_DIR)
318318
TEST_FIXTURE_DIR = os.path.join(ROOT_DIR, "fixtures", "tests")
319+
DUMP_JSON = os.environ.get('DUMP_JSON') == 'True'

runner/tasks.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import uuid
33
import logging
44
import requests
5+
import json
56
from celery import shared_task
67
from django.conf import settings
78
from runner.run.objects.run_object import RunObject
@@ -95,6 +96,9 @@ def process_triggers():
9596
@shared_task
9697
def create_run_task(run_id, inputs, output_directory=None):
9798
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"))
98102
try:
99103
run = RunObject.from_cwl_definition(run_id, inputs)
100104
run.ready()
@@ -125,13 +129,23 @@ def submit_job(run_id, output_directory=None):
125129
inputs = dict()
126130
for port in run.port_set.filter(port_type=PortType.INPUT).all():
127131
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+
128137
if not output_directory:
129138
output_directory = os.path.join(run.app.output_directory, str(run_id))
130139
job = {
131140
'app': app,
132141
'inputs': inputs,
133142
'root_dir': output_directory
134143
}
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+
135149
logger.info("Job %s ready for submitting" % run_id)
136150
response = requests.post(settings.RIDGEBACK_URL + '/v0/jobs/', json=job)
137151
if response.status_code == 201:

0 commit comments

Comments
 (0)