diff --git a/SAS/TMSS/client/lib/populate.py b/SAS/TMSS/client/lib/populate.py index e63fee7091ad77667770c0ed76591c4a53050c03..387a47b8a202bba0f3338fa876bf69cd90d43735 100644 --- a/SAS/TMSS/client/lib/populate.py +++ b/SAS/TMSS/client/lib/populate.py @@ -23,7 +23,8 @@ def populate_main(): (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 from lofar.sas.tmss.tmss import setup_and_check_tmss_django_database_connection_and_exit_on_error @@ -33,7 +34,7 @@ def populate_main(): 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: if schema_dir is None: schema_dir = os.path.expandvars('$LOFARROOT/share/tmss/schemas') @@ -186,14 +187,14 @@ def populate_schemas(schema_dir: str=None, dbcreds_name: str=None): # then, upload the remaining templates in parallel 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) # and finally, the strategy_templates for strategy_templates in (reservation_strategy_templates, observing_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) if __name__=='__main__':