Commit ff323259 authored by Daniel Scheffler's avatar Daniel Scheffler Committed by Mathias Peters
Browse files

Added possibility to run test job via CLI argparser.

parent 995c68f7
......@@ -31,10 +31,15 @@ def run_from_jobid(args):
# TODO download: run only the downloader
# set up process controller instance
PC = process_controller(args.jobid, **get_config_kwargs_from_cli_args(args))
kwargs = get_config_kwargs_from_cli_args(args)
# run the job
if 'GMS_IS_TEST' in os.environ and os.environ['GMS_IS_TEST'] == 'True':
kwargs['is_test'] = True
PC = process_controller(args.jobid, **kwargs)
# run the job
if 'GMS_IS_TEST_CONFIG' in os.environ and os.environ['GMS_IS_TEST_CONFIG'] == 'True':
# in case of software test, it is enough to get an instance of process controller because all inputs are
# validated within options.config.Job_Config (indirectly called by ProcessController.__init__() )
pass
......@@ -100,10 +105,13 @@ def _run_job(dbJob, **config_kwargs):
dbJob.create()
# set up process controller instance
if 'GMS_IS_TEST' in os.environ and os.environ['GMS_IS_TEST'] == 'True':
config_kwargs['is_test'] = True
PC = process_controller(dbJob.id, **config_kwargs)
# run the job
if 'GMS_IS_TEST' in os.environ and os.environ['GMS_IS_TEST'] == 'True':
if 'GMS_IS_TEST_CONFIG' in os.environ and os.environ['GMS_IS_TEST_CONFIG'] == 'True':
# in case of software test, it is enough to get an instance of process controller because all inputs are
# validated within options.config.Job_Config (indirectly called by ProcessController.__init__() )
pass
......@@ -163,6 +171,10 @@ def get_gms_argparser():
default=options_default["usecase"]["datasetid_spatial_ref"],
help='dataset ID of the spatial reference')
gop_p('--CPUs', type=int,
default=options_default["global_opts"]["CPUs"],
help='number of CPU cores to be used for processing (default: "None" -> use all available')
gop_p('-c', '--comment', nargs='?', type=str,
default='',
help='comment concerning the job')
......
......@@ -61,6 +61,7 @@ class GMS_logger(logging.Logger):
fileHandler = None
# set fileHandler for job logfile
# if False: # log_to_joblog:
if log_to_joblog:
job_logfile = os.path.join(CFG.path_job_logs, '%s.log' % CFG.ID)
......@@ -162,9 +163,9 @@ class GMS_logger(logging.Logger):
# if handler.get_name()=='StringIO handler':
# self.streamObj.flush()
# self.streamHandler.flush()
handler.close()
self.removeHandler(handler) # if not called with '[:]' the StreamHandlers are left open
handler.flush()
handler.close()
except PermissionError:
warnings.warn('Could not properly close logfile due to a PermissionError: %s' % sys.exc_info()[1])
......@@ -182,8 +183,9 @@ def close_logger(logger):
if logger and hasattr(logger, 'handlers'):
for handler in logger.handlers[:]: # if not called with '[:]' the StreamHandlers are left open
try:
handler.close()
logger.removeHandler(handler)
handler.flush()
handler.close()
except PermissionError:
warnings.warn('Could not properly close logfile due to a PermissionError: %s' % sys.exc_info()[1])
......
......@@ -289,10 +289,12 @@ class JobConfig(object):
self.path_fileserver = self.joinP(path_gmslib, '..', 'tests', 'data')
self.path_archive = self.joinP(path_gmslib, '..', 'tests', 'data', 'archive_data')
self.path_procdata_scenes = self.joinP(path_gmslib, '..', 'tests', 'data', 'output_scenes')
# self.path_procdata_scenes = '/data1/gms/mount/db/data/processed_scenes/test_loggingerrors/' # FIXME
self.path_procdata_MGRS = self.joinP(path_gmslib, '..', 'tests', 'data', 'output_mgrs_tiles')
self.path_ECMWF_db = self.joinP(path_gmslib, '..', 'tests', 'data', 'processed_ECMWF')
self.path_benchmarks = self.joinP(path_gmslib, '..', 'tests', 'data', 'benchmarks')
self.path_job_logs = self.joinP(path_gmslib, '..', 'tests', 'data', 'job_logs')
# self.path_job_logs = '/data1/gms/mount/db/data/job_logs/' # FIXME
###########################
# processor configuration #
......
......@@ -28,10 +28,10 @@ class Base_CLITester:
def setUp(self):
self.parser_run = run_path(path_run_gms)['get_gms_argparser']()
os.environ['GMS_IS_TEST'] = 'True'
os.environ['GMS_IS_TEST_CONFIG'] = 'True'
def tearDown(self):
del os.environ['GMS_IS_TEST']
del os.environ['GMS_IS_TEST_CONFIG']
# delete the created test job in case the created subparser creates a new job
if self.baseargs[0] in ['sceneids', 'entityids', 'filenames']:
......
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