Skip to content
Snippets Groups Projects
Commit 60354a7f authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[scripts][databases_provider] Add parameter to specify configuration section to load

With the current implementation, the configuration of the
execution process may contain two entries:
1) Main algorithm
2) Loop algorithm

The way the databases provider works will only load the main
entry which means that it will use the wrong configuration
for the loop algorithm. This new parameter allows to set
which entry should be used to configure the database. The
default is None so the default behaviour doesn't change.
parent 8c8901f9
No related branches found
No related tags found
1 merge request!31Add parameter to specify configuration section to load for databases_provider
Pipeline #25467 passed
......@@ -29,15 +29,16 @@
"""Executes some database views. (%(version)s)
usage:
%(prog)s [--debug] <addr> <dir> <cache>
%(prog)s [--debug] <addr> <dir> <cache> [<conf_name>]
%(prog)s (--help)
%(prog)s (--version)
arguments:
<addr> Listen for incoming request on this address ('host:port')
<dir> Directory containing all configuration required to run the views
<cache> Path to the cache
<addr> Listen for incoming request on this address ('host:port')
<dir> Directory containing all configuration required to run the views
<cache> Path to the cache
<conf_name> Name of the configuration to load
options:
......@@ -55,6 +56,7 @@ import docopt
import simplejson
import pwd
import stat
import json
import zmq
......@@ -167,10 +169,26 @@ def main(arguments=None):
database_cache = {}
try:
configuration_path = os.path.join(args['<dir>'], 'configuration.json')
if not os.path.exists(configuration_path):
raise RuntimeError("Configuration file '%s' not found" %
configuration_path)
with open(configuration_path) as f:
configuration_data = json.load(f)
configuration_name = args.get('<conf_name>', None)
if configuration_name is not None:
configuration_data = configuration_data.get(configuration_name,
None)
if configuration_data is None:
raise RuntimeError("Configuration section '%s' not found" %
configuration_name)
dbexecutor = DBExecutor(message_handler,
os.path.join(args['<dir>'], 'prefix'),
args['<cache>'],
os.path.join(args['<dir>'], 'configuration.json'),
configuration_data,
dataformat_cache,
database_cache)
except (MemoryError):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment