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

Include M1 runners in CI and update install instructions accordingly #125

Merged
merged 2 commits into from
Feb 28, 2024

Conversation

niksirbi
Copy link
Member

@niksirbi niksirbi commented Feb 23, 2024

Description

What is this PR

  • Bug fix
  • Addition of a new feature
  • Other

Why is this PR needed?

References

closes #123

How has this PR been tested?

The real test are the CI checks in this PR.

Is this a breaking change?

No

Does this PR require an update to the documentation?

No

Checklist:

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

EDIT 2024-02-26

The CI tests were failing on M1 runners, because the hdf5 binaries could not be found (see discussion below). Therefore, this PR has been amended to also change movement's installation procedure, which should now be:

conda create -n movement-env -c conda-forge python=3.10 hdf5
conda activate movement-env
pip install movement

The above should work cross-platform.
I've renamed the PR from "Include CI tests on macOS 14 M1 runner" to "Include M1 runners in CI and update install instructions accordingly".

@niksirbi
Copy link
Member Author

@neuroinformatics-unit/behaviour I think our fears have been confirmed, installation specifically fails on macos-14 (M1) runners, seemingly due to the HDF5 hack we discussed in #91 and implemented in #104.

The relevant error:

× Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      /var/folders/1k/qq3pcbf12vb6vyblh81736p40000gn/T/H5close02d79slb.c:1:10: fatal error: 'H5public.h' file not found
      #include "H5public.h"
               ^~~~~~~~~~~~
      1 error generated.
      cpuinfo failed, assuming no CPU features: 'flags'
      * Using Python 3.10.11 (v3.10.11:7d4cc5aa85, Apr  4 [202](https://github.com/neuroinformatics-unit/movement/actions/runs/8021671030/job/21915041655?pr=125#step:3:215)3, 19:05:19) [Clang 13.0.0 (clang-1300.0.29.30)]
      * Found cython 3.0.8
      * USE_PKGCONFIG: True
      .. ERROR:: Could not find a local HDF5 installation.
         You may need to explicitly state where your local HDF5 headers and
         library can be found by setting the ``HDF5_DIR`` environment
         variable or by using the ``--hdf5`` command-line option.
      [end of output]

This doesn't occur on Linux, Windows and Intel MacOS (macos-latest aka macos-12) runners.

I'm considering to revert #104.

@willGraham01 if the same hack is also implemented for some BrainGlobe packages, we should also test on M1 runners there.

@willGraham01
Copy link
Contributor

willGraham01 commented Feb 26, 2024

This is a problem with M1 macs in general, not just GitHub runners. A brew-installed version of HDF5 goes into opt/homebrew/opt and not the usual header directory.

brew install hdf5
export HDF5_DIR=/opt/homebrew/opt/hdf5

will allow the HDF5 headers to be found by the C++ compiler.

(Also, not wanting to be too pedantic, but it looks like the source code is #include "H5public.h" rather than #include <H5public.h>, which means the compiler is searching for a local version of H5 - within the source location - rather than the system include directories. This shouldn't affect anything since if the compiler cannot locate the file locally, it should default back to the system directories, but worth double-checking what the intention is here. If HDF5 is being included as a submodule, then ignore me 😅 )

@niksirbi
Copy link
Member Author

This is a problem with M1 macs in general, not just GitHub runners. A brew-installed version of HDF5 goes into opt/homebrew/opt and not the usual header directory.

😞 so we can forget about a one-line installation. So we either instruct people to brew install hdf5 or we go back to the previous installation instructions with conda install pytables.

@willGraham01
Copy link
Contributor

willGraham01 commented Feb 26, 2024

conda install pytables

If we do go back to non-oneline, why not conda install hdf5 instead? I would need to double check the recipe, but I would assume that conda puts the headers in a sensible place, unlike brew.

(Recipe: https://github.com/conda-forge/hdf5-feedstock/blob/d2771a298d3d3efe279422aad7533cefbafae8c1/recipe/build.sh#L4 - looks like it will put the header files wherever the system library directory is, which should be the correct place)

@niksirbi
Copy link
Member Author

If we do go back to non-oneline, why not conda install hdf5 instead? I would need to double check the recipe, but I would assume that conda puts the headers in a sensible place, unlike brew

True, I might try that instead.

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@niksirbi
Copy link
Member Author

Alright, conda install -c conda-forge hdf5 definitely does the trick, and I think we'll go with that for now. Anyway, the goal is to release movement on conda-forge soonish.

@niksirbi niksirbi changed the title Include CI tests on macOS 14 M1 runner Include M1 runners in CI and update install instructions accordingly Feb 26, 2024
@niksirbi niksirbi marked this pull request as ready for review February 26, 2024 10:52
@niksirbi niksirbi requested a review from sfmig February 26, 2024 10:52
@niksirbi
Copy link
Member Author

@sfmig I've tagged you as reviewer because you've also encountered the hdf5 problem on your M2 Mac.

Copy link
Contributor

@sfmig sfmig left a comment

Choose a reason for hiding this comment

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

works for me! ✨

You may want to add a quick check after installation, to make sure everything works (like running Python and importing movement for example?).

@niksirbi niksirbi merged commit 4e8d967 into main Feb 28, 2024
24 checks passed
@niksirbi niksirbi deleted the test-on-m1 branch February 28, 2024 17:30
niksirbi added a commit to b-peri/movement that referenced this pull request Mar 11, 2024
niksirbi added a commit that referenced this pull request Mar 12, 2024
* Added `filtering.py` module, w/ draft `interp_pose()` & `filter_confidence()` fxns

* Fix logging for operations in place

* Renamed fxns to `interpolate_over_time()` and `filter_by_confidence`

* Cleaned up code + corrected docstrings

* Refactored `filtering.py` to movement base folder

* Improved logging logic, fixed diagnostic report, removed in-place

* Removed printing of diagnostic report

* Updated dependency from `xarray` to `xarray[accel]`

* Added testing for `filtering.py`

* Minor fixes and clean-up

* Reorganise Accessor (#122)

* Check for expected `dims` and `data_vars` in dataset

* Fix `missing_dim_dataset` fixture

* Rename `poses` accessor to `move`

* Rename `PoseAccessor` class to `MoveAccessor`

* Rename `poses_accessor.py` to `move_accessor.py`

* Move `move_accessor.py` to the top level

* Fix accessor docstring formatting

* Compute locomotion features (#106)

* Draft compute velocity

* Add test for displacement

* Fix confidence values in `valid_pose_dataset` fixture

* Refactor kinematics test and functions

* Vectorise kinematic functions

* Refactor repeated calls to compute magnitude + direction

* Displacement to return 0 instead of NaN

* Return x y components in kinematic functions

* Refactor kinematics tests

* Remove unnecessary instantiations

* Improve time diff calculation

* Prefix kinematics methods with `compute_`

* Add kinematic properties to `PosesAccessor`

* Update `test_property` docstring

* Refactor `_vector` methods and kinematics tests

* Update `expected_dataset` docstring

* Rename `poses` to `move` in `PosesAccessor`

* Refactor properties in `PosesAccessor`

* Remove vector util functions and tests

* Update `not_a_dataset` fixture description

* Validate dataset upon accessor property access

* Update `poses_accessor` test description

* Validate input data in kinematic functions

* Remove unused fixture

* Parametrise kinematics tests

* Set `compute_derivative` as internal function

* Update `kinematics.py` docstrings

* Add new modules to API docs

* Update `move_accessor` docstrings

* Rename `test_move_accessor` filename

* Include M1 runners in CI and update install instructions (#125)

* also test on macOS 14 M1 runner

* conda install hdf5

* Add dependabot config (#128)

* Bump actions/cache from 3 to 4 (#130)

Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](actions/cache@v3...v4)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#131)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.0 → v0.3.0](astral-sh/ruff-pre-commit@v0.2.0...v0.3.0)
- [github.com/psf/black: 24.1.1 → 24.2.0](psf/black@24.1.1...24.2.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Add codecov token to test_and_deploy.yml (#129)

* Add codecov token to test_and_deploy.yml

* use test action from main branch

* switch back to using v2 of the test action

* tweaked phrasing in docstrings

* added filtering functions to API index

* add note about default confidence threshold

* rename and reorganise filter_diagnostics as report_nan_values

* use xarray's copy method

* max_gaps is in seconds and also works at edges

* use xarray's built-in isnull method

* added sphinx-gallery example for filtering and interpolation

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Chang Huan Lo <[email protected]>
Co-authored-by: Niko Sirmpilatze <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

Also test on Apple silicon during CI
3 participants