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

Move OpenIJTIFF python to module/conda-package #647

Merged
merged 6 commits into from
Apr 24, 2024

Conversation

k-dominik
Copy link
Collaborator

@k-dominik k-dominik commented Apr 23, 2024

This will enable installing OpenIJTIFF as a module. I didn't change the name of the module (although it's not canonical, and the name doesn't work for a conda package). So no code changes needed in the notebooks.

Summary:

  • I ran black over it for some objective code style
  • Improved/fixed typing and docstrings (google python docstring style)
  • consistent behavior for downloading files among osses:
    • previously windows would sneakily hide OSErrors which happened when cleaning up the temporary directory while having the file open in tifffile. Disabled cleaning up on all osses now - linux and osx will likely clean up on reboot, and on windows (which wouldn't cleanup before anyways) users can trigger temp cleanup themselves.
  • Made it a python package
  • Added conda recipe
  • removed all sys.path modifications as those are not necessary anymore to use the functionality

I also felt an itch to remove the fetching of extra metadata (as it doesn't seem to be used in the tutorial and complicates typing. Also variable number of return values is not a good pattern. But left it for now.

CC: @bugraoezdemir @tischi

in preparation of creating a python package out of it.
* Ran black for a more objective code style
* Fixed some type annotations (mostly in order to understand the better
  understand the code
* Added more docstrings mostly in order to better understand the code
* Ensured google-style docstrings
Note: This changes the behavior a bit. Previous version was opening the
tiff file and immediately unlinking the file, such that it was deleted
once tifffile closed the handle. However, this was not supported on
windows, where a blank try except was employed to hide it and also
obscure what was really happening. Now the behavior on all osses is the
same and users can employ the os-specific way to clean up their temp
folder.
would prefer to remove the special handling of fetching extra metadata
as it's also not used in the tutorial.
Typing gets ugly with the different return types.
it's also not really good practice.
@tischi
Copy link
Collaborator

tischi commented Apr 23, 2024

@k-dominik thanks a lot for working on this!

Sorry, this may be a dump question, becuase I don't know enough about python: How would the students install the OpenIJTIFF python module?

@k-dominik
Copy link
Collaborator Author

Hi @tischi,

before being able to install the package has to be built first - there are several options.

  • For "development" installation (say you want to change/improve OpenIJTIFF, you could pip install --editable functions/python_modules/OpenIJTIFF from the repository root
  • for users of this tutorial, it would be good to (after merging) build and upload this package to some conda channel. (conda build functions/python_modules/OpenIJTIFF/conda-recipe and (with anaconda client installed) upload with something like (you can also configure conda build to do this automatically, we could have CI here to do it, many options) anaconda upload /Users/kutra/mambaforge/conda-bld/noarch/openijtiff-2024.4.0-py_0.tar.bz2
  • Then users can create the env as per our instructions, add the channel with -c and also add the openijtiff package as dependency.

@tischi
Copy link
Collaborator

tischi commented Apr 24, 2024

OK, thanks, then I will just merge such that we can go ahead.

@tischi tischi merged commit e2a8274 into master Apr 24, 2024
2 checks passed
@tischi tischi deleted the move-openij-python-to-module branch April 24, 2024 06:49
@bugraoezdemir
Copy link
Collaborator

I have built the package and uploaded it to our conda channel (euro-bioimaging). When I installed it to a fresh conda environment and briefly tested the open_ij_tiff function, it worked as expected. It would be good to test it also in the course environment to see if there is any conflict with the other packages. Here is the installation command:
conda install euro-bioimaging::openijtiff.

@bugraoezdemir
Copy link
Collaborator

If there is an environment.yml for the course environment, we could include the package in it.

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.

3 participants