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

[MRG] Set legacy mode to false by default #619

Merged
merged 16 commits into from Mar 20, 2023

Conversation

ntolley
Copy link
Contributor

@ntolley ntolley commented Mar 13, 2023

closes #526

Changes all network models to use legacy_mode=False by default. Some minor changes in tests/examples were necessary but overall a pretty small change.

@ntolley
Copy link
Contributor Author

ntolley commented Mar 13, 2023

Unfortunately #614 didn't solve all our problems since the GUI has it's own code to loop over drives and add them. I've added the same logic to skip over these drives.

Not really sure what the best course of action is. @chenghuzi @jasmainak it seems like this will be necessary for loading old param files? Unless we enforce that you need to delete drive elements that contain invalid values.

@jasmainak
Copy link
Collaborator

sounds like the logic of legacy_mode that you implemented here should actually go inside _extract_drive_specs_from_hnn_params ? So it will return only the non-legacy drives?

@chenghuzi
Copy link
Collaborator

sounds like the logic of legacy_mode that you implemented here should actually go inside _extract_drive_specs_from_hnn_params ? So it will return only the non-legacy drives?

Could we have a more structured way of creating networks?

@rythorpe
Copy link
Contributor

What do you propose? At some point we need to cut out all the param file bloat (e.g., consolidate params.py and params_default.py), but the work just hasn't been done yet primarily because of our dependence on legacy_mode.

@@ -69,7 +69,6 @@ def test_gui_upload_params():
assert gui.drive_widgets[-1]['tstop'].value == 250.
gui._simulate_upload_drives(file1_url)
assert gui.connectivity_widgets[0][0].children[1].value == 0.01
assert gui.drive_widgets[-1]['tstop'].value == 0.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test does not apply anymore, the poisson drive (that is not used, hence tstop=0) is no longer added when legacy_mode=False

@ntolley ntolley changed the title WIP: Set legacy mode to false by default [MRG] Set legacy mode to false by default Mar 15, 2023
@ntolley
Copy link
Contributor Author

ntolley commented Mar 15, 2023

Ok I've moved all of the logic into _extract_drive_specs_from_hnn_params so hopefully that's the last of it!

hnn_core/params.py Outdated Show resolved Hide resolved
@@ -353,6 +355,12 @@ def __init__(self, params, add_drives_from_params=False, legacy_mode=True):
# XXX this can be removed once tests are made independent of HNN GUI
# creates nc_dict-entries for ALL cell types
self._legacy_mode = legacy_mode
if self._legacy_mode:
warnings.warn(
'Legacy mode is used solely to maintain compatibility with'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jasmainak what do you think of this? I'm ok with being annoying if you are 😉

Copy link
Collaborator

Choose a reason for hiding this comment

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

okay for me ! what happens during optimization though? Hope the warning is emitted only once?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good point - I'm assuming this will get printed anytime Network.copy() is called?

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, we could place this warning in jones_2009_model() since all the other template models call that function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My reasoning was they all have legacy mode as well as an option

@ntolley ntolley changed the title [MRG] Set legacy mode to false by default WIP: Set legacy mode to false by default Mar 15, 2023
@ntolley
Copy link
Contributor Author

ntolley commented Mar 15, 2023

Just remembered I need to double check how badly the beta example is impacted by this before this PR is set to merge (it's fairly sensitive to the random seed)

@ntolley ntolley changed the title WIP: Set legacy mode to false by default [MRG] Set legacy mode to false by default Mar 16, 2023


def test_external_drive_times():
"""Test the different external drives."""

params = Params()
params_fname = op.join(hnn_core_root, 'param', 'gamma_L5weak_L2weak.json')
Copy link
Contributor Author

@ntolley ntolley Mar 16, 2023

Choose a reason for hiding this comment

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

The test below assumes the existence of a poisson drive, which only gets added if legacy_mode=True for default.json

Copy link
Contributor

Choose a reason for hiding this comment

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

You might be able to get away with removing this read_params() step along with _extract_drive_specs_from_hnn_params by defining the poisson drive dynamics on L38 explicitly. I think this would be a cleaner unit test that circumvents the black magic contained in _extract_drive_specs_from_hnn_params.

@ntolley
Copy link
Contributor Author

ntolley commented Mar 16, 2023

Just checked the beta example locally and it isn't impacted! I'll keep an eye on lingering CI's but I can see the legacy mode cord being cut very soon 😄

hnn_core/network.py Outdated Show resolved Hide resolved
@rythorpe
Copy link
Contributor

Also, looks like something is now off with the seed values that causes test_parallel_backend to fail. I'm guess that a negative seed value gets read in from the .param file which then doesn't get the proper gid-boost that it used to from the ghost poisson drives?

@jasmainak
Copy link
Collaborator

This is huge @ntolley !! Don't forget to document in whats_new.rst !!

Co-authored-by: Ryan Thorpe <ryvthorpe@gmail.com>
@rythorpe
Copy link
Contributor

Do you want help with this @ntolley in order to be ready for tomorrow?

@ntolley
Copy link
Contributor Author

ntolley commented Mar 19, 2023

If you have the time to check out the seed problem that'd be great! I'm literally troubleshooting my MPI build right now

@jasmainak
Copy link
Collaborator

I updated the PR description to close #526 !

Comment on lines +223 to +224
if legacy_mode:
drive['event_seed'] -= 18
Copy link
Contributor

Choose a reason for hiding this comment

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

This was one of the culprits causing test_parallel_backend.py to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great find!!

Comment on lines +96 to +99
legacy_mode = False
# Legacy mode necessary for exact dipole comparison test
net = jones_2009_model(params, add_drives_from_params=True,
legacy_mode=legacy_mode)
Copy link
Contributor

Choose a reason for hiding this comment

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

The other culprit was here. When test_parallel_backend.test_mpi_failure() was called, it didn't expect to encounter the new legacy mode deprecation warning. The easiest way around this was to just set legacy_mode=False when running the reduced model simulation.

@codecov-commenter
Copy link

codecov-commenter commented Mar 20, 2023

Codecov Report

Merging #619 (0557bcc) into master (d5d1a03) will decrease coverage by 0.15%.
The diff coverage is 100.00%.

❗ Current head 0557bcc differs from pull request most recent head 07f6574. Consider uploading reports for the commit 07f6574 to get more accurate results

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #619      +/-   ##
==========================================
- Coverage   92.19%   92.04%   -0.15%     
==========================================
  Files          22       22              
  Lines        4229     4238       +9     
==========================================
+ Hits         3899     3901       +2     
- Misses        330      337       +7     
Impacted Files Coverage Δ
hnn_core/drives.py 98.54% <ø> (+0.66%) ⬆️
hnn_core/gui/gui.py 95.02% <ø> (-1.43%) ⬇️
hnn_core/network.py 93.39% <100.00%> (+0.04%) ⬆️
hnn_core/network_models.py 100.00% <100.00%> (ø)
hnn_core/params.py 91.89% <100.00%> (+0.25%) ⬆️
hnn_core/viz.py 89.23% <100.00%> (+0.04%) ⬆️

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@jasmainak jasmainak enabled auto-merge (rebase) March 20, 2023 14:52
@jasmainak jasmainak merged commit 9bc2230 into jonescompneurolab:master Mar 20, 2023
7 checks passed
@jasmainak
Copy link
Collaborator

Thanks @ntolley @rythorpe ! 🥳

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.

make legacy_mode=False in the GUI
5 participants