Skip to content
Snippets Groups Projects
Commit 1cbfcb13 authored by abaumann's avatar abaumann
Browse files

Fixes after review, and removed submit script that wasn't part of this

PR
parent 15b56f1c
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,8 @@ entity_update.tsv
__pycache__/
*.py[cod]
*$py.class
scripts/*.py[cod]
scripts/*$py.class
# Environments
.env
.venv
......
FROM google/cloud-sdk:170.0.1-slim
COPY install.sh /
RUN /bin/bash -c "/install.sh"
RUN /install.sh
# Tell gcloud to save state in /.config so it's easy to override as a mounted volume.
ENV HOME=/
......
......@@ -3,6 +3,8 @@ pip install PyYAML
pip install google-auth-httplib2
pip install google-api-python-client
pip install gcs-oauth2-boto-plugin
pip install google-cloud-datastore
pip install google-cloud
pip install retrying
pip install firecloud
pip install xlrd
......
File deleted
from common import *
from pprint import pprint
def escapedText(fileName):
with open(fileName, 'r') as f:
fileContent = f.read()
escapedText = json.dumps(fileContent)
return escapedText
def main():
setup()
# The main argument parser
parser = DefaultArgsParser(description="Create Method and Method Config from WDL source file and inputs json")
# Core application arguments
parser.add_argument('-mns', '--method-namespace', dest='method_namespace', action='store', required=True, help='Method namespace')
parser.add_argument('-mn', '--method-name', dest='method_name', action='store', required=True, help='Method name')
parser.add_argument('-wns', '--workspace-namespace', dest='workspace_namespace', action='store', required=True, help='Workspace namespace')
parser.add_argument('-wn', '--workspace-name', dest='workspace_name', action='store', required=True, help='Workspace name')
parser.add_argument('-w', '--wdl-file', dest='wdl_file', action='store', required=True, help='WDL source (File)')
parser.add_argument('-i', '--wdl-inputs', dest='wdl_inputs', action='store', required=False, help='WDL inputs (File)')
#Optional arguments
parser.add_argument('-s', '--method-synopsis', dest='method_synopsis', action='store', required=False, help='Method Synopsis (File)')
parser.add_argument('-d', '--method-docs', dest='method_docs', action='store', required=False, help='Method Docs (File)')
parser.add_argument('-cns', '--config-namespace', dest='config_namespace', action='store', required=False, help='Config namespace (Default: Method namespace')
parser.add_argument('-cn', '--config-name', dest='config_name', action='store', required=False, help='Config name (Default: Method name)')
parser.add_argument('-e', '--root-entity', dest='root_entity', action='store', required=False, help='Method config root entity (Default: participant)')
args = parser.parse_args()
docs = args.method_docs if (args.method_docs) else None
if args.method_synopsis is not None:
with open (args.method_synopsis, 'r') as f:
synopsis = f.read()
else:
synopsis = ""
#TODO: Add error handling for failed method creation requests
method_submission = firecloud_api.update_repository_method(args.method_namespace, args.method_name, synopsis, args.wdl_file, docs)
if method_submission.status_code != 201:
print method_submission
fail("Unable to create method: %s %s" % (args.method_namespace, args.method_name))
submission_json = method_submission.json()
config_name = args.config_name if (args.config_name) else args.method_name
config_namespace = args.config_namespace if (args.config_namespace) else args.method_namespace
root_entity = args.root_entity if (args.root_entity) else "participant"
#get inputs
if args.wdl_inputs is not None:
with open (args.wdl_inputs, 'r') as f:
inputs_json = json.loads(f.read())
#Filter out any key/values that contain # and escape characters
inputs_1 = {k:v for k,v in inputs_json.iteritems() if '#' not in k}
inputs = json.loads(json.dumps(inputs_1).replace('"','"\\"'))
else:
inputs = {}
#Build JSON for method config
method_body = json.dumps({
'name': config_name,
'namespace': config_namespace,
'methodRepoMethod': { 'methodNamespace': args.method_namespace,
'methodName': args.method_name,
'methodVersion': submission_json["snapshotId"]
},
'rootEntityType': root_entity,
"prerequisites": {},
"methodConfigVersion": 1,
"deleted": False,
"inputs": inputs,
"outputs": {}
})
print("method body: ")
print(method_body)
#TODO: perform GET to see if the method config already exists and use update_workspace_config instead
config_submission = firecloud_api.create_workspace_config(args.workspace_namespace, args.workspace_name, method_body)
config_submission_json = config_submission.json()
if config_submission.status_code != 201:
print("Failed request response:")
print(config_submission_json)
fail("Unable to create method config: %s %s " % (config_namespace, config_name))
if __name__ == "__main__":
main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment