Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicorninputjson #243

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tibanna/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ def args(self):
"your current default is %s)" % TIBANNA_DEFAULT_STEP_FUNCTION_NAME,
'default': TIBANNA_DEFAULT_STEP_FUNCTION_NAME},
{'flag': ["-p", "--postrunjson"],
'help': "print out postrun json instead", 'action': "store_true"}],
'help': "print out postrun json instead", 'action': "store_true"},
{'flag': ["-r", "--runjson"],
'help': "print out run json instead", 'action': "store_true"},
{'flag': ["-u", "--unicorn-input-json"],
'help': "print out unicorn input json instead", 'action': "store_true"}],
'add_user':
[{'flag': ["-u", "--user"],
'help': "user to add to a Tibanna usergroup"},
Expand Down Expand Up @@ -300,9 +304,10 @@ def list_sfns(numbers=False):
API().list_sfns(numbers=numbers)


def log(exec_arn=None, job_id=None, exec_name=None, sfn=TIBANNA_DEFAULT_STEP_FUNCTION_NAME, postrunjson=False):
def log(exec_arn=None, job_id=None, exec_name=None, sfn=TIBANNA_DEFAULT_STEP_FUNCTION_NAME,
postrunjson=False, runjson=False, unicorn_input_json=False):
"""print execution log or postrun json (-p) for a job"""
print(API().log(exec_arn, job_id, exec_name, sfn, postrunjson))
print(API().log(exec_arn, job_id, exec_name, sfn, postrunjson, runjson, unicorn_input_json))


def kill_all(sfn=TIBANNA_DEFAULT_STEP_FUNCTION_NAME):
Expand Down
5 changes: 4 additions & 1 deletion tibanna/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,14 @@ def kill_all(self, sfn=None):
else:
break

def log(self, exec_arn=None, job_id=None, exec_name=None, sfn=None, postrunjson=False, runjson=False, quiet=False):
def log(self, exec_arn=None, job_id=None, exec_name=None, sfn=None, postrunjson=False,
runjson=False, unicorn_input_json=False, quiet=False):
if postrunjson:
suffix = '.postrun.json'
elif runjson:
suffix = '.run.json'
elif unicorn_input_json:
suffix = '.unicorn.input.json'
else:
suffix = '.log'
if not sfn:
Expand Down
7 changes: 4 additions & 3 deletions tibanna/ec2_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ def input_dict(self):
return self.unicorn_input.as_dict()

def prelaunch(self, profile=None):
self.upload_run_json(self.input_dict, suffix='unicorn.input.json')
self.check_dependency(**self.args.dependency)
runjson = self.create_run_json_dict()
self.upload_run_json(runjson)
Expand Down Expand Up @@ -605,9 +606,9 @@ def create_run_json_dict(self):
del(pre['config']['key_name'])
return pre

def upload_run_json(self, runjson):
def upload_run_json(self, runjson, suffix = 'run.json'):
jsonbody = json.dumps(runjson, indent=4, sort_keys=True)
jsonkey = self.jobid + '.run.json'
jsonkey = self.jobid + '.' + suffix
# Keep log of the final json
logger.info("jsonbody=\n" + jsonbody)
# copy the json file to the s3 bucket
Expand All @@ -619,7 +620,7 @@ def upload_run_json(self, runjson):
try:
res = s3.put_object(Body=jsonbody.encode('utf-8'), Bucket=self.cfg.json_bucket, Key=jsonkey)
except Exception:
raise Exception("boto3 client error: Failed to upload run.json %s to s3: %s" % (jsonkey, str(res)))
raise Exception("boto3 client error: Failed to upload %s %s to s3: %s" % (suffix, jsonkey, str(res)))

def create_userdata(self, profile=None):
"""Create a userdata script to pass to the instance. The userdata script is run_workflow.$JOBID.sh.
Expand Down
6 changes: 4 additions & 2 deletions tibanna_4dn/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ def list_sfns(numbers=False):
API().list_sfns(numbers=numbers)


def log(exec_arn=None, job_id=None, exec_name=None, sfn=TIBANNA_DEFAULT_STEP_FUNCTION_NAME, postrunjson=False):
API().log(exec_arn, job_id, exec_name, sfn, postrunjson)
def log(exec_arn=None, job_id=None, exec_name=None, sfn=TIBANNA_DEFAULT_STEP_FUNCTION_NAME,
postrunjson=False, runjson=False, unicorn_input_json=False):
"""print execution log or postrun json (-p) for a job"""
print(API().log(exec_arn, job_id, exec_name, sfn, postrunjson, runjson, unicorn_input_json))


def kill_all(sfn=TIBANNA_DEFAULT_STEP_FUNCTION_NAME):
Expand Down
6 changes: 4 additions & 2 deletions tibanna_cgap/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ def list_sfns(numbers=False):
API().list_sfns(numbers=numbers)


def log(exec_arn=None, job_id=None, exec_name=None, sfn=TIBANNA_DEFAULT_STEP_FUNCTION_NAME, postrunjson=False):
API().log(exec_arn, job_id, exec_name, sfn, postrunjson)
def log(exec_arn=None, job_id=None, exec_name=None, sfn=TIBANNA_DEFAULT_STEP_FUNCTION_NAME,
postrunjson=False, runjson=False, unicorn_input_json=False):
"""print execution log or postrun json (-p) for a job"""
print(API().log(exec_arn, job_id, exec_name, sfn, postrunjson, runjson, unicorn_input_json))


def kill_all(sfn=TIBANNA_DEFAULT_STEP_FUNCTION_NAME):
Expand Down