Skip to content
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

Simulator CLI/GUI #368

Merged
merged 18 commits into from
Dec 11, 2024
Merged

Simulator CLI/GUI #368

merged 18 commits into from
Dec 11, 2024

Conversation

lawhead
Copy link
Collaborator

@lawhead lawhead commented Nov 26, 2024

Overview

Created a command line interface and GUI to assist with configuring parameters for a simulation.

Ticket

https://www.pivotaltracker.com/story/show/188497024

Contributions

  • Added an interactive mode to the existing command line interface. bcipy-sim -i.
  • Added a GUI to run the simulator: bcipy-sim-gui
  • Both modes produce similar results but the GUI has better support for selecting data directories from more loosely structured data folders.
  • Added an argument to customize the output folder of the simulation.
  • Simulator bug fixes

Test

  • Ran all unit tests
  • Ran the simulator CLI and GUI code to confirm output as expected.

@lawhead lawhead requested a review from tab-cmd November 26, 2024 00:45
Copy link
Contributor

@tab-cmd tab-cmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I haven't pulled it locally to try the new GUI yet, but will soon. We should demo with Dan after the next visit to get some feedback.

@@ -0,0 +1,65 @@
"""Update parameters files to latest."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What versions of BciPy would this support?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works for all versions.

setup.py Outdated
@@ -110,6 +110,7 @@ def run(self):
'bcipy = bcipy.main:bcipy_main',
'bcipy-erp-viz = bcipy.helpers.visualization:erp',
'bcipy-sim = bcipy.simulator:main',
'bcipy-sim-gui = bcipy.simulator.ui.gui:main',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be a flag on bcipy-sim? I was considering collapsing some of these scripts in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored to remove the setup script and include a command line flag instead.

return True


class ChooseFileInput(QWidget):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have similar code in the GUI module for getting files and directories. Could we leverage that here? We will be collapsing some of the GUI code (and likely passing around a single QApplication Instance) to package in the future, which is why I ask.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These widgets are a bit different in that they represent just the selection input and not the input, label, checkbox, and separator, all of which would affect the layout. These also have hooks for a change action, which is important for this form, but not the parameters GUI.

I do think our existing widgets could be updated to use these components as the underlying input, which would eliminate the duplicate code between the two. That would be a good refinement and when we do that work these could move to a common location.

command = panel.cli_output()
app.quit()
if command:
print(command, file=sys.stdout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the logger?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this starts executing a subprocess immediately in the console it's confusing to the user if this doesn't print to stdout. Also, this gives users the opportunity to run straight from the command line once the configuration is set, which can be faster than the GUI if you're doing this multiple times with only small variation.

@@ -133,7 +133,7 @@ def compute_device_evidence(
# This assumes that sampling is independent. Changes to the sampler API are needed if
# we need to provide the trial context of the last sample.
sampled_data = sampler.sample_data(current_state)
evidence = model.compute_class_probabilities(
evidence = model.compute_likelihood_ratio(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

"Override. Another checkbox is needed for editable"
if value is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update type to show it can be more than bool

@tab-cmd
Copy link
Contributor

tab-cmd commented Nov 26, 2024

I think this can go to the base branch 2.0 unless you were hoping to release it with the patch.

@lawhead lawhead changed the base branch from 2.0.1rc4 to 2.0.0 December 3, 2024 01:15
@lawhead lawhead changed the base branch from 2.0.0 to 2.0.1rc4 December 3, 2024 01:25
@lawhead lawhead changed the base branch from 2.0.1rc4 to 2.0.0 December 10, 2024 00:58
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for b256aed1 24.05% (target: 70.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (b256aed) Report Missing Report Missing Report Missing
Head commit (34b7511) 9071 6114 67.40%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#368) 582 140 24.05%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@lawhead lawhead merged commit dde7b50 into 2.0.0 Dec 11, 2024
0 of 10 checks passed
@lawhead lawhead deleted the sim-cli branch December 11, 2024 00:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants