diff --git a/api/controller.py b/api/controller.py index ac1763f5..59a33d06 100644 --- a/api/controller.py +++ b/api/controller.py @@ -194,6 +194,7 @@ def breeders_post(content): # noqa: E501 breeder_config = dict(content.get('breeder')) breeder_name = breeder_config.get('name') uuid = uuid.uuid4() + config.update(dict(uuid=uuid)) def create_breeder(api_client, content): diff --git a/breeder/linux_network_stack/objective.py b/breeder/linux_network_stack/objective.py index 37c6625a..47f1bb62 100644 --- a/breeder/linux_network_stack/objective.py +++ b/breeder/linux_network_stack/objective.py @@ -5,7 +5,7 @@ def objective(trial, identifier=None, archive_db_url=None, locking_db_url=None, - breeder_name=None): + breeder_id=None): ###--- definition coroutines ---### ### We have to keep to coroutines in the objective function, @@ -44,7 +44,7 @@ def objective(trial, logger.debug('fetching setting data') - breeder_table_name = f"{breeder_name}_{run}_{identifier}" + breeder_table_name = f"{breeder_id}_{run}_{identifier}" query = f"SELECT * FROM {breeder_table_name} WHERE {breeder_table_name}.setting_id = '{setting_id}';" archive_db_data = archive_db_engine.execute(query).fetchall() @@ -64,10 +64,10 @@ def objective(trial, # get lock to gate other objective runs locker = pals.Locker('network_breeder_effectuation', locking_db_url) - dlm_lock = locker.lock(f'{breeder_name}_{identifier}') + dlm_lock = locker.lock(f'{breeder_id}') if not dlm_lock.acquire(acquire_timeout=1200): - task_logger.debug("Could not aquire lock for {breeder_name}_{identifier}") + task_logger.debug("Could not aquire lock for {breeder_id}") asyncio.run(send_msg_via_nats(subject=f'effectuation_{identifier}', data_dict=settings_data)) diff --git a/breeder/linux_network_stack/optimization.py b/breeder/linux_network_stack/optimization.py index 27e19cd0..f7c1e183 100644 --- a/breeder/linux_network_stack/optimization.py +++ b/breeder/linux_network_stack/optimization.py @@ -24,7 +24,7 @@ def run_optimization(): locking_db_url=DLM_DB_CONNECTION, run=run, identifier=identifier, - breeder_name=config.get('name'), + breeder_id=config.get('uuid'), ) __directions = list() diff --git a/breeder/linux_network_stack/root_dag.py b/breeder/linux_network_stack/root_dag.py index e9314343..edbaa997 100644 --- a/breeder/linux_network_stack/root_dag.py +++ b/breeder/linux_network_stack/root_dag.py @@ -107,7 +107,7 @@ parallel_runs = config.get('run').get('parallel') targets = config.get('effectuation').get('targets') -dag_name = config.get('name') +dag_name = config.get('uuid') is_cooperative = config.get('cooperation').get('active') target_id = 0 @@ -137,13 +137,13 @@ def determine_config_shard(run_id=None, for target in targets: - identifier = hashlib.sha256(str.encode(target.get('address'))).hexdigest()[0:6] + hash_suffix = hashlib.sha256(str.encode(target.get('address'))).hexdigest()[0:6] for run_id in range(0, parallel_runs): dag_id = f'{dag_name}_{run_id}' if not is_cooperative: config = determine_config_shard() - globals()[f'{dag_id}_optimization_{identifier}'] = create_optimization_dag(f'{dag_id}_optimization_{identifier}', config, run_id, identifier) - globals()[f'{dag_id}_target_{identifier}'] = create_target_interaction_dag(f'{dag_id}_target_interaction_{identifier}', config, target, identifier) + globals()[f'{dag_id}_optimization_{hash_suffix}'] = create_optimization_dag(f'{dag_id}_optimization_{hash_suffix}', config, run_id, hash_suffix) + globals()[f'{dag_id}_target_{hash_suffix}'] = create_target_interaction_dag(f'{dag_id}_target_interaction_{hash_suffix}', config, target, hash_suffix) target_id += 1