-
Notifications
You must be signed in to change notification settings - Fork 34
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
Immutable params #101
Immutable params #101
Conversation
…meters.json file which will be edited
…rameters.json, rather than override the default values for an experiment
… within the bcipy code base
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments to address. Let's get time with one of the clinical team members (Betts, Deirdre, or Dan) to review the GUI changes.
bcipy/helpers/load.py
Outdated
|
||
from tkinter.filedialog import askopenfilename, askdirectory | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
DEFAULT_PARAMETERS_PATH = 'bcipy/parameters/parameters.json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we should pull this from from bcipy.helpers.parameters
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point. I'll clean that up.
bcipy/helpers/load.py
Outdated
def cast_value(value): | ||
"""Cast Value. | ||
def copy_parameters(path: str = DEFAULT_PARAMETERS_PATH, | ||
destination: str = 'bcipy/parameters/') -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a constant or derived from DEFAULT_PARAMETERS_PATH
@@ -12,7 +13,7 @@ class TestSave(unittest.TestCase): | |||
def setUp(self): | |||
# set up the needed paths and initial data save structure | |||
|
|||
self.data_save_path = 'data/' | |||
self.data_save_path = tempfile.mkdtemp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
DEFAULT_PARAMETERS_PATH = 'bcipy/parameters/parameters.json' | ||
|
||
|
||
class Parameters(dict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me really happy. I like the parameters being a class that can handle itself.
bcipy/helpers/load.py
Outdated
except Exception: | ||
raise ValueError(f'Could not cast {actual_value} to {actual_type}') | ||
now = datetime.now() | ||
month = str(now.month).rjust(2, "0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's cleaner to use strftime
for filenames with datetimes. I use it in helpers/save
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll look at that.
bcipy/gui/params_form.py
Outdated
frame.Show() | ||
app.MainLoop() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
import argparse | ||
from bcipy.helpers.load import DEFAULT_PARAMETERS_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be okay loading from bcipy.helpers.parameters
bcipy/gui/params_form.py
Outdated
size=14) | ||
loading_box.Add(self.loaded_from) | ||
loading_box.AddSpacer(10) | ||
# loading_box.AddSpacer(5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to remove if commented out code isn't needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good catch.
bcipy/gui/mode/RSVPKeyboard.py
Outdated
@@ -45,8 +73,9 @@ def launch_bci_main(self, event: wx.Event) -> None: | |||
username = self.comboboxes[0].GetValue().replace(" ", "_") | |||
experiment_type = event.GetEventObject().GetId() | |||
mode = 'RSVP' | |||
cmd = 'python bci_main.py -m {} -t {} -u {}'.format( | |||
mode, experiment_type, username) | |||
# TODO: add -p flag and use configured parameter_location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like you're doing that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yep. I'll remove this.
bcipy/gui/mode/RSVPKeyboard.py
Outdated
import itertools | ||
import os | ||
import subprocess | ||
|
||
import wx | ||
|
||
from bcipy.gui.gui_main import BCIGui | ||
from bcipy.helpers.load import load_json_parameters | ||
from bcipy.helpers.load import load_json_parameters, copy_parameters | ||
from bcipy.helpers.load import DEFAULT_PARAMETERS_PATH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd take this from helpers/parameters
or keep it on the same line
Overview
In the current workflow, any edits to the configuration for a session overwrite the default parameters. This makes it problematic to upgrade BciPy since this file often gets updated with new configuration options. This same file is used for both defining which parameters are available and their default values, as well as the configuration used for the current session.
This PR separates out these two concepts so that the default parameters.json file never gets overridden when configuration a session. The workflow has been modified so that users in the RSVPKeyboard GUI interface can select an existing parameters file. If they attempt to edit the configuration without first selecting experiment parameters, a new parameters file is created by copying the default params.
Ticket
https://www.pivotaltracker.com/story/show/175193758
Contributions
Test