Commit 0728d63f authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

some improvements for console argument parser

updated __version__


Former-commit-id: 02670273
parent c8909644
......@@ -15,7 +15,7 @@ from . import config
from .processing.process_controller import process_controller
__version__ = '20170411.01'
__version__ = '20170411.02'
__author__ = 'Daniel Scheffler'
__all__ = ['algorithms',
'io',
......
......@@ -5,6 +5,9 @@ import sys
import argparse
import warnings
import matplotlib
matplotlib.use('Agg', warn=False) # switch matplotlib backend to 'Agg' and disable warning in case its already 'Agg'
try:
from GeoMultiSens import process_controller, __version__
from GeoMultiSens.misc.database_tools import GMS_JOB
......@@ -17,6 +20,11 @@ except ImportError as e:
def run_from_jobid(args):
# TODO distinguish between ID of a master, processing or download job
# TODO master: find corresponding sub-jobs and run them
# TODO processing: check for not downloaded scenes and run processing after download
# TODO download: run only the downloader
# set up process controller instance
PC = process_controller(args.jobid, parallelization_level='scenes')
#PC.job.path_procdata_scenes = '/geoms/data/processed_scenes_dev'
......@@ -147,7 +155,9 @@ if __name__=='__main__':
prog='run_gms.py',
description='='*70+'\n'+'GeoMultiSens console argument parser. ' \
'Python implementation by Daniel Scheffler (daniel.scheffler@gfz-potsdam.de)',
epilog="")
epilog="The argument parser offers multiple sub-argument parsers (jobid, sceneids, ...) for starting GMS jobs. "
"use '>>> python /path/to/GeMultiSens/run_gms.py <sub-parser> -h' for detailed documentation and usage "
"hints.")
parser.add_argument('--version', action='version', version=__version__)
......@@ -155,21 +165,21 @@ if __name__=='__main__':
### CONFIGURE SUBPARSERS FOR GeoMultiSens
parse_jobid = subparsers.add_parser('jobid',
parser_jobid = subparsers.add_parser('jobid',
description= 'Run a GeoMultiSens job using an already existing job ID.',
help="use '>>> python /path/to/GeMultiSens/run_gms.py jobid -h' for documentation and usage hints")
help="Run a GeoMultiSens job using an already existing job ID (Sub-Parser).")
parse_sceneids = subparsers.add_parser('sceneids',
parser_sceneids = subparsers.add_parser('sceneids',
description='Run a GeoMultiSens job for a given list of scene IDs.',
help="use '>>> python /path/to/GeMultiSens/run_gms.py sceneids -h' for documentation and usage hints")
help="Run a GeoMultiSens job for a given list of scene IDs (Sub-Parser).")
parse_entityids = subparsers.add_parser('entityids',
parser_entityids = subparsers.add_parser('entityids',
description='Run a GeoMultiSens job for a given list of entity IDs.',
help="use '>>> python /path/to/GeMultiSens/run_gms.py entityids -h' for documentation and usage hints")
help="Run a GeoMultiSens job for a given list of entity IDs (Sub-Parser).")
parse_constraints = subparsers.add_parser('constraints',
parser_constraints = subparsers.add_parser('constraints',
description='Run a GeoMultiSens job matching the given constraints.',
help="use '>>> python /path/to/GeMultiSens/run_gms.py constraints -h' for documentation and usage hints")
help="Run a GeoMultiSens job matching the given constraints (Sub-Parser).")
#parse_from_sceneids = subparsers.add_parser('from_sceneids',
# description='Run a GeoMultiSens job for a given list of scene IDs.',
......@@ -179,19 +189,19 @@ if __name__=='__main__':
## ADD ARGUMENTS
if sys.argv[1]=='jobid':
# add arguments to parse_jobid
jid_p = parse_jobid.add_argument
jid_p = parser_jobid.add_argument
jid_p('jobid', type=int,
help='job ID of an already created GeoMultiSens job (must be present in the jobs table of the database)')
elif sys.argv[1]=='sceneids':
# add arguments to parse_sceneids
sid_p = parse_sceneids.add_argument
sid_p = parser_sceneids.add_argument
sid_p('sceneids', nargs='+', type=int,
help="list of scene IDs corresponding to valid records within the 'scenes' table of the database")
elif sys.argv[1]=='entityids':
# add arguments to parse_entityids
eid_p = parse_sceneids.add_argument
eid_p = parser_entityids.add_argument
eid_p('entityids', nargs='+', type=str,
help="list of entity IDs corresponding to valid records within the 'scenes' table of the database")
# FIXME satellite and sensor are required
......@@ -199,7 +209,7 @@ if __name__=='__main__':
elif sys.argv[1]=='constraints':
# add arguments to parse_constraints
con_p = parse_sceneids.add_argument
con_p = parser_constraints.add_argument
# TODO
#con_p('constraints', nargs='+', type=str, help="list of entity IDs corresponding to valid records within the "
# "'scenes' table of the database")
......@@ -227,10 +237,10 @@ if __name__=='__main__':
## LINK PARSERS TO RUN FUNCTIONS
parse_jobid.set_defaults(func=run_from_jobid)
parse_sceneids.set_defaults(func=run_from_sceneids)
parse_entityids.set_defaults(func=run_from_entityids)
parse_constraints.set_defaults(func=run_from_constraints)
parser_jobid.set_defaults(func=run_from_jobid)
parser_sceneids.set_defaults(func=run_from_sceneids)
parser_entityids.set_defaults(func=run_from_entityids)
parser_constraints.set_defaults(func=run_from_constraints)
# RUN!
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment