Skip to content

Commit

Permalink
Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanFauvel committed Oct 22, 2022
1 parent 23e98e2 commit 1da0785
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 48 deletions.
6 changes: 0 additions & 6 deletions .env

This file was deleted.

4 changes: 4 additions & 0 deletions .env -sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
USERNAME = "my_username"
PASSWORD = "azerty123"
AUTH_TOKEN ="TOKEN"
ROOT_FOLER = "/home/"
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
*.csv
*.odt
*.sif
.Rproj.user
R_baseline/
TODO.md
config.py
*.zip
*.mp4
References/
.env
43 changes: 18 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
# Template-Python-Singularity
## A template to build executable Singularity images in Python projects
## A template to build executable Singularity images for Python projects

### Objective

This repo contains a template to create a Python app that will run in an executable Singularity image. A Singularity containers can typically be used in data science projects to provide transparency and support of reproducibility.
This repo contains a template to create a Python app that will run in an executable Singularity container. A Singularity container can typically be used in data science projects to provide transparency and support of reproducibility.

### Content

* `singularity/`: singularity container
* singularity_test
* `utils/` : utility scripts (to make submissions, etc)

* `src/`: models
* `utils/` : utility scripts. The code in this directory is not included in the singularity container.
* `build_image.sh` : a script to build a container image based on `singularity/recipe.txt`. The corresponding Singularity image is executable, and contains the scripts in `src/`. By default, the execution of the container image runs `src/model.py` (edit `recipe.txt` to change this behavior).
* `test_container.sh` : a script to test if the execution of the container image works properly.
* `singularity/`: contains the singularity image built with `build_image.sh`
* `singularity_test` : a directory where a singularity image is copied and tested.
* `src/`: the code that is included in the container.
* `data/` : input data
* `output/` : where code output is stored

### Instruction to build the singularity container from the recipe.txt

To create an executable singularity container (which contains the code in /src), run :
To create an executable singularity container (which contains the code in `/src`) from `singularity/recipe.txt`, run :

```bash
./utils/build_container.sh
```

This will create a container container.sif in /singularity.
To test the executable singularity container, run :
This will create a container image `/singularity/container.sif`.
To test the executable singularity container image, run :

```bash
./utils/test_container.sh
```

This will output the results in singularity/test_singularity/output.
This will output the results of `src/model.py` in `singularity/test_singularity/output`.

### Instructions to run the model
### Instructions to execute the image

The singularity container container.sif is executable, you can reproduce the results by running:
The singularity container image container.sif is executable, you can execute it by running:

```bash
singularity run ./singularity/container.sif <Argument for input path>
Expand All @@ -43,11 +44,10 @@ singularity run ./singularity/container.sif <Argument for input path>
Note: `<Argument for input path> ` is optional, default is ./


Note that container.sif should be in the same folder as /training and /test.
The prediction scores on test dataset are saved in `./output/scores.csv`.
### Instructions to run a custom model in the same environment

To run a model locally on synthetic data in the container environement, activate the singularity container in Terminal using:
By default, the script called model.py is executed upon execution of the image.
To run a specific Python script locally on synthetic data in the container environment, activate the singularity container in Terminal using:

```bash
singularity shell ./singularity/container.sif
Expand All @@ -57,22 +57,15 @@ This will allow you to have an environment (`Singularity>`) to run the model wit
In order to run the model, run the following command :

```bash
Singularity> python3 src/model.py <Argument for input path>
```

For example, on my computer, when my cwd is the DreamHF folder, I run :

```bash
Singularity> python3 src/model.py ./
Singularity> python3 src/script.py <Argument for input path>
```

This command can also be used to run the singularity without accessing the singularity shell:

```bash
singularity exec container.sif python3 src/model.py <Argument for input path>
singularity exec container.sif python3 src/script.py <Argument for input path>
```


### License

This software is distributed under the GNU GENERAL PUBLIC LICENSE. Please refer to the file LICENCE.txt included for details.
6 changes: 0 additions & 6 deletions singularity/test_singularity/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions utils/.env -sample

This file was deleted.

File renamed without changes.

0 comments on commit 1da0785

Please sign in to comment.