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 functionality to specify temp directory location when creating memory mapped temp arrays #162

Open
wants to merge 16 commits into
base: development
Choose a base branch
from

Conversation

sophiamaedler
Copy link
Contributor

this allows you to also utilize memory mapped temp arrays in multithreaded processes by explicitly passing the directory name without needing to rely on the global TEMP_DIR_NAME variable still being accurate

…mory mapped temp arrays

this allows you to also utilize memory mapped temp arrays in multithreaded processes by explicitly passing the directory name without needing to rely on the global TEMP_DIR_NAME variable still being accurate
alphabase/io/tempmmap.py Outdated Show resolved Hide resolved
alphabase/io/tempmmap.py Outdated Show resolved Hide resolved
alphabase/io/tempmmap.py Outdated Show resolved Hide resolved
@jalew188
Copy link
Collaborator

jalew188 commented May 7, 2024

@sophiamaedler We now have quite restrict PR rules for alphaX packages. Please git pull before coding/pushing:)

@sophiamaedler
Copy link
Contributor Author

@sophiamaedler We now have quite restrict PR rules for alphaX packages. Please git pull before coding/pushing:)

@jalew188 Sure :) I had done a git pull before opening this PR, should I still do anything else next time?

- updated name to temp_dir_abs_path
- moved code to check if directory exists to seperate function
move code to check if file path for creating a new empty temp directory is valid to a seperate helper function and update variable name to be more understandable
@jalew188
Copy link
Collaborator

jalew188 commented May 8, 2024

@sophiamaedler We now have quite restrict PR rules for alphaX packages. Please git pull before coding/pushing:)

@jalew188 Sure :) I had done a git pull before opening this PR, should I still do anything else next time?

I think the only thing is to fix this error in this PR: https://github.com/MannLabs/alphabase/actions/runs/9000693343/job/24725402319?pr=162#step:4:246

@sophiamaedler
Copy link
Contributor Author

@sophiamaedler We now have quite restrict PR rules for alphaX packages. Please git pull before coding/pushing:)

@jalew188 Sure :) I had done a git pull before opening this PR, should I still do anything else next time?

I think the only thing is to fix this error in this PR: https://github.com/MannLabs/alphabase/actions/runs/9000693343/job/24725402319?pr=162#step:4:246

I installed the ruff linter and let it run over the code. I hope that should fix it and should avoid this problem for the future.

alphabase/io/tempmmap.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@jalew188 jalew188 left a comment

Choose a reason for hiding this comment

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

tempmmap was designed long time ago by Sander, we can refactor it if necessary in the near future.

The same for alphabase.io.hdf.py and so on.

in cases where no abs_path is provided this otherwise throws an error.
rename function to better reflect what the code does
name better reflects what the code does
@sophiamaedler
Copy link
Contributor Author

I also noticed that the global definition of TEMP_DIR_NAME was removed and added it back in. This otherwise throws errors in some rare cases.

@sophiamaedler
Copy link
Contributor Author

tempmmap was designed long time ago by Sander, we can refactor it if necessary in the near future.

The same for alphabase.io.hdf.py and so on.

In general I think there is a lot of potential here for additional use cases e.g. I have currently been playing around with Dask arrays and found a way to use a tempmmap compatible HDF5 in the backend of a memory mapped Dask array (see here : src/sparcstools/base/daskmmap.py) but I am not sure where the best place to include it would be and if alpha base is the correct location to add something like that. Might be worth a more in depth discussion at some point.

alphabase/io/tempmmap.py Outdated Show resolved Hide resolved
Copy link
Contributor

@mschwoer mschwoer left a comment

Choose a reason for hiding this comment

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

LGTM! thanks for hanging on ;-)

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

4 participants