Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Berselli authored and Michele Berselli committed Oct 22, 2021
1 parent 0318a92 commit 0a9174b
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 28 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
__pycache__
*egg-info*
.DS_Store
.coverage
build
dist
.eggs
_build
_static
_templates
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0
94 changes: 94 additions & 0 deletions pipeline_utils/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env python3

################################################
#
# __main__
# this is the entry point for command line
#
# Michele Berselli - [email protected]
# Phil Grayson - [email protected]
#
################################################

################################################
# Libraries
################################################
import sys, os
import argparse

# Commands
from pipeline_utils import deploy_pipeline

################################################
# Functions
################################################
################################################
# main
################################################
def main(args=None):
'''
command line wrapper around available commands
'''
# Adding parser and subparsers
parser = argparse.ArgumentParser(prog='pipeline_utils', description='Collection of utilities for cgap-pipeline')
subparsers = parser.add_subparsers(dest='func', metavar="<command>")

# Add deploy_pipeline to subparsers
deploy_pipeline_parser = subparsers.add_parser('deploy_pipeline', description='Utility to automatically deploy a pipeline',
help='Utility to automatically deploy a pipeline')

# Required args
deploy_pipeline_parser.add_argument('--ff-env', required=True)
deploy_pipeline_parser.add_argument('--cwl-bucket', required=False)
deploy_pipeline_parser.add_argument('--account', required=False)
deploy_pipeline_parser.add_argument('--region', required=False)
deploy_pipeline_parser.add_argument('--project-uuid', required=False)
deploy_pipeline_parser.add_argument('--institution-uuid', required=False)

# Optional args
deploy_pipeline_parser.add_argument('--post-software', action='store_true')
deploy_pipeline_parser.add_argument('--post-file-format', action='store_true')
deploy_pipeline_parser.add_argument('--post-file-reference', action='store_true')
deploy_pipeline_parser.add_argument('--post-workflow', action='store_true')
deploy_pipeline_parser.add_argument('--post-metaworkflow', action='store_true')
deploy_pipeline_parser.add_argument('--post-cwl', action='store_true')
deploy_pipeline_parser.add_argument('--post-ecr', action='store_true')
deploy_pipeline_parser.add_argument('--del-prev-version', action='store_true')

# Subparsers map
subparser_map = {
'deploy_pipeline': deploy_pipeline_parser
}

# Checking arguments
if len(sys.argv) == 1:
parser.print_help(sys.stderr)
sys.exit(1)
elif len(sys.argv) == 2:
if sys.argv[1] in subparser_map:
subparser_map[sys.argv[1]].print_help(sys.stderr)
sys.exit(1)
else:
parser.print_help(sys.stderr)
sys.exit(1)
#end if
#end if
args = vars(parser.parse_args())

print(args)
sys.exit()

# Call the right tool
if args['func'] == 'deploy_pipeline':
deploy_pipeline.main(args)

#################################################################
#
# MAIN
#
#################################################################
if __name__ == "__main__":

main()

#end if
36 changes: 12 additions & 24 deletions pipeline_utils/deploy_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,17 @@ def _post_patch_repo(ff_key, cwl_bucket, account, region,


################################################
# main
# runner
################################################
def main(args):
'''
deploy cgap pipeline
post | patch metadata and dockers in the specified environment from repos
'''

print(args)
return

# Get env variables
if os.environ.get('GLOBAL_BUCKET_ENV', ''): # new cgap account
s3 = s3_utils.s3Utils(env=ff_env)
Expand Down Expand Up @@ -380,28 +383,13 @@ def main(args):
args.post_cwl, args.post_ecr, args.del_prev_version)


if __name__ == '__main__':

parser = argparse.ArgumentParser()

# Required args
parser.add_argument('--ff-env', required=True)
parser.add_argument('--cwl-bucket', required=False)
parser.add_argument('--account', required=False)
parser.add_argument('--region', required=False)
parser.add_argument('--project-uuid', required=False)
parser.add_argument('--institution-uuid', required=False)

# Optional args
parser.add_argument('--post-software', action='store_true')
parser.add_argument('--post-file-format', action='store_true')
parser.add_argument('--post-file-reference', action='store_true')
parser.add_argument('--post-workflow', action='store_true')
parser.add_argument('--post-metaworkflow', action='store_true')
parser.add_argument('--post-cwl', action='store_true')
parser.add_argument('--post-ecr', action='store_true')
parser.add_argument('--del-prev-version', action='store_true')
#################################################################
#
# MAIN
#
#################################################################
if __name__ == "__main__":

args = parser.parse_args()
main()

main(args)
#end if
Empty file added pipeline_utils/lib/__init__.py
Empty file.
File renamed without changes.
13 changes: 9 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages

# Description
with open('README_utils.md') as fd:
with open('README.md') as fd:
long_description = fd.read()
#end with

Expand All @@ -20,13 +20,13 @@

setup(
name='cgap-pipeline-utils',
version=open('VERSION').readlines()[-1].replace('v', '').strip() + '.0', # VERSION.release
version=open('VERSION').readlines()[-1],
description = 'Collection of utilities for cgap-pipeline',
long_description = long_description,
long_description_content_type = 'text/markdown',
author = 'Michele Berselli, Soo Lee',
author = 'Michele Berselli, Phil Grayson',
author_email = '[email protected]',
url='https://github.com/dbmi-bgm/cgap-pipeline',
url='https://github.com/dbmi-bgm/cgap-pipeline-utils',
include_package_data=True,
packages=['pipeline_utils'],
classifiers=[
Expand All @@ -35,6 +35,11 @@
'Programming Language :: Python',
'Programming Language :: Python :: 3'
],
entry_points = {
'console_scripts': [
'pipeline_utils = pipeline_utils.__main__:main',
]
},
install_requires=install_requires,
setup_requires=install_requires,
tests_require=tests_requires,
Expand Down

0 comments on commit 0a9174b

Please sign in to comment.