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

Add an optional attribute to handle updates during atlas downloads #126

Merged
merged 2 commits into from
Jul 26, 2022

Conversation

yoda-vid
Copy link
Contributor

@yoda-vid yoda-vid commented Jul 12, 2022

Description

What is this PR

Atlas download progress is currently handled within a Rich progress indicator, but external libraries do not have access to these updates. This PR adds an optional attribute to BrainGlobeAtlas to reference a handler that is updated during atlas downloads. This handler can be given as a function that takes the currently competed and total required bytes to download the given atlas.

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

Provides access to track real-time atlas download updates by external apps. There may be better ways to provide this functionality...I'm all ears to alternatives.

What does this PR do?

Adds a hook called by bg-atlasapi during atlas downloads.

References

I am using this handler to update a progress bar in MagellanMapper when downloading atlases through BrainGlobe (see sanderslab/magellanmapper#75).

How has this PR been tested?

  • Tested downloading the "kim_mouse_50um" atlas in bg-atlasapi in an interactive Python 3.6 session, where the handler is ignored and download proceeds as normal
  • Tested in MagellanMapper PR 75, which passes a function that updates the progress bar during atlas downloads

Is this a breaking change?

No

Does this PR require an update to the documentation?

Updated the docstrings with the changes. Also added a type hint to the handler to specify its expected parameters.

Checklist:

  • The code has been tested locally
  • Tests have been added to cover all new functionality (unit & integration)
  • The documentation has been updated to reflect any changes
  • The code has been formatted with pre-commit

Atlas download progress is currently handled within a Rich progress indicator, but external libraries do not have access to these updates. Add an optional attribute to `BrainGlobeAtlas` to reference a handler that is updated during atlas downloads. This handler is a function that takes the currently competed and total required bytes to download the given atlas.
yoda-vid added a commit to sanderslab/magellanmapper that referenced this pull request Jul 12, 2022
Provide real-time updates by supplying a handler to BrainGlobe, which requires brainglobe/brainglobe-atlasapi#126. Format download sizes in human-readable units for the progress bar message.
- Remove whitespace on empty line
- Format line width, indentation, and closing parenthesis placement
@yoda-vid
Copy link
Contributor Author

yoda-vid commented Jul 14, 2022

Attempted to fix formatting errors from the lint action by running the black package. Also checked in pre-commit (used Python 3.7 as I ran into a SyntaxError: future feature annotations is not defined error in Python 3.6).

@adamltyson
Copy link
Member

Looks good to me @yoda-vid. Just because everything else depends on this package, I'll wait for @vigji or @FedeClaudi to approve before merging.

@yoda-vid
Copy link
Contributor Author

Sounds good, thanks @adamltyson! Open to any feedback to make this best fit with BrainGlobe's goals.

Copy link
Member

@vigji vigji left a comment

Choose a reason for hiding this comment

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

Sorry for taking so long! Good to go for me.

@adamltyson adamltyson merged commit cc98014 into brainglobe:master Jul 26, 2022
@adamltyson
Copy link
Member

Merged, thanks @yoda-vid!

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.

None yet

3 participants