Skip to content

Commit

Permalink
Adding Docker config
Browse files Browse the repository at this point in the history
  • Loading branch information
JBris committed Aug 16, 2024
1 parent 8ac9aa0 commit a1bfc71
Show file tree
Hide file tree
Showing 24 changed files with 8,013 additions and 4 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Project
COMPOSE_PROJECT_NAME=deep-root-gen
APP_VERSION=0.1.0
GITHUB_CONTAINER_REPO=ghcr.io/jbris/${COMPOSE_PROJECT_NAME}

# Postgres
DB_NAME=deeprootgen
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: Docker Build

on:
workflow_dispatch: {}

release:
types:
- published

permissions:
actions: write
packages: write
Expand Down
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
![DeepRootGen](docs/logos/deep_root_gen.png)

# DeepRootGen

A simulation model for the digital reconstruction of 3D root system architectures. Integrated with a simulation-based inference generative deep learning model.
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Tests](https://github.com/JBris/deep-root-gen/actions/workflows/tests.yaml/badge.svg?branch=main)](https://github.com/JBris/deep-root-gen/actions/workflows/tests.yaml)
[![Documentation](https://github.com/JBris/deep-root-gen/actions/workflows/docs.yaml/badge.svg?branch=main)](https://github.com/JBris/deep-root-gen/actions/workflows/docs.yaml)
[![Build](https://github.com/JBris/deep-root-gen/actions/workflows/docker-build.yaml/badge.svg?branch=main)](https://github.com/JBris/deep-root-gen/actions/workflows/docker-build.yaml)

*A simulation model for the digital reconstruction of 3D root system architectures. Integrated with a simulation-based inference generative deep learning model.*

# Table of contents

- [DeepRootGen](#deeprootgen)
- [Table of contents](#table-of-contents)
- [Introduction](#introduction)
- [Data Schema](#data-schema)
- [Contacts](#contacts)

# Introduction

This repository contains an implementation of a simulation model for generating the root system architecture, for the estimation of root parameters as informed by observational data collected from the field.

# Data Schema

The primary purpose of DeepRootGen is to output a synthetic root system into a tabular data format. The tabular data are composed of several columns:

| Column | Type | Description |
| ------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id | Discrete | A unique ID for each row. |
| plant_id | Discrete | A unique ID for each plant. |
| organ_id | Discrete | A unique ID for each root. |
| order | Discrete | The plant order. A first order root grows from the plant base, second order roots emerge from first order roots, third order roots emerge from second order roots, and so on. |
| root_type | Discrete | The root type classification. Can be one of 1 = Structural Root or 2 = Fine Root. |
| segment_rank | Discrete | The rank number for each root segment. A small rank refers to segments that are close to the root base, while a large rank refers to roots that are near the root apex. |
| parent | Discrete | The parent organ of the root segment. The parent node of the organ within the GroIMP graph. Used by the XEG reader to recursively import the synthetic root data. |
| coordinates | Continuous | The combined 3D coordinates (x, y, and z) of each root segment. |
| diameter | Continuous | The root segment diameter. |
| length | Continuous | The root segment length. |
| x | Continuous | The x coordinate of the root segment. |
| y | Continuous | The y coordinate of the root segment. |
| z | Continuous | The z coordinate of the root segment. |

# Contacts

- DeepRootGen Developer: James Bristow
- DeepRootGen Project Supervisor: Junqi Zhu
- Crop System Modeller: Xiumei Yang
17 changes: 17 additions & 0 deletions apptainer/python/Apptainer.0.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Bootstrap: docker
From: ghcr.io/jbris/deep-root-gen:0.1.0

%labels
Maintainer [email protected]
Version 0.1.0

%post
prefect config set PREFECT_API_ENABLE_HTTP2=false
prefect config set PREFECT_API_TLS_INSECURE_SKIP_VERIFY=true
prefect config set PREFECT_EXPERIMENTAL_ENABLE_TASK_SCHEDULING=true

%help
This is a container to run the DeepRootGen model.

%runscript
exec "$@"
132 changes: 132 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
services:

mlflow:
image: ghcr.io/jbris/deep-root-gen:${APP_VERSION}
build:
context: .
dockerfile: ./dockerfiles/python/Dockerfile.${APP_VERSION}
args:
BUILD_DATE: date -u +'%Y-%m-%dT%H:%M:%SZ'
restart: always
stop_grace_period: 10s
environment:
MLFLOW_BACKEND_STORE_URI: $MLFLOW_BACKEND_STORE_URI
MLFLOW_S3_ENDPOINT_URL: http://minio:9000
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
ports:
- 5000:5000
command: >
mlflow server --serve-artifacts --host 0.0.0.0 --port 5000
--backend-store-uri "${MLFLOW_BACKEND_STORE_URI}" --default-artifact-root s3://mlflow/
--expose-prometheus /prometheus
prefect-server:
image: ghcr.io/jbris/deep-root-gen:${APP_VERSION}
build:
context: .
dockerfile: ./dockerfiles/python/Dockerfile.${APP_VERSION}
args:
BUILD_DATE: date -u +'%Y-%m-%dT%H:%M:%SZ'
restart: always
stop_grace_period: 10s
environment:
PREFECT_UI_URL: http://127.0.0.1:4200/api
PREFECT_API_URL: http://127.0.0.1:4200/api
PREFECT_SERVER_API_HOST: 0.0.0.0
PREFECT_API_DATABASE_CONNECTION_URL: $PREFECT_API_DATABASE_CONNECTION_URL
ports:
- 4200:4200
entrypoint: >
prefect server start
postgres:
image: ${COMPOSE_PROJECT_NAME}-postgres:${APP_VERSION}
build:
context: .
dockerfile: ./dockerfiles/postgres/Dockerfile.${APP_VERSION}
args:
BUILD_DATE: date -u +'%Y-%m-%dT%H:%M:%SZ'
restart: always
stop_grace_period: 10s
environment:
POSTGRES_PASSWORD: $DB_PASSWORD
POSTGRES_DB: $DB_NAME
POSTGRES_USER: $DB_USER
ports:
- 5432:5432
volumes:
- postgres-data:/var/lib/postgresql/data

minio:
image: minio/minio:RELEASE.2023-05-27T05-56-19Z
restart: always
stop_grace_period: 10s
working_dir: /data
volumes:
- minio-data:/data
ports:
- 9000:9000
- 9001:9001
environment:
MINIO_ACCESS_KEY: $MINIO_ACCESS_KEY
MINIO_SECRET_KEY: $MINIO_SECRET_KEY
MINIO_ROOT_USER: $MINIO_ROOT_USER
MINIO_ROOT_PASSWORD: $MINIO_ROOT_PASSWORD
MINIO_STORAGE_USE_HTTPS: False
MINIO_PROMETHEUS_AUTH_TYPE: public
command: server --console-address :9001 --address :9000 /data

mc:
image: minio/mc:RELEASE.2023-05-30T22-41-38Z
environment:
MINIO_PORT: 9000
MINIO_ACCESS_KEY: $MINIO_ACCESS_KEY
MINIO_SECRET_KEY: $MINIO_SECRET_KEY
depends_on:
- minio
entrypoint: >
/bin/sh -c ' sleep 5;
/usr/bin/mc config host add s3 http://minio:9000 ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY} --api S3v4;
[[ ! -z "`/usr/bin/mc ls s3 | grep challenge`" ]] || /usr/bin/mc mb s3/mlflow; /usr/bin/mc policy download s3/mlflow;
[[ ! -z "`/usr/bin/mc ls s3 | grep challenge`" ]] || /usr/bin/mc mb s3/data; /usr/bin/mc policy download s3/data; exit 0; '
cloudbeaver:
image: dbeaver/cloudbeaver:23.3.1
restart: always
stop_grace_period: 10s
ports:
- 8978:8978
volumes:
- cloudbeaver-data:/opt/cloudbeaver/workspace

metabase:
image: metabase/metabase:v0.48.0
restart: unless-stopped
stop_grace_period: 10s
environment:
MB_DB_TYPE: postgres
MB_DB_HOST: postgres
MB_DB_PORT: 5432
MB_DB_PASS: $DB_PASSWORD
MB_DB_DBNAME: $DB_NAME
MB_DB_USER: $DB_USER
MB_DB_FILE: /metabase-data/metabase.db
MB_PROMETHEUS_SERVER_PORT: 3001
ports:
- 3000:3000
- 3001:3001
volumes:
- metabase-data:/metabase-data

networks:
default:
name: $COMPOSE_PROJECT_NAME
driver: bridge

volumes:
minio-data: {}
postgres-data: {}
cloudbeaver-data: {}
metabase-data: {}

9 changes: 9 additions & 0 deletions dockerfiles/postgres/Dockerfile.0.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM postgres:15.3-bullseye

ARG BUILD_DATE

LABEL [email protected]

LABEL org.label-schema.build-date=$BUILD_DATE

COPY sql/init.sql /docker-entrypoint-initdb.d/init.sql
43 changes: 43 additions & 0 deletions dockerfiles/python/Dockerfile.0.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM python:3.10.14-bullseye as base

ARG BUILD_DATE

LABEL [email protected]

LABEL org.label-schema.build-date=$BUILD_DATE

WORKDIR /app

COPY README.md README.md

COPY deeprootgen deeprootgen

RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential libpq-dev graphviz \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /tmp/downloaded_packages

FROM base as builder

ENV POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_IN_PROJECT=1 \
POETRY_VIRTUALENVS_CREATE=1 \
POETRY_CACHE_DIR=/tmp/poetry_cache \
PATH="/root/.local/bin:$PATH"

COPY pyproject.toml poetry.lock ./

RUN curl -sSL https://install.python-poetry.org | python3 -\
&& poetry install --without dev \
&& rm -rf $POETRY_CACHE_DIR \
&& curl -sSL https://install.python-poetry.org | python3 - --uninstall

FROM base as runtime

ENV VIRTUAL_ENV=/app/.venv \
PATH="/app/.venv/bin:$PATH"

COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}

RUN chmod -R 755 /app
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file added docs/logos/deep_root_gen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
5 changes: 5 additions & 0 deletions docs/source/api_reference/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
API Reference
=============

.. toctree::
:maxdepth: 1
7 changes: 7 additions & 0 deletions docs/source/changelogs/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Changelog
=========

0.1.0 - 2024/08/17
------------------

* Stub
41 changes: 41 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import os
import sys

sys.path.insert(0, os.path.abspath("../.."))

project = "DeepRootGen"
copyright = "2024, James Bristow"
author = "James Bristow"
release = "0.1.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
"sphinxarg.ext",
]

numpydoc_show_class_members = False

templates_path = ["_templates"]

source_suffix = ".rst"

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"

html_static_path = ["_static"]

# The master toctree document.
master_doc = "index"

# Datetime

today_fmt = "%d/%m/%y"
Loading

0 comments on commit a1bfc71

Please sign in to comment.