-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cache manual entries to blech_exp_info #300
Comments
To address the issue of caching manual entries in the
Here is a concrete example of how these changes can be implemented: Step 1: Define Cache File PathAdd a variable to define the path to the cache file. cache_file_path = os.path.join(dir_path, 'manual_entries_cache.json') Step 2: Load CacheLoad the cache at the beginning of the script. if os.path.exists(cache_file_path):
with open(cache_file_path, 'r') as cache_file:
cache = json.load(cache_file)
else:
cache = {} Step 3: Update Manual Entry SectionsModify sections where manual entries are made to check the cache first. For example, in the section where taste dig-ins are entered: # Check cache for taste dig-ins
if 'taste_dig_ins' in cache:
taste_dig_inds = cache['taste_dig_ins']
else:
if not args.programmatic:
taste_dig_in_str, continue_bool = entry_checker(
msg=' INDEX of Taste dig_ins used (IN ORDER, anything separated) :: ',
check_func=count_check,
fail_response='Please enter integers only')
if continue_bool:
nums = re.findall('[0-9]+', taste_dig_in_str)
taste_dig_inds = [int(x) for x in nums]
# Update cache
cache['taste_dig_ins'] = taste_dig_inds
with open(cache_file_path, 'w') as cache_file:
json.dump(cache, cache_file)
else:
exit()
else:
if args.taste_digins:
taste_dig_inds = parse_csv(args.taste_digins, int)
else:
raise ValueError('Taste dig-ins not provided, use --taste-digins') Step 4: Repeat for Other Manual EntriesRepeat the above pattern for other manual entries like tastes, concentrations, palatability rankings, laser parameters, etc. By implementing these changes, manual entries can be efficiently cached, reducing the need for repeated manual input. This response was automatically generated by blech_bot |
Store cache in blech_clust/cache_and_logs...rather than the data_dir |
To address the feedback regarding storing the cache in Step 1: Define Cache Directory PathFirst, ensure that the cache directory exists and define the path to the cache file within this directory. # Define the cache directory and ensure it exists
cache_dir = os.path.join('blech_clust', 'cache_and_logs')
os.makedirs(cache_dir, exist_ok=True)
# Define the cache file path
cache_file_path = os.path.join(cache_dir, 'manual_entries_cache.json') Step 2: Update Cache Loading and SavingEnsure that the cache is loaded from and saved to the new cache file path. Load Cacheif os.path.exists(cache_file_path):
with open(cache_file_path, 'r') as cache_file:
cache = json.load(cache_file)
else:
cache = {} Save CacheWhen updating the cache, save it to the new location: # Update cache
cache['taste_dig_ins'] = taste_dig_inds
with open(cache_file_path, 'w') as cache_file:
json.dump(cache, cache_file) Step 3: Apply Changes to Other Manual EntriesRepeat the pattern of checking and updating the cache for other manual entries like tastes, concentrations, palatability rankings, laser parameters, etc., using the new cache file path. By implementing these changes, the cache will be stored in the specified This response was automatically generated by blech_bot |
No description provided.
The text was updated successfully, but these errors were encountered: