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

Add docker file #594

Closed
wants to merge 1 commit into from
Closed

Add docker file #594

wants to merge 1 commit into from

Conversation

abcsds
Copy link

@abcsds abcsds commented Sep 2, 2022

Hi,

This is related to #591. Back I talked with @hoechenberger about parallel distributed usage of the pipeline. He mentioned there were some attempts at dask, but we concluded it might be easier to just containerize the project and run it as docker swarm.

In #591 I suggested a dockerfile from the python image, with the config file and data are the only variables of the container.

@hoechenberger suggested:

  • Using the official installation of MNE:

    I changed the base image to miniconda then, to be able to install MNE through conda, as suggested in the documentation.

  • Pulling the repo:

    Since dockerfiles are commonly already inside a repository, it is uncommon to pull that same repository when building the image, but I have followed your suggestion. I think it might be a good example for someone trying to build their own images.

I documented basic usage in docker/README.md, but you can test the image like this:

sudo docker build -t mne . && sudo docker run --rm -it -v /host/work:/work -v /host/data/:/data --name mne-pipeline mne

Also, I added these changes in a new folder: docker. This is because I consider these examples, rather than the one and only Dockerfile for the repo (generally stored in ./Dockerfile). One could be made with build and test targets, though: There is a tiny example comment on this Dockerfile. I don't really know how the test are run for this repo, so I didn't test it myself.

The following points are missing:

  • Changelog has been updated (docs/source/changes.md):
    Should I just add a new line at the top with the date and a comment on what I did?
  • Many libraries are not installed with "default" installation, as seen by the output of mne.sys_info().

Output of mne.sys_info():


Platform:         Linux-5.15.60-1-MANJARO-x86_64-with-glibc2.31
Python:           3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:35:26) [GCC 10.4.0]
Executable:       /opt/conda/envs/mnenv/bin/python
CPU:              : 12 cores
Memory:           47.0 GB

mne:              1.1.1
numpy:            1.22.4 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:            1.9.1
matplotlib:       3.5.3 {backend=agg}

sklearn:          1.1.2
numba:            0.55.2
nibabel:          4.0.2
nilearn:          0.9.2
dipy:             1.5.0
cupy:             Not found
pandas:           1.4.4
pyvista:          Not found
pyvistaqt:        Not found
ipyvtklink:       0.2.2
vtk:              Not found
qtpy:             2.2.0 {PyQt5=5.15.4}
ipympl:           Not found
pyqtgraph:        Not found
pooch:            v1.6.0

mne_bids:         Not found
mne_nirs:         Not found
mne_features:     Not found
mne_qt_browser:   0.3.2
mne_connectivity: Not found
mne_icalabel:     Not found

I think mne_bids should be installed, shouldn't it?

Best,

Alberto

@welcome
Copy link

welcome bot commented Sep 2, 2022

Hello! 👋 Thanks for opening your first pull request here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

Copy link
Member

@hoechenberger hoechenberger left a comment

Choose a reason for hiding this comment

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

Hello, thanks for the work!!

I suggested to use the standalone installers instead of installing via conda, and I still believe this is the best approach here. Could you try to adjust the Dockerfile accordingly, please?

After [installing docker](https://docs.docker.com/get-docker/), open a terminal in the `docker` folder and build the image:

```
sudo docker build -t mne .
Copy link
Member

Choose a reason for hiding this comment

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

sudo shouldn't be necessary

A pipeline can be run from a configuration file on the current folder of the host machine (`./config.py`) as follows:

```
sudo docker run --rm -v .:/work -v /host/data/:/data --name mne-pipeline mne run
Copy link
Member

Choose a reason for hiding this comment

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

No sudo please.


To run an interactive session, you can add the flags `-it` and don't call the `run` parameter:
```
sudo docker run --rm -it -v /host/work:/work -v /host/data/:/data --name mne-pipeline mne
Copy link
Member

Choose a reason for hiding this comment

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

Again, no sudo please

@larsoner
Copy link
Member

larsoner commented Oct 6, 2022

@abcsds since mne-bids-pipeline is becoming a package, we'll soon put it up on pip and conda, hence it will have versions you can pin, and dask now seems to be working (but not extensively tested) -- do you still want to pursue this?

@rob-luke
Copy link
Member

rob-luke commented Oct 8, 2022

mne-bids-pipeline is becoming a package, we'll soon put it up on pip

At this point a docker container may be as simple as building off the official MNE-Docker repo build, then your image may be as simple as


FROM ghcr.io/mne-tools/mne-python-plot

RUN pip install mne-bids-pipeline

ENTRYPOINT ["tini", "-g", "--", "/usr/bin/prepare.sh"]

@larsoner
Copy link
Member

Once we have a proper PyPI and conda-forge release, can we close this and make a PR to mne-docker to add it there? It would be nice to keep mne-installers and mne-docker in sync. Even better if mne-docker could use mne-installers to do this...

@larsoner larsoner added this to the 0.1 milestone Nov 19, 2022
@hoechenberger
Copy link
Member

I have been working on exactly this and will share results soon

@larsoner
Copy link
Member

Closing in favor of mne-tools/mne-docker#24 and mne-tools/mne-installers#159

@larsoner larsoner closed this Nov 30, 2022
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.

None yet

4 participants