Skip to content
Snippets Groups Projects
Commit 1812ce52 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-1093: when called from the commandline, don't use parallel uploading to...

TMSS-1093: when called from the commandline, don't use parallel uploading to make the log lines sequential/readable
parent 98b1121d
No related branches found
No related tags found
2 merge requests!634WIP: COBALT commissioning delta,!611TMSS-1093: export/populate schemas/templates
...@@ -23,7 +23,8 @@ def populate_main(): ...@@ -23,7 +23,8 @@ def populate_main():
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
populate_schemas(options.schema_dir, options.rest_credentials) # when called from the commandline, don't use parallel uploading to make the log lines sequential/readable
populate_schemas(options.schema_dir, options.rest_credentials, parallel=False)
# now that the schema's were uploaded, let's populate the dependend task connectors, and the permissions # now that the schema's were uploaded, let's populate the dependend task connectors, and the permissions
from lofar.sas.tmss.tmss import setup_and_check_tmss_django_database_connection_and_exit_on_error from lofar.sas.tmss.tmss import setup_and_check_tmss_django_database_connection_and_exit_on_error
...@@ -33,7 +34,7 @@ def populate_main(): ...@@ -33,7 +34,7 @@ def populate_main():
populate_connectors() populate_connectors()
def populate_schemas(schema_dir: str=None, dbcreds_name: str=None): def populate_schemas(schema_dir: str=None, dbcreds_name: str=None, parallel: bool=True):
with TMSSsession.create_from_dbcreds_for_ldap(dbcreds_name=dbcreds_name) as client: with TMSSsession.create_from_dbcreds_for_ldap(dbcreds_name=dbcreds_name) as client:
if schema_dir is None: if schema_dir is None:
schema_dir = os.path.expandvars('$LOFARROOT/share/tmss/schemas') schema_dir = os.path.expandvars('$LOFARROOT/share/tmss/schemas')
...@@ -186,14 +187,14 @@ def populate_schemas(schema_dir: str=None, dbcreds_name: str=None): ...@@ -186,14 +187,14 @@ def populate_schemas(schema_dir: str=None, dbcreds_name: str=None):
# then, upload the remaining templates in parallel # then, upload the remaining templates in parallel
rest_templates = [template for template in schema_templates_dict.values()] rest_templates = [template for template in schema_templates_dict.values()]
with ThreadPoolExecutor() as executor: with ThreadPoolExecutor(max_workers=None if parallel else 1) as executor:
executor.map(upload_template, rest_templates) executor.map(upload_template, rest_templates)
# and finally, the strategy_templates # and finally, the strategy_templates
for strategy_templates in (reservation_strategy_templates, for strategy_templates in (reservation_strategy_templates,
observing_strategy_templates, observing_strategy_templates,
scheduling_set_strategy_templates): scheduling_set_strategy_templates):
with ThreadPoolExecutor() as executor: with ThreadPoolExecutor(max_workers=None if parallel else 1) as executor:
executor.map(upload_strategy_templates, strategy_templates) executor.map(upload_strategy_templates, strategy_templates)
if __name__=='__main__': if __name__=='__main__':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment