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

fix arbor tests with latest arbor version #498

Merged
merged 11 commits into from
Aug 23, 2024
Merged

Conversation

AurelienJaquier
Copy link
Collaborator

@AurelienJaquier AurelienJaquier commented Aug 20, 2024

dropped support for python 3.8 because latest arbor does not support it and python 3.8 will reach end of life in one month.

@AurelienJaquier AurelienJaquier self-assigned this Aug 20, 2024
@codecov-commenter
Copy link

codecov-commenter commented Aug 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.37%. Comparing base (43d63a8) to head (d1758ba).
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #498   +/-   ##
=======================================
  Coverage   87.36%   87.37%           
=======================================
  Files          50       50           
  Lines        4346     4349    +3     
=======================================
+ Hits         3797     3800    +3     
  Misses        549      549           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@thorstenhater thorstenhater left a comment

Choose a reason for hiding this comment

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

I'll leave these as comments: most is as expected, but I have some comments here and there.

@@ -307,6 +307,8 @@ def load(morpho_filename, replace_axon):
morpho = arbor.load_component(morpho_filename).component
elif morpho_suffix == '.swc':
morpho = arbor.load_swc_arbor(morpho_filename)
# turn loaded_morphology into morphology type
morpho = arbor.morphology(morpho.segment_tree)

Choose a reason for hiding this comment

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

This should be easier by using

Suggested change
morpho = arbor.morphology(morpho.segment_tree)
morpho = morpho.morphology

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in latest commit

@@ -631,7 +636,7 @@ def instantiate_recordings(self, cell_model, use_labels=False):
"""Instantiate recordings"""

# Attach voltage probe sampling at 10 kHz (every 0.1 ms)
for i, rec in enumerate(self.recordings):
for _, rec in enumerate(self.recordings):

Choose a reason for hiding this comment

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

Why use enumerate just to drop the index we just added?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Keeping the index in the latest commit

@@ -648,7 +653,9 @@ def instantiate_recordings(self, cell_model, use_labels=False):

cell_model.probe('voltage',
arb_loc.ref if use_labels else arb_loc.loc,
frequency=10) # could be a parameter
"0", # tag: default is '0'

Choose a reason for hiding this comment

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

Better:

Suggested change
"0", # tag: default is '0'
f"probe-{i}",

and keep the index above. Sampling then needs to reference that tag.
Alternatively, we can label by the location-expression and assert that
those are unique.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in latest commit.

@@ -10,7 +10,7 @@
{%- endif %}
{%- else %}
{%- for param in params %}
(default ({{ param.name }} {{ param.value }}))
(default ({{ param.name }} {{ param.value }} (scalar 1.0)))

Choose a reason for hiding this comment

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

I won't check all of those in detail, but this is correct for a fixed value.
If the tests are green, I'd assume all are correct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The tests are green

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend to additionally check the major examples' notebooks qualitatively by inspection (not everything is run as part of the test suite).

Choose a reason for hiding this comment

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

As said before using Arbor to write these might be an easier option.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is there a function that can write these kind of files?

Choose a reason for hiding this comment

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

Yes, there's versions for full cable cells or just parts thereof.
https://docs.arbor-sim.org/en/latest/fileformat/cable_cell.html#parsable-arbor-components-and-meta-data
In Python, you'd construct a cable cell (or the parts you're interested in) and call arbor.write_component(thing, filename)
https://docs.arbor-sim.org/en/latest/python/cable_cell_format.html#reading-and-writing-arbor-components

Copy link
Contributor

Choose a reason for hiding this comment

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

That would basically mean to turn this template into code at the end of the ACC exporter by instantiating Arbor objects that are then serialized again. Could be an option - I guess it comes down to how much control you need over the export vs. learning the s-expression syntax. The original design of BluePyOpt was to make model exporting configurable (overridable by the user) through templates, hence I chose this option.

In my view, most of the complexity in the ACC exporter comes from converting BluePyOpt's frontend representation to one suitable for Arbor. That last step of dumping the decor is less complicated, but requires some understanding of the format.

I don't want to take any particular side, though. Would only suggest that if you plan to make major changes to the ACC exporter, maybe a good idea would be to do that in a separate PR.

Choose a reason for hiding this comment

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

Yes, I'd support splitting this. One straight port that can be verified and a lateral move to another scheme.

The original design of BluePyOpt was to make model exporting configurable (overridable by the user) through templates, hence I chose this option.

This is why I as an outsider should have an opinion here :D

@thorstenhater
Copy link

Picking one of the examples from the test suite

(arbor-component
  (meta-data (version "0.9-dev"))
  (decor
    (paint (region "soma") (membrane-capacitance 0.01 (scalar 1.0)))
    (paint (region "soma") (density (mechanism "default::hh" ("gnabar" 0.10299326453483033) ("gkbar" 0.027124836082684685))))))

should be produced by

import arbor as A

d = A.decor()
d.paint('"soma"', cm=0.01)
d.paint('"soma"', A.density('default:hh', gnabar=0.10299326453483033, gkbar=0.027124836082684685))

A.write_component(d, 'test.acc')

@AurelienJaquier
Copy link
Collaborator Author

Thanks for your help @lukasgd @thorstenhater , I think this PR is good to be merged.
For the ACC exporter PR, we will have to tackle it at a later date, because I have a bunch of other priorities right now and we are a little bit short on manpower.

@AurelienJaquier AurelienJaquier merged commit d46979b into master Aug 23, 2024
5 checks passed
@AurelienJaquier AurelienJaquier deleted the arbor-v0.10 branch August 23, 2024 15:09
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.

5 participants