Skip to content

Commit

Permalink
implement uuid in breeder
Browse files Browse the repository at this point in the history
  • Loading branch information
cherusk committed Nov 29, 2023
1 parent 21306ac commit 7ebb005
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions api/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
8 changes: 4 additions & 4 deletions breeder/linux_network_stack/objective.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand All @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion breeder/linux_network_stack/optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions breeder/linux_network_stack/root_dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 7ebb005

Please sign in to comment.