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 Dockerfile and instructions for vscode and google cloud #58

Merged
merged 28 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f966234
add dockerfile
gcattan Jun 28, 2022
5d60654
push ci file
gcattan Jun 28, 2022
7c7e48b
fix dockerfile
gcattan Jun 28, 2022
9c90ab3
modify dockerfile
gcattan Jun 28, 2022
c9132c6
push image to registery
gcattan Jun 28, 2022
84e4f3b
fix syntax error
gcattan Jun 28, 2022
688a349
missing parenthesis
gcattan Jun 28, 2022
01144dd
trigger pipeline
gcattan Jun 28, 2022
c0a4129
syntax error
gcattan Jun 28, 2022
fcec670
trigger pipeline
gcattan Jun 28, 2022
6d91f8a
fix tag
gcattan Jun 28, 2022
960150b
syntax error
gcattan Jun 28, 2022
9c74859
use PR id number instead
gcattan Jun 28, 2022
d9cd036
fix registry name
gcattan Jun 28, 2022
9d03261
visual studio config.
gcattan Jun 28, 2022
78544c8
- add workaround for qiskit version number
gcattan Jun 29, 2022
e37e66c
comment docker login and docker push
gcattan Jun 29, 2022
352911d
edit readme
gcattan Jun 29, 2022
0eae2bf
test modification of example to see if google cloud run it.
gcattan Jun 29, 2022
ae4394a
add home/mne_data for google cloud
gcattan Jun 29, 2022
64c1e3a
Revert "test modification of example to see if google cloud run it."
gcattan Jun 29, 2022
56544d8
Update README.md
gcattan Jun 29, 2022
a970391
Revert "Revert "test modification of example to see if google cloud r…
gcattan Jun 29, 2022
37be539
made another test with the example
gcattan Jun 29, 2022
2fa9e84
Merge branch 'gc/docker' of https://github.com/gcattan/pyRiemann-qisk…
gcattan Jun 29, 2022
5049a4e
Revert "Revert "Revert "test modification of example to see if google…
gcattan Jun 29, 2022
ca52c92
reset modification to example
gcattan Jun 29, 2022
9cd83f8
Update README.md
gcattan Jun 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.0/containers/docker-existing-dockerfile
{
"name": "Existing Dockerfile",

"context": "..",

"dockerFile": "../Dockerfile",

"settings": {},

"extensions": [
],

"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
]
}
22 changes: 22 additions & 0 deletions .github/workflows/create_docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:

build:

runs-on: ubuntu-latest
env:
tag: ${{ github.event.pull_request.number }}
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: |
docker build . --file Dockerfile --tag ghcr.io/${{ github.actor }}/pyriemann-qiskit:$tag
# docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
# docker push ghcr.io/${{ github.actor }}/pyriemann-qiskit:$tag
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM python:3.8-slim-buster
ADD pyriemann_qiskit /pyriemann_qiskit
ADD examples /examples
ADD setup.py /
ADD README.md /

RUN apt-get update
RUN apt-get -y install git

RUN apt-get --allow-releaseinfo-change update
RUN python -m pip install --upgrade pip
RUN apt-get -y install --fix-missing git-core
RUN apt-get -y install build-essential

RUN python setup.py develop
RUN pip install .[docs]

# WORKAROUNDS
## Qiskit problem in parsing version number
RUN echo 0.21.0 > /usr/local/lib/python3.8/site-packages/qiskit_terra-0.21.0rc1-py3.8-linux-x86_64.egg/qiskit/VERSION.txt
## Creating folders for mne data
RUN mkdir /root/mne_data
RUN mkdir /home/mne_data

