-
Notifications
You must be signed in to change notification settings - Fork 143
Add MacOS build packaging tool #734
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
Draft
OtabekRintaro
wants to merge
8
commits into
Deep-MI:dev
Choose a base branch
from
OtabekRintaro:feature/release-packaging
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f73e360
Add package installer tool for macos
OtabekRintaro 705e27d
Move docker and singularity into tools
OtabekRintaro 051c9ff
Create workflow for MacOS package deployment
OtabekRintaro 9a34ec1
Apply suggestions from code review
dkuegler 5d43d92
Reformat scripts and fix broken paths
OtabekRintaro 450846f
Upload assets instead of artifacts in deploy.yml
OtabekRintaro d06303d
Fix script imports style
OtabekRintaro 3b74988
Add config file for tools
OtabekRintaro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,55 +1,88 @@ | ||
| name: MAN deploy-docker | ||
|
|
||
| on: | ||
| # release: | ||
| # types: | ||
| # - published | ||
| release: | ||
| types: | ||
| - published | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| deploy-gpu: | ||
| runs-on: ubuntu-latest | ||
| deploy-mac: | ||
| runs-on: macos-14 | ||
| timeout-minutes: 120 | ||
|
|
||
| env: | ||
| RELEASE_ASSETS: true | ||
| strategy: | ||
| matrix: | ||
| arch: [intel, arm] | ||
| steps: | ||
| - name: Get repository name. | ||
| run: echo "FASTSURFER_DIR=$GITHUB_WORKSPACE" >> $GITHUB_ENV | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Login to Docker | ||
| uses: docker/login-action@v2 | ||
| - name: Set up python environment | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
| - name: Build Docker image GPU | ||
| run: python Docker/build.py --device cuda --tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} | ||
| - name: Add additional tags | ||
| python-version: '3.10' | ||
| - name: install dependencies | ||
| run: python -m pip install py2app pyyaml | ||
| - name: package app for ${{ matrix.arch }} | ||
| run: tools/macos_build/build_release_package.sh ${{ matrix.arch }} ${{ env.FASTSURFER_DIR }} | ||
| - name: Move assets. | ||
| if: env.RELEASE_ASSETS == 'true' | ||
| run: | | ||
| docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-latest | ||
| docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:latest | ||
| - name: Push Docker image GPU | ||
| run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} | ||
| deploy-cpu: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 120 | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
| mkdir assets | ||
| mv tools/macos_build/installer/* assets/ | ||
| - name: Upload release assets. | ||
| uses: softprops/action-gh-release@v2 | ||
| if: env.RELEASE_ASSETS == 'true' | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Login to Docker | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v2 | ||
| - name: Build Docker image CPU | ||
| run: python Docker/build.py --device cpu --tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }} | ||
| - name: Add additional tags | ||
| run: | | ||
| docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-latest | ||
| - name: Push Docker image CPU | ||
| run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }} | ||
|
|
||
| files: ${{ env.FASTSURFER_DIR }}/assets/* | ||
| # deploy-gpu: | ||
| # runs-on: ubuntu-latest | ||
| # timeout-minutes: 120 | ||
| # steps: | ||
| # - name: Checkout repository | ||
| # uses: actions/checkout@v3 | ||
| # with: | ||
| # fetch-depth: 0 | ||
| # - name: Login to Docker | ||
| # uses: docker/login-action@v2 | ||
| # with: | ||
| # username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| # password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| # - name: Set up Docker Buildx | ||
| # uses: docker/setup-buildx-action@v2 | ||
| # - name: Build Docker image GPU | ||
| # run: python Docker/build.py --device cuda --tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} | ||
| # - name: Add additional tags | ||
| # run: | | ||
| # docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-latest | ||
| # docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:latest | ||
| # - name: Push Docker image GPU | ||
| # run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:gpu-${{ github.event.release.tag_name }} | ||
| # deploy-cpu: | ||
| # runs-on: ubuntu-latest | ||
| # timeout-minutes: 120 | ||
| # steps: | ||
| # - name: Checkout repository | ||
| # uses: actions/checkout@v3 | ||
| # with: | ||
| # fetch-depth: 0 | ||
| # - name: Login to Docker | ||
| # uses: docker/login-action@v2 | ||
| # with: | ||
| # username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| # password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| # - name: Set up Docker Buildx | ||
| # uses: docker/setup-buildx-action@v2 | ||
| # - name: Build Docker image CPU | ||
| # run: python Docker/build.py --device cpu --tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }} | ||
| # - name: Add additional tags | ||
| # run: | | ||
| # docker tag ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }} ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-latest | ||
| # - name: Push Docker image CPU | ||
| # run: docker push --all-tags ${{ secrets.DOCKERHUB_USERNAME }}/fastsurfer:cpu-${{ github.event.release.tag_name }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| Running FastSurfer | ||
| ================== | ||
|
|
||
| If you want to run only segmentation (replace placeholders starting with "<" and ending with ">", see https://deep-mi.org/FastSurfer/stable): | ||
| `run_fastsurfer.sh --seg_only --sd <path/to/output/dir> --sid <subject_id> --t1 <path/to/subjects/t1/image>` | ||
| To full run fastsurfer: | ||
| `run_fastsurfer.sh --device mps --sd <path/to/output/dir> --sid <subject_id> --t1 <path/to/subjects/t1/image> --fs_license </path/to/freesurfer/license>` | ||
| Some files of **FreeSurfer** binaries require bypassing MacOS security, which is | ||
| significantly easier to do with the following command than manually and one by one. | ||
| ` xattr -dr com.apple.quarantine /Applications/freesurfer/*` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| FASTSURFER: | ||
| VERSION: '242' | ||
| PYTHON_VERSION: '3.10' | ||
|
|
||
| FREESURFER_LINK_LINUX: 'https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer-linux-ubuntu22_amd64-7.4.1.tar.gz' | ||
| FREESURFER_LINK_MACOS: 'https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.4.1/freesurfer-macOS-darwin_x86_64-7.4.1.tar.gz' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # Copyright 2024 Image Analysis Lab, German Center for Neurodegenerative Diseases (DZNE), Bonn | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import argparse | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| import yaml | ||
|
|
||
|
|
||
| def make_parser() -> argparse.ArgumentParser: | ||
| """ | ||
| Create a command line interface and return command line options. | ||
|
|
||
| Returns | ||
| ------- | ||
| options | ||
| Namespace object holding options. | ||
| """ | ||
| parser = argparse.ArgumentParser( | ||
| description="Tool for extracting values from configuration file", | ||
| ) | ||
| parser.add_argument( | ||
| "--file", "-f", | ||
| type=Path, | ||
| dest="file", | ||
| help="configuration file", | ||
| required=True, | ||
| ) | ||
| parser.add_argument( | ||
| "--key", "-k", | ||
| type=str, | ||
| dest="key", | ||
| help="key to lookup", | ||
| required=True, | ||
| ) | ||
| return parser | ||
|
|
||
|
|
||
| def extract_value(config_file: Path | str, key: str) -> str: | ||
| """ | ||
| Read configuration file and return the value for the given key. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| config_file : Path, str | ||
| Path to configuration file. | ||
| key : str | ||
| Key to lookup. | ||
|
|
||
| Returns | ||
| ------- | ||
| value | ||
| Value under the given key. | ||
| """ | ||
| with open(config_file) as config: | ||
| try: | ||
| conf = yaml.safe_load(config) | ||
| value = conf[key.split('.')[0]] | ||
| for k in key.split('.')[1:]: | ||
| value = value[k] | ||
| return value | ||
| except yaml.YAMLError as e: | ||
| print(e) | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = make_parser() | ||
| args = parser.parse_args() | ||
|
|
||
| print(extract_value(args.file,args.key)) | ||
| sys.exit(0) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also be renamed to something like
MACOS.md