Conversation
Fix search and replace typo
Fix search and replace typo
Fix import
zhuowenzhao
approved these changes
Jul 16, 2024
zhuowenzhao
reviewed
Jul 16, 2024
copick_live/utils/copick_dataset.py
Outdated
| ) | ||
|
|
||
| copick_dataset = CopickDataset( | ||
| copick_config_path=COPICK_TEMPLATE_PATH, |
Collaborator
There was a problem hiding this comment.
line 291 should be copick_config_path=COPICKLIVE_CONFIG_PATH,
copick_live/utils/copick_dataset.py
Outdated
| copick_dataset = None | ||
|
|
||
|
|
||
| def get_copick_dataset(config_path=None): |
Collaborator
There was a problem hiding this comment.
Found another bug: the counter_checkpoint_file_path is not passed correctly. Can we define another function that return this path, similar to returning local_dataset.
def get_local_dataset(config_path=None):
global local_dataset
if config_path or not local_dataset:
config = configparser.ConfigParser()
if config_path:
config_path = os.path.abspath(config_path)
else:
config_path = os.path.join(os.getcwd(), "config.ini")
if os.path.exists(config_path):
config.read(config_path)
else:
raise FileNotFoundError(f"Config file not found at {config_path}")
LOCAL_FILE_PATH = config.get("local_picks", "PICK_FILE_PATH", fallback=None)
if LOCAL_FILE_PATH:
LOCAL_FILE_PATH = os.path.join(LOCAL_FILE_PATH, "ExperimentRuns/")
COPICK_TEMPLATE_PATH = config.get("copick_template", "COPICK_TEMPLATE_PATH", fallback=None)
if not LOCAL_FILE_PATH or not COPICK_TEMPLATE_PATH:
raise ValueError("Config paths for LocalDataset are not provided and not found in the config file.")
local_dataset = LocalDataset(local_file_path=LOCAL_FILE_PATH, config_path=COPICK_TEMPLATE_PATH)
return local_dataset
def get_counter_file_path(config_path=None):
global COUNTER_FILE_PATH
if config_path or not COUNTER_FILE_PATH:
config = configparser.ConfigParser()
if config_path:
config_path = os.path.abspath(config_path)
else:
config_path = os.path.join(os.getcwd(), "config.ini")
if os.path.exists(config_path):
config.read(config_path)
else:
raise FileNotFoundError(f"Config file not found at {config_path}")
COUNTER_FILE_PATH = config.get("counter_checkpoint", "COUNTER_FILE_PATH", fallback=None)
if not COUNTER_FILE_PATH:
raise ValueError("Config path for COUNTER_FILE_PATH is not provided and not found in the config file.")
return COUNTER_FILE_PATH
copick_live/callbacks/update_res.py
Outdated
| ) | ||
| from utils.local_dataset import ( | ||
| local_dataset, | ||
| from copick_live.utils.local_dataset import ( |
Collaborator
There was a problem hiding this comment.
from copick_live.utils.local_dataset import (
get_local_dataset,
get_counter_file_path,
dirs,
dir2id,
)
| return dict(content=json.dumps(local_dataset.config_file, indent=4), filename=filename) | ||
| get_local_dataset().config_file["user_id"] = input_value | ||
| return dict(content=json.dumps(get_local_dataset().config_file, indent=4), filename=filename) | ||
|
|
Collaborator
There was a problem hiding this comment.
Replace download_txt() callback function to
@callback(
Output("download-txt", "data"),
Input("btn-download-txt", "n_clicks"),
#State("username", "value"),
prevent_initial_call=True,
)
def download_txt(n_clicks):
counter_checkpoint = get_counter_file_path()
if counter_checkpoint:
with open(counter_checkpoint) as f:
counter = json.load(f)
if counter['repeat'] == 2:
counter['start'] += counter['tasks_per_person']
counter['repeat'] = 0
counter['repeat'] += 1
task_contents = '\n'.join(dirs[counter['start']:counter['start']+counter['tasks_per_person']])
print(task_contents)
task_filename = 'task_recommendation.txt'
with open(counter_checkpoint, 'w') as f:
f.write(json.dumps(counter, indent=4))
return dict(content=task_contents, filename=task_filename)
Collaborator
Author
|
the comments have been addressed, but this isn't ready to merge due to the project explorer being a wip. i made heavy modifications to how configs work, and i have also updated the code to use copick's api more explicitly (e.g. removing directory traversals in favor of using copick to traverse runs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@zhuowenzhao this is my current refactor. I think it is pretty close to done, but I'm running some tests now.