Skip to content

Commit

Permalink
Add java_opts to cbioportalImporter.py (#13)
Browse files Browse the repository at this point in the history
* Convert jar_path to java_opts

* Keep usage of jar_path and integrate it with java_opts

* Make the JAVA_OPTS from the environment the default for --java_opts
  • Loading branch information
oplantalech authored Apr 4, 2024
1 parent 08e5e17 commit 2047090
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
24 changes: 19 additions & 5 deletions src/main/resources/scripts/importer/cbioportalImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ def check_dir(study_directory):
def add_parser_args(parser):
parser.add_argument('-s', '--study_directory', type=str, required=False,
help='Path to Study Directory')
parser.add_argument('-jvo', '--java_opts', type=str, default=os.environ.get('JAVA_OPTS'),
help='Path to specify JAVA_OPTS for the importer. \
(default: gets the JAVA_OPTS from the environment)')
parser.add_argument('-jar', '--jar_path', type=str, required=False,
help='Path to scripts JAR file')
parser.add_argument('-meta', '--meta_filename', type=str, required=False,
Expand Down Expand Up @@ -520,18 +523,29 @@ def main(args):
module_logger.addHandler(error_handler)
LOGGER = module_logger

# jar_path is optional. If not set, try to find it relative to this script
if args.jar_path is None:
# move jar_path to java_opts if it exists
if args.jar_path:
args.java_opts = f"-cp {args.jar_path} {args.java_opts}"

# java_opts is optional. If class (jar) path is not set (-cp), try to find the jar path relative to this script
locate_jar_path = True
if args.java_opts is not None and '-cp' in args.java_opts:
locate_jar_path = False
if locate_jar_path:
try:
args.jar_path = locate_jar()
jar_path = locate_jar()
except FileNotFoundError as e:
print(e)
sys.exit(2)
print('Data loading step using', args.jar_path)
print('Data loading step using', jar_path)
print()
if args.java_opts is None:
args.java_opts = f"-cp {jar_path}"
else:
args.java_opts = f"-cp {jar_path} {args.java_opts}"

# process the options
jvm_args = "-Dspring.profiles.active=dbcp -cp " + args.jar_path
jvm_args = "-Dspring.profiles.active=dbcp " + args.java_opts
study_directory = args.study_directory

# check if DB version and application version are in sync
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/scripts/importer/metaImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ def interface():
portal_mode_group.add_argument('-n', '--no_portal_checks', default=False,
action='store_true',
help='Skip tests requiring information '
'from the cBioPortal installation')
'from the cBioPortal installation')
parser.add_argument('-jvo', '--java_opts', type=str, default=os.environ.get('JAVA_OPTS'),
help='Path to specify JAVA_OPTS for the importer. \
(default: gets the JAVA_OPTS from the environment)')
parser.add_argument('-jar', '--jar_path', type=str, required=False,
help=(
'Path to scripts JAR file (default: locate it '
'relative to the import script)'))
help='Path to scripts JAR file (default: locate it '
'relative to the import script)')
parser.add_argument('-html', '--html_table', type=str,
help='path to html report')
parser.add_argument('-v', '--verbose', action='store_true',
Expand Down

0 comments on commit 2047090

Please sign in to comment.