Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions core/Experiment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
import logging
import time
from dataclasses import dataclass, field

Expand Down Expand Up @@ -183,8 +184,8 @@ def log_conditions(self, conditions, condition_tables=['Condition'], schema='exp
for ctable in condition_tables: # insert dependant condition tables
core = [field for field in self.logger.get_table_keys(schema, ctable, key_type='primary') if field != hsh]
fields = [field for field in self.logger.get_table_keys(schema, ctable)]
if not np.all([np.any(np.array(k) == list(cond.keys())) for k in fields]):
if self.logger.manual_run: print('skipping ', ctable)
if not all(k in cond for k in fields):
logging.warning("skipping table: %s, because of missing attributes: %s", ctable, [k for k in fields if k not in cond])
continue # only insert complete tuples
if core and hasattr(cond[core[0]], '__iter__'):
for idx, pcond in enumerate(cond[core[0]]):
Expand Down Expand Up @@ -240,11 +241,11 @@ def _get_new_cond(self):
if perf >= self.curr_cond['stair_up']:
self.cur_block = self.curr_cond['next_up']
self.cur_block_sz = 0
self.logger.update_setup_info({'difficulty': self.cur_block})
self.logger.update_setup_info({'difficulty': self.cur_block, 'block': False})
elif perf < self.curr_cond['stair_down']:
self.cur_block = self.curr_cond['next_down']
self.cur_block_sz = 0
self.logger.update_setup_info({'difficulty': self.cur_block})
self.logger.update_setup_info({'difficulty': self.cur_block, 'block': False})
if self.curr_cond['antibias']:
anti_bias = self._anti_bias(choice_h, self.un_choices[self.un_blocks == self.cur_block])
condition_idx = np.logical_and(self.choices == anti_bias, self.blocks == self.cur_block)
Expand Down
25 changes: 12 additions & 13 deletions core/Logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,22 +779,22 @@ def check_connection(self, host="8.8.8.8", port=53, timeout=0.1):
except socket.error:
return False

def update_setup_info(self, info: Dict[str, Any], key: Optional[Dict[str, Any]] = None):
def update_setup_info(self, info: Dict[str, Any], key: Optional[Dict[str, Any]] = None, block: bool = True):
"""
This method updates the setup information in Control table with the provided info and key.
Updates the setup information in the Control table with the provided info and key.

It first fetches the existing setup information from the experiment's Control table,
then updates it with the provided info. If 'status' is in the provided info, it blocks
and validates the update operation.
This method fetches the existing setup information from the experiment's Control table,
updates it with the provided info. If 'status' is included in the info, it sets the update status and
logs the caller's information.

Args:
info (dict): The information to update the setup with.
key (dict, optional): Additional keys to fetch the setup information with.
Defaults to an empty dict.
info (dict): The information to update the setup with. This should include any
relevant fields, such as 'status' and 'notes'.
key (dict, optional): Additional keys to filter the setup information. If None,
defaults to an empty dictionary.

Side Effects:
Updates the setup_info attribute with the new setup information.
Updates the setup_status attribute with the new status.
Raises:
Exception: If an exception has occurred in threads running in logger.
"""
if self.thread_exception:
self.thread_exception = None
Expand All @@ -805,8 +805,7 @@ def update_setup_info(self, info: Dict[str, Any], key: Optional[Dict[str, Any]]
if not public_conn.is_connected:
set_connection()

block = True if "status" in info else False
if block:
if "status" in info:
self.update_status.set()
caller = inspect.stack()[1]
caller_info = (f"Function called by {caller.function} "
Expand Down