Skip to content

Commit a94aab4

Browse files
Merge pull request #112 from ArnovanHilten/dockerfile
Add docker image for reproducibility
2 parents 7d8c18b + e55d7ca commit a94aab4

File tree

3 files changed

+73
-41
lines changed

3 files changed

+73
-41
lines changed

.dockerignore

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,14 @@ conda_env/
1111
build/
1212
dist/
1313
*.egg-info
14-
# Ignore version control system folders
15-
.git/
16-
.gitignore
1714
# Ignore OS-specific hidden files
1815
.DS_Store
1916
Thumbs.db
20-
# If you have a big data directory or logs, ignore those too
21-
data/
22-
logs/
23-
2417
# jupyter notebooks
2518
.ipynb_checkpoints
2619
__pycache__/
27-
# processed data
28-
processed_data/*
29-
!processed_data/.gitkeep
30-
# results
31-
results/*
32-
!results/.gitkeep
3320
# idea
3421
.idea/
3522
.idea/*
3623
.swp
3724
*.swp
38-
.log
39-
*.log
40-
examples/A_to_Z/processed_data/*

Dockerfile

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,22 @@
1-
# Step 1: Use the official TensorFlow 2.11 image as the base
2-
FROM tensorflow/tensorflow:2.11.0
1+
FROM continuumio/miniconda3
32

4-
# Step 2: Install system dependencies
5-
RUN apt-get update && apt-get install -y \
6-
git \
7-
wget \
8-
&& rm -rf /var/lib/apt/lists/*
3+
WORKDIR /workspace
94

10-
# Step 3: Upgrade pip to the latest version
11-
RUN python3 -m pip install --upgrade pip
5+
COPY requirements_GenNet.txt .
126

13-
# Step 4: Copy your requirements file into the container
14-
COPY requirements_GenNet.txt /tmp/requirements_GenNet.txt
7+
# Create the environment
8+
RUN conda create -n env_GenNet python=3.10.12 -y
159

16-
# Step 5: Install Python packages
17-
RUN pip install --no-cache-dir -r /tmp/requirements_GenNet.txt
10+
# Install pip packages
11+
RUN /bin/bash -c "source activate env_GenNet && \
12+
pip install --upgrade pip && \
13+
pip install -r requirements_GenNet.txt"
1814

19-
# Step 6: Set the working directory
20-
WORKDIR /app
15+
COPY . /workspace
2116

22-
# Step 7: Copy your project files into the container
23-
COPY . /app
17+
# RUN mkdir -p /workspace/processed_data /workspace/results
2418

25-
# Step 8: Set environment variables (optional)
26-
ENV RESULT_PATH="/app/results"
27-
ENV DATA_PATH="/app/examples"
19+
RUN echo "conda activate env_GenNet" >> ~/.bashrc
2820

29-
# Step 9: Define the entrypoint to simplify CLI usage
30-
ENTRYPOINT ["python", "GenNet.py"]
21+
# Set CMD to launch bash with environment activated
22+
CMD ["/bin/bash", "-c", "source activate env_GenNet && exec bash"]

README.md

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ The Gennet framework is based on tensorflow, click [here](GenNet_utils/LocallyDi
2323

2424
## 2. Getting started
2525

26+
GenNet can be used in two ways:
27+
- Manual installation: clone the repository and set up the virtual environment.
28+
- Use the docker image.
29+
30+
### 1. Manual installation
31+
2632
Follow the instructions below to get started.
2733

2834
> [!TIP]
2935
> Check the [A to Z Colab tutorial](https://colab.research.google.com/github/ArnovanHilten/GenNet/blob/master/examples/A_to_Z/GenNet_A_to_Z.ipynb) for an overview on how to use GenNet with your own data!
3036
31-
### Prerequisites:
37+
#### Prerequisites:
3238

3339
- GenNet is optimized to use Tensorflow on CPU using multiple-cores as sparse matrix multiplcations does not benefit from GPU acceleration. We are currently restricting testing and recommending using:
3440

@@ -38,13 +44,13 @@ Follow the instructions below to get started.
3844

3945

4046

41-
### Clone the repository
47+
#### Clone the repository
4248

4349
Open terminal. Navigate to the a place where you want to store the project. Clone the repository:
4450
```
4551
git clone https://github.com/arnovanhilten/GenNet
4652
```
47-
### Install the virtual envionment
53+
#### Install the virtual envionment
4854

4955
**Create a virtual environment**
5056
```
@@ -73,6 +79,56 @@ python GenNet.py train -path ./examples/example_classification/ -ID 1
7379

7480
Check the [wiki](https://github.com/ArnovanHilten/GenNet/wiki) for more info!
7581

82+
83+
### 2. Docker
84+
85+
Make sure that you have [docker](https://www.docker.com/) installed:
86+
87+
#### Pull the Docker image
88+
```bash
89+
docker pull avanhilten/gennet-image:latest
90+
```
91+
#### Run the docker
92+
93+
In Linux/macOS/WSL:
94+
95+
```bash
96+
docker run --rm -it \
97+
-v $(pwd)/examples:/workspace/examples \
98+
-v $(pwd)/processed_data:/workspace/processed_data \
99+
-v $(pwd)/results:/workspace/results \ avanhilten/gennet-image \
100+
```
101+
Or in powershell:
102+
```
103+
powershell docker run --rm -it -v C:\Users\YOURNAME\GenNet\examples:/workspace/examples `
104+
-v C:\Users\YOURNAME\GenNet\processed_data:/workspace/processed_data `
105+
-v C:\Users\YOURNAME\GenNet\results:/workspace/results `
106+
avanhilten/gennet-image
107+
```
108+
> Replace `YOURNAME` with your actual Windows username and adjust the paths if needed.
109+
110+
Then all GenNet commands can be utilized, such as:
111+
```
112+
python GenNet.py train -path /workspace/examples/example_classification -ID 1 -out results
113+
```
114+
115+
> [!CAUTION]
116+
> Output argument required
117+
> Always include the
118+
> `-out /workspace/results` argument when running in Docker to ensure results are written to the mounted `results/` folder on your machine.
119+
120+
#### Running on your own data
121+
122+
You can mount your own input/output directories:
123+
```bash
124+
docker run --rm -it \
125+
-v /path/to/my_data:/workspace/my_data \
126+
-v /path/to/output:/workspace/output \
127+
avanhilten/gennet-image \
128+
129+
python GenNet.py train -path /workspace/my_data -ID 7 -out /workspace/output
130+
```
131+
76132
## 3. GenNet command line.
77133
<img align = "right" src="https://github.com/ArnovanHilten/GenNet/blob/master/figures/Gennet_wiki_overview.png?raw=true" width="480">
78134

0 commit comments

Comments
 (0)