ENTRYPOINT [ "python", "/examples/ERP/classify_P300_bi.py" ]
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ Then you can run the python example of your choice like:
python examples\ERP\classify_P300_bi.py
```

### Installation with docker

We also offer the possibility to set up the dev environment within docker.
To this end, we recommand to use `vscode` with the `Remote Containers` extension
from Microsoft.

Once the installation is successful, just open the project in `vscode` and enter `F1`.
In the search bar that opens, type `Rebuild and Reopen Container`.

Wait for the container to build, and open a python shell within the container.
Then ensure everything went smoothly by typing:

```
import pyriemann_qiskit
```

## Contributor Guidelines

Everyone is welcomed to contribute to this repository. There are two types of contributions:
Expand Down Expand Up @@ -132,8 +148,43 @@ Code contribution (pull request) can be either on core functionalities, document

Workflows are automatically triggered when you push a commit. However, the worflow for example execution is only triggered when you modify one of the examples or the documentation as the execution take a lot of time. You can enable [Github Actions](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository) in your fork to see the result of the CI pipeline. Results are also indicated at the end of your pull request when raised. However note, that workflows in the pull request need approval from the maintainers before being executed.

### Deploy an example on the cloud

When creating an example, your local computer may be limited in terms of ressources to emulate a quantum computer.
Instead, you might want to use a cloud provider to run the example.
Here we will provide the steps with the Google Cloud Plateform (other cloud providers offer similar functionnalities):

1. Create a new branch with you example in your fork repository. Modify the `/Dockerfile` to redirect the `entrypoint` to your example.
Make sure that the `create_docker_image` workflow passed.
2. Open an account on Google Cloud (it required a billing account, but you will not be charged until you upgrade your account).
3. Create a [Cloud Run Service](https://console.cloud.google.com/run/create?project=pyriemann-qiskit) called `pyriemmann-qiskit` (or any project name which is suitable for you).
For the moment use the default configuration, although you may want to already indicate the physical ressources:

![image](https://user-images.githubusercontent.com/6229031/176449146-d3c3da37-0382-46e6-a20b-1b963ce6c12a.png)

4. Create an [artifactory repository](https://console.cloud.google.com/artifacts/create-repo?project=pyriemann-qiskit), following
the `Create a Docker repository in Artifactory` tutorial. Tutorials are displayed in the right side panel of the plateform.
Make sure to indicate `pyriemann-qiskit` as a project (or the one you created instead).
5. Create a new [Cloud Build Trigger](https://console.cloud.google.com/cloud-build/triggers?project=pyriemann-qiskit). Provide the required permissions to install the `Google Build app` on Github. This will allow Google Cloud to build a container image directly from your fork repository. The process is automated and you only need to follow the steps. For more details click [here](https://cloud.google.com/build/docs/automating-builds/build-repos-from-github).
6. Under `Configuration>Type`, select `Dockerfile`.
7. Under `Configuration>Location`, select `Repository` and type `Dockerfile` in the input box `Dockerfile name`.
8. Under `Configuration>Location` provide a value for the image name.
It should be in the form: `<XXX>-docker.pkg.dev/<name of your cloud run service>/<name of your docker repo>/<custom image name>:$COMMIT_SHA`.
You can copy the first part of this URL (except the image name) from your artifactory settings:

![image](https://user-images.githubusercontent.com/6229031/176449496-daf5f263-3bb9-4eb9-aad3-7bcf289b8f59.png)

9. Validate the trigger, and run it. Check everything passed.
10. Edit the service you created in step `3`, and select a `Container Image URL`. If everything went well,
a new image should have been pushed in your artifact repository. It is also possible to specify a different entrypoint that the one provided in setp `1`

![image](https://user-images.githubusercontent.com/6229031/176448796-8d2472c5-5662-4b69-8d47-c31ebbe9a7e5.png)

11. Validate the service and click on the `Logs` tab to see the output.

# Troubleshooting

## Version of pyRiemann not updated
There is a known issue when you install `pyRiemann-qiskit` in an environement where there is already `pyRiemann` installed. In such case, the `pyRiemann` version is not updated. Therefore before installing or updating `pyRiemann-qiskit`, we recommend to install `pyRiemann` as it follows:

```
Expand Down