diff --git a/.github/workflows/publish_and_release.yml b/.github/workflows/publish_and_release.yml index 3cce64d3..e4c3f03b 100644 --- a/.github/workflows/publish_and_release.yml +++ b/.github/workflows/publish_and_release.yml @@ -6,6 +6,10 @@ on: name: Publish on PyPi and release on GitHub +env: + REGISTRY: ghcr.io + IMAGE_NAME: MannLabs/alphatims + jobs: Version_Bumped: runs-on: ubuntu-latest @@ -193,6 +197,49 @@ jobs: uses: pypa/gh-action-pypi-publish@master with: password: ${{ secrets.PYPI_API_TOKEN }} + + Create_Docker_Release: + # Adapted from wfondrie/mokapot's docker actions + runs-on: ubuntu-latest + needs: [Create_Linux_Release] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Build Wheel + run: | + python setup.py bdist_wheel + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to the GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Push the Docker image to the GHCR + uses: docker/build-push-action@v3 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + Test_PyPi_Release: name: Test_PyPi_version_on_${{ matrix.os }} runs-on: ${{ matrix.os }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..bd6723bc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ + +# FROM python:3.9-slim +FROM --platform=linux/amd64 python:3.9-bullseye + +RUN apt-get update && apt-get install -y build-essential gcc python3-dev + +RUN adduser worker +USER worker +WORKDIR /home/worker + +COPY --chown=worker:worker dist/*.whl /home/worker + +# RUN python3 -m pip install ".[plotting-stable]" # Image is 1.6gb with plotting +# The size is reduced to 847 mb without it. +RUN python3 -m pip install --disable-pip-version-check --no-cache-dir --user /home/worker/*.whl +RUN ls /home/worker/.local/lib/python3.9/site-packages/alphatims/ext/timsdata.so +RUN chmod 777 /home/worker/.local/lib/python3.9/site-packages/alphatims/ext/timsdata.so + +RUN python3 -m pip cache purge +ENV PATH="/home/worker/.local/bin:${PATH}" + +ENTRYPOINT [ "alphatims" ] diff --git a/README.md b/README.md index 35039bd2..d39df1e5 100755 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ There are three different types of installation possible: * [**One-click GUI installer:**](#one-click-gui) Choose this installation if you only want the GUI and/or keep things as simple as possible. * [**Pip installer:**](#pip) Choose this installation if you want to use AlphaTims as a Python package in an existing Python 3.8 environment (e.g. a Jupyter notebook). If needed, the GUI and CLI can be installed with pip as well. * [**Developer installer:**](#developer) Choose this installation if you are familiar with CLI tools, [conda](https://docs.conda.io/en/latest/) and Python. This installation allows access to all available features of AlphaTims and even allows to modify its source code directly. Generally, the developer version of AlphaTims outperforms the precompiled versions which makes this the installation of choice for high-throughput experiments. +* [**Docker:**](#docker) Use this installation if you want to use a container based workflow. This is usefull to preserve a clean environment or when running multiple tools that might have conflicting dependencies. ***IMPORTANT: While AlphaTims is mostly platform independent, some calibration functions require [Bruker libraries](alphatims/ext) which are only available on Windows and Linux.*** @@ -179,6 +180,14 @@ The following steps are optional, but make working with AlphaTims slightly more When `zsh` is the default terminal instead of `bash`, replace `~/.bashrc` with `~/.zshrc`. On Windows, the command `where alphatims` can be used to find the location of the binary executable. This path can then be (permanently) added to Windows' path variable. * When using Jupyter notebooks and multiple conda environments direcly from the terminal, it is recommended to `conda install nb_conda_kernels` in the conda base environment. Hereafter, running a `jupyter notebook` from the conda base environment should have a `python [conda env: alphatims]` kernel available, in addition to all other conda kernels in which the command `conda install ipykernel` was run. +### Docker + +(WIP) + +```shell +docker pull ghcr://MannLabs/alphatims:latest +``` + ### Installation issues See the general [troubleshooting](#troubleshooting) section. diff --git a/alphatims/utils.py b/alphatims/utils.py index 1b2e5314..34e01460 100755 --- a/alphatims/utils.py +++ b/alphatims/utils.py @@ -164,8 +164,10 @@ def show_platform_info() -> None: ) # check if architecture is arm64 as psutil.cpu_freq() is not yet supported on apple silicon - if platform.machine() != 'arm64': + try: logging.info(f"cpu frequency - {psutil.cpu_freq().current:.2f} Mhz") + except AttributeError: + logging.info("Unable to log cpu frequency") logging.info( f"ram - " f"{psutil.virtual_memory().available/1024**3:.1f}/"