Skip to content

Commit

Permalink
Fix h5py optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tjwsch committed Jun 18, 2024
1 parent 7999d6e commit c64517a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Install Micro Manager and uninstall pyprecice
working-directory: micro-manager
run: |
pip3 install --user .
pip3 install --user .[snapshot]
pip3 uninstall -y pyprecice
- name: Run micro_manager unit test
Expand All @@ -44,10 +44,6 @@ jobs:
working-directory: micro-manager/tests/unit
run: python3 -m unittest test_hdf5_functionality.py

- name: Install dependencies for snapshot computation
working-directory: micro-manager/tests/unit
run: pip3 install --user ".[snapshot]"

- name: Run snapshot_computation unit tests
working-directory: micro-manager/tests/unit
run: python3 -m unittest test_snapshot_computation.py
15 changes: 13 additions & 2 deletions micro_manager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@

from .config import Config
from .micro_manager import MicroManagerCoupling
from .snapshot.snapshot import MicroManagerSnapshot

try:
from .snapshot.snapshot import MicroManagerSnapshot

is_snapshot_possible = True
except ImportError:
is_snapshot_possible = False


def main():
Expand All @@ -24,7 +30,12 @@ def main():
if not args.snapshot:
manager = MicroManagerCoupling(config_file_path)
else:
manager = MicroManagerSnapshot(config_file_path)
if not is_snapshot_possible:
raise ImportError(
"The Micro Manager snapshot computation requires the h5py package."
)
else:
manager = MicroManagerSnapshot(config_file_path)

manager.initialize()

Expand Down
3 changes: 2 additions & 1 deletion micro_manager/snapshot/dataset.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from importlib import metadata
import os
from datetime import datetime

import numpy as np

try:
import h5py
except ImportError:
raise ImportError(
"The Micro Manager snapshot computation requires the h5py package to store snapshots."
"The Micro Manager snapshot computation requires the h5py package."
)


Expand Down
3 changes: 2 additions & 1 deletion micro_manager/snapshot/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import importlib
import os
import sys
import numpy as np
import time

import numpy as np

from micro_manager.micro_manager import MicroManager
from .dataset import ReadWriteHDF
from micro_manager.micro_simulation import create_simulation_class
Expand Down

0 comments on commit c64517a

Please sign in to comment.