Skip to content
Snippets Groups Projects
Commit c023dfa4 authored by Philip ABBET's avatar Philip ABBET
Browse files

Fix the execution in a container

parent 14af44b4
No related branches found
No related tags found
1 merge request!14Add support to serve databases from a docker container
Pipeline #
...@@ -114,10 +114,8 @@ class DBExecutor(object): ...@@ -114,10 +114,8 @@ class DBExecutor(object):
self.input_list = None self.input_list = None
self.data_sources = [] self.data_sources = []
self.handler = None self.handler = None
# runs validation if required
self.errors = [] self.errors = []
self.data = data self.data = None
# temporary caches, if the user has not set them, for performance # temporary caches, if the user has not set them, for performance
database_cache = database_cache if database_cache is not None else {} database_cache = database_cache if database_cache is not None else {}
...@@ -137,7 +135,7 @@ class DBExecutor(object): ...@@ -137,7 +135,7 @@ class DBExecutor(object):
self.input_list = None self.input_list = None
self.data_sources = [] self.data_sources = []
if not isinstance(data, dict): #user has passed a file pointer if not isinstance(data, dict): #user has passed a file name
if not os.path.exists(data): if not os.path.exists(data):
self.errors.append('File not found: %s' % data) self.errors.append('File not found: %s' % data)
return return
...@@ -254,9 +252,8 @@ class DBExecutor(object): ...@@ -254,9 +252,8 @@ class DBExecutor(object):
) )
self.input_list.add(group) self.input_list.add(group)
input_conf = self.data['inputs'][name] input_db = self.databases[details['database']]
input_db = self.databases[input_conf['database']] input_dataformat_name = input_db.set(details['protocol'], details['set'])['outputs'][details['output']]
input_dataformat_name = input_db.set(input_conf['protocol'], input_conf['set'])['outputs'][name]
group.add(inputs.Input(name, self.dataformat_cache[input_dataformat_name], data_source)) group.add(inputs.Input(name, self.dataformat_cache[input_dataformat_name], data_source))
......
...@@ -132,7 +132,8 @@ def main(): ...@@ -132,7 +132,8 @@ def main():
database_cache = {} database_cache = {}
try: try:
dbexecutor = DBExecutor(args['<dir>'], 'configuration.json', dbexecutor = DBExecutor(os.path.join(args['<dir>'], 'prefix'),
os.path.join(args['<dir>'], 'configuration.json'),
dataformat_cache, database_cache) dataformat_cache, database_cache)
except (MemoryError): except (MemoryError):
raise raise
...@@ -141,7 +142,7 @@ def main(): ...@@ -141,7 +142,7 @@ def main():
exc_type, exc_value, exc_traceback = sys.exc_info() exc_type, exc_value, exc_traceback = sys.exc_info()
tb = traceback.extract_tb(exc_traceback) tb = traceback.extract_tb(exc_traceback)
s = ''.join(traceback.format_list(tb[4:])) #exclude this file s = ''.join(traceback.format_list(tb[4:])) #exclude this file
s = s.replace(args['<dir>']).strip() s = s.replace(args['<dir>'], '').strip()
raise UserError("%s%s: %s" % (s, type(e).__name__, e)) raise UserError("%s%s: %s" % (s, type(e).__name__, e))
# Execute the code # Execute the code
...@@ -156,7 +157,7 @@ def main(): ...@@ -156,7 +157,7 @@ def main():
exc_type, exc_value, exc_traceback = sys.exc_info() exc_type, exc_value, exc_traceback = sys.exc_info()
tb = traceback.extract_tb(exc_traceback) tb = traceback.extract_tb(exc_traceback)
s = ''.join(traceback.format_list(tb[4:])) s = ''.join(traceback.format_list(tb[4:]))
s = s.replace(args['<dir>']).strip() s = s.replace(args['<dir>'], '').strip()
raise UserError("%s%s: %s" % (s, type(e).__name__, e)) raise UserError("%s%s: %s" % (s, type(e).__name__, e))
except UserError as e: except UserError as e:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment