Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
b7e0dfb
Minor typo fix
jlegrand62 Oct 8, 2025
d513877
Update dependencies and Python version requirements
jlegrand62 Oct 8, 2025
f620013
Refactor imports to use `fsdb.core`
jlegrand62 Oct 8, 2025
e016330
Refactor date function and update imports
jlegrand62 Oct 8, 2025
fcc4c5c
Refactor date functions for ISO 8601 compliance
jlegrand62 Oct 8, 2025
a935ecd
Add User Authentication Module
jlegrand62 Oct 8, 2025
04afd7e
Add Authentication Tests
jlegrand62 Oct 8, 2025
72acdd1
Refactor imports in `core.py`
jlegrand62 Oct 8, 2025
99bbfa7
Refactor User Authentication in `core.py`
jlegrand62 Oct 8, 2025
7940039
Add User Authentication Methods and Token Management to PlantDB Client
jlegrand62 Oct 8, 2025
6d284d2
Add JWT Authentication to REST API Endpoints
jlegrand62 Oct 8, 2025
777b7a4
Enhance REST API Security and Session Management
jlegrand62 Oct 8, 2025
edfaec2
Add User Management Methods
jlegrand62 Oct 8, 2025
8b00656
Remove metadata management script
jlegrand62 Oct 8, 2025
233c0c1
Update Python version constraint in conda setup and refactor FSDB imp…
jlegrand62 Oct 8, 2025
329d17e
Refactor FSDB import paths to use core module.
jlegrand62 Oct 17, 2025
664e392
Refactor function parameter names in test_database.py
jlegrand62 Oct 17, 2025
2d743fb
Refactor FSDB import paths to use core module.
jlegrand62 Oct 17, 2025
fcf7bd8
Enhance REST API Server Initialization
jlegrand62 Oct 17, 2025
eaf21a0
Enhance REST API Server Initialization in WSGI
jlegrand62 Oct 17, 2025
df663c3
Enhance User Authentication and Session Management
jlegrand62 Oct 17, 2025
e36fe87
Add decorators and improve user authentication in FSDB
jlegrand62 Oct 17, 2025
e6c020f
Improve shared_fsdb.py documentation and add comments
jlegrand62 Oct 17, 2025
109c146
Refactor JWT Authentication and Update REST API Endpoints
jlegrand62 Oct 17, 2025
a25be85
Add REST API Server Tests
jlegrand62 Oct 17, 2025
18ff80c
Refactor JWT Authentication in PlantDB Client
jlegrand62 Oct 17, 2025
c593bb4
Fix examples in REST API
jlegrand62 Oct 17, 2025
162485e
Refactor JWT Session Manager and SingleSessionManager
jlegrand62 Oct 17, 2025
2ff55a2
Move `dummy_db`
jlegrand62 Oct 17, 2025
56fd687
Fix authentication system
jlegrand62 Oct 17, 2025
8f59a76
Update authentication system by updating JWT refresh logic
jlegrand62 Oct 17, 2025
fdc9bbc
Use `JWTSessionManager` as sessions in REST API
jlegrand62 Oct 17, 2025
139faa2
Add `require_token` decorator and refactor `logout` method
jlegrand62 Oct 17, 2025
253a5f4
Refactor session management and username handling
jlegrand62 Oct 17, 2025
f3d3f37
Support `SingleSessionManager` in `FSDB` and improve locking mechanisms
jlegrand62 Oct 17, 2025
7984a26
Add environment variables for Flask and JWT secret keys, enhance type…
jlegrand62 Oct 17, 2025
0506b3f
Add robust server availability checker with SSRF safety guards
jlegrand62 Oct 21, 2025
cd28384
Refactor server availability checks and update function names
jlegrand62 Oct 21, 2025
24b838b
Remove unused datetime imports from utils.py
jlegrand62 Oct 22, 2025
f5f956c
Add write permission test for FSDB base path
jlegrand62 Oct 22, 2025
34d3445
Add robust URL validation and server check with SSRF protection
jlegrand62 Oct 22, 2025
837061e
Add token validation endpoint and refine related documentation
jlegrand62 Oct 22, 2025
b3381ca
Add session token validation and simplify auth handling
jlegrand62 Oct 22, 2025
8a90a23
Remove legacy certificate handling and simplify API request logic
jlegrand62 Oct 22, 2025
5ab022d
Update wsgi docs and URL prefix comment
jlegrand62 Oct 23, 2025
8181029
Add optional cert_path to server availability check
jlegrand62 Oct 23, 2025
cce6a2d
Update test imports and server availability usage
jlegrand62 Oct 23, 2025
d6a9842
Use environment variables for API host, port, and prefix
jlegrand62 Oct 23, 2025
fa221a4
Add login/logout helpers and preview image URL helper
jlegrand62 Oct 23, 2025
fc6bf8a
Fix `make_api_request`
jlegrand62 Oct 23, 2025
8056528
Add session_token support to API calls and improve timeout handling
jlegrand62 Oct 23, 2025
cf191c7
Simplify login token handling
jlegrand62 Oct 23, 2025
e6d4e76
Update API host/port defaults and simplify base_url
jlegrand62 Oct 27, 2025
6d3d460
Update tests for simplified URL helper signatures
jlegrand62 Oct 27, 2025
9449a51
Reformat ServerCheckResult return statements for consistency
jlegrand62 Oct 27, 2025
9dcc2f4
Add ada-url dependency
jlegrand62 Oct 28, 2025
c55cbed
Refactor whitelist URL parsing to use AdaURL
jlegrand62 Oct 28, 2025
0862418
Update blacklist download logic to use urllib3 and add force flag
jlegrand62 Oct 28, 2025
5db4400
Refactor DNS resolution to use `urllib3` and improve error handling
jlegrand62 Oct 28, 2025
94abec8
Rename `_validate_host` to `_validate_hostname` and update documentation
jlegrand62 Oct 28, 2025
1c54e8d
Refactor URL parsing to use Ada‑URL and add host validation flag
jlegrand62 Oct 28, 2025
289a550
Refactor server availability check to use urllib3 and expose redirect…
jlegrand62 Oct 28, 2025
fab5aad
Update test_client_against_server.py to disable SSL verification
jlegrand62 Oct 28, 2025
cf66c3b
Add API endpoints helper module for PlantDB client
jlegrand62 Oct 29, 2025
3bce052
Refactor REST API URL helpers to use ada‑url and a central endpoint b…
jlegrand62 Oct 29, 2025
7ad54f0
Refactor REST API URL helpers and centralize URL construction
jlegrand62 Oct 29, 2025
d008d23
Add register, token refresh, and token validation endpoints
jlegrand62 Oct 29, 2025
c3d9701
Add register and user‑validation helpers to REST client
jlegrand62 Oct 29, 2025
9a0bd52
Fix quoting in Authorization header
jlegrand62 Oct 29, 2025
57c7dc8
Add manual measures support and refine Sequence endpoint
jlegrand62 Nov 12, 2025
ef2b999
Add sequence endpoint helper
jlegrand62 Nov 12, 2025
e0282b0
Increase rate limit for image retrieval to 3000 requests per minute
jlegrand62 Nov 13, 2025
d24c7bb
Add missing ‘exists’ exceptions for scans, filesets, and files
jlegrand62 Nov 13, 2025
7a77dad
Add missing `*ExistsError` exceptions for scans, filesets, and files
jlegrand62 Nov 13, 2025
49d266b
Drop Python 3.13 upper bound and adjust Open3D dependency
jlegrand62 Dec 16, 2025
85dd26a
Add Open3D dependency to Docker image
jlegrand62 Dec 16, 2025
b3456fe
Drop Python3.13 upper bound
jlegrand62 Dec 16, 2025
7b694b8
fix: Import `sanitize_name` from `plantdb.client.api_endpoints` inste…
jlegrand62 Jan 20, 2026
87d0ab7
Refactor REST API setup and add helper utilities
jlegrand62 Jan 20, 2026
5633a77
Reformat API registration and tighten configuration signatures
jlegrand62 Jan 20, 2026
e1938e6
Simplify image response by removing explicit mimetype
jlegrand62 Jan 21, 2026
dc3249b
Authentication module refactoring
jlegrand62 Jan 21, 2026
4f670f5
Refactor auth imports to use the new top‑level `plantdb.commons.auth`…
jlegrand62 Jan 21, 2026
a31a3a3
Fix docstring indentation in lock.py
jlegrand62 Jan 21, 2026
49b6aaf
Update test_auth imports to use the new auth submodule paths.
jlegrand62 Jan 21, 2026
d64eec7
Refactor URL handling and server availability checks
jlegrand62 Jan 22, 2026
0ff2aec
Improve download handling in `src/commons/plantdb/commons/test_databa…
jlegrand62 Jan 22, 2026
7ef76c5
Add type annotations and lazy imports to FSDB exception classes
jlegrand62 Jan 22, 2026
40414c7
Minor fix
jlegrand62 Jan 22, 2026
e4de834
Rename environment variables for PlantDB client
jlegrand62 Jan 22, 2026
7719a97
Add 'test' dependencies 'plantdb.server' and 'open3d' in 'plantdb.cli…
jlegrand62 Jan 22, 2026
a040982
Bump package versions to 0.14.6
jlegrand62 Jan 22, 2026
f4c0435
Add admin login before creating scan in fsdb_import_images.py
jlegrand62 Jan 26, 2026
fff4797
Add build cache mounts to Dockerfile
jlegrand62 Jan 26, 2026
6eabc92
Add unit-test mode to Docker run script
jlegrand62 Jan 26, 2026
a224951
Simplify CI workflow for pull requests
jlegrand62 Jan 26, 2026
1b841ed
Change gh‑pages workflow to trigger on release and dispatch
jlegrand62 Jan 26, 2026
69d84a6
Add client test dependencies and run client tests in Docker build
jlegrand62 Jan 26, 2026
1085251
Simplify pull request CI workflow
jlegrand62 Jan 26, 2026
c542ae4
Specify Dockerfile path for pull request build
jlegrand62 Jan 26, 2026
552b9ac
Add client source to Docker build
jlegrand62 Jan 26, 2026
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
7 changes: 5 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

name: Build & Deploy documentation

# Triggers workflow on any push to the repository
on:
- push
# Automatic trigger on release
release:
types: [ published ]
# Enables manual triggering from the Action tab
workflow_dispatch:

jobs:
docs:
Expand Down
47 changes: 12 additions & 35 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,26 @@
# GitHub workflow that build the Docker image, run python unit tests & clean-up

# pull_request.yml
name: CI UnitTests

on: pull_request
on:
pull_request:

jobs:
# Build a Docker image with the current code
docker-build:
runs-on: ubuntu-latest
build-and-test:
runs-on: ubuntu-22.04
steps:
# Step 1: Check out repository code including submodules
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

# Step 2: Build the Dockerfile
- name: Build Dockerfile
# Build the Docker image, targeting the test stage
- name: Build Docker image
run: |
# Clean up any dangling containers before build
docker container prune -f
# Build Docker image using commit SHA as tag with clean cache
./docker/build.sh -t ${{ github.sha }} --no-cache

# Run unit tests in the Docker container
unit-tests:
runs-on: ubuntu-latest
# Ensure Docker image is built before running tests
needs: docker-build
steps:
- name: Run Unit Tests
run: |
# Execute tests using the previously built Docker image
./docker/run.sh -t ${{ github.sha }} --unittest
docker build -f docker/Dockerfile --target test -t plantdb-test:${{ github.sha }} .

# Cleanup Docker resources after tests complete
docker-clean:
runs-on: ubuntu-latest
# Run after tests complete, regardless of test outcome
needs: unit-tests
if: always()
steps:
- name: Remove Docker Image
# Clean up
- name: Remove Docker image
if: always()
run: |
# Remove any unused containers
docker container prune -f
# Force remove the image created for this workflow run
docker image rm roboticsmicrofarms/plantdb:${{ github.sha }} --force
docker image rm plantdb-test:${{ github.sha }} --force
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ The `plantdb` packages are available through:

To create a new conda environment for PlantDB:
``` shell
conda create -n plantdb 'python=3.10' ipython
conda create -n plantdb 'python<3.13' ipython
```

## Installation
Expand Down Expand Up @@ -191,7 +191,7 @@ import os

db_path = os.environ['ROMI_DB']
# Use it to connect to DB:
from plantdb.commons.fsdb import FSDB
from plantdb.commons.fsdb.core import FSDB

db = FSDB(db_path)
db.connect()
Expand Down
35 changes: 26 additions & 9 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ ENV PYTHONUNBUFFERED=1
ENV PATH="/root/.local/bin:${PATH}"

# Install build dependencies
RUN apt-get update && \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && \
apt-get install -yq --no-install-recommends \
# Install python3.10 & pip
python3 python3-pip python3-dev \
Expand All @@ -27,11 +29,13 @@ COPY src/commons commons/
COPY src/server server/

# Build uwsgi & Python packages
RUN python3 -m pip install --no-cache-dir --user \
RUN --mount=type=cache,target=/root/.cache/pip \
python3 -m pip install --no-cache-dir --user \
wheel setuptools pip --upgrade && \
python3 -m pip install --no-cache-dir --user \
uwsgi \
commons/.[io] \
open3d \
server/. && \
# Remove pip cache and unnecessary files
python3 -m pip cache purge
Expand All @@ -40,23 +44,33 @@ RUN python3 -m pip install --no-cache-dir --user \
FROM builder AS test

# Update package manager & install requirements:
RUN apt-get update && \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && \
apt-get install -yq --no-install-recommends \
# Install Open3D system dependencies
libegl1 libgl1 libgomp1

COPY src/client client/

# Install test dependencies
RUN echo "\n\n# Installing 'plantdb.commons' test dependencies..." && \
RUN --mount=type=cache,target=/root/.cache/pip \
echo "\n\n# Installing 'plantdb.commons' test dependencies..." && \
python3 -m pip install --no-cache-dir --user \
commons/[test] && \
echo "\n\n# Installing 'plantdb.server' test dependencies..." && \
python3 -m pip install --no-cache-dir --user \
server/[test]
server/[test] && \
echo "\n\n# Installing 'plantdb.client' test dependencies..." && \
python3 -m pip install --no-cache-dir --user \
client/[test]
# Run tests
RUN echo "\n\n# Running 'plantdb.commons' tests..." && \
nose2 -v -s commons/tests/ && \
echo "\n\n# Running 'plantdb.commons' tests..." && \
nose2 -v -s server/tests/
echo "\n\n# Running 'plantdb.server' tests..." && \
nose2 -v -s server/tests/ && \
echo "\n\n# Running 'plantdb.client' tests..." && \
nose2 -v -s client/tests/

# ============= Final stage =============
FROM ubuntu:22.04 AS runtime
Expand Down Expand Up @@ -91,7 +105,9 @@ ENV ROMI_DB="/myapp/db"
SHELL ["/bin/bash", "-c"]

# Update package manager & install requirements:
RUN apt-get update && \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && \
apt-get install -yq --no-install-recommends \
# Install curl to performs healthcheck
curl \
Expand Down Expand Up @@ -127,7 +143,8 @@ WORKDIR /home/${USER_NAME}
# Copy Python packages from builder (including uwsgi)
COPY --chown=${USER_NAME} --from=builder /root/.local /home/${USER_NAME}/.local

RUN echo "\n\n# Installing 'plantdb.commons', 'plantdb.server' & uwsgi..." && \
RUN --mount=type=cache,target=/root/.cache/pip \
echo "\n\n# Installing 'plantdb.commons', 'plantdb.server' & uwsgi..." && \
python3 -m pip install --no-cache-dir --user plantdb.commons plantdb.server uwsgi && \
# Clean pip cache:
python3 -m pip cache purge && \
Expand Down
80 changes: 56 additions & 24 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

#!/bin/bash

# --------------------------------
# ------------------------------------------
# Functions for colors and messages
# --------------------------------
# ------------------------------------------
setup_colors() {
RED="\033[0;31m" # Define red color code
GREEN="\033[0;32m" # Define green color code
Expand Down Expand Up @@ -38,9 +37,9 @@ log_debug() {
fi
}

# --------------------------------
# ------------------------------------------
# Functions for script initialization
# --------------------------------
# ------------------------------------------
initialize_variables() {
# Image tag to use, 'latest' by default:
vtag="latest"
Expand All @@ -54,6 +53,8 @@ initialize_variables() {
DEBUG_MODE=false
# Production mode is disabled by default
PRODUCTION_MODE=false
# Unit‑test mode is disabled by default
UNITTEST_MODE=false

# If the `ROMI_DB` variable is set, use it as default database location, else set it to empty:
if [ -z ${ROMI_DB+x} ]; then
Expand All @@ -63,9 +64,9 @@ initialize_variables() {
fi
}

# --------------------------------
# ------------------------------------------
# Usage information function
# --------------------------------
# ------------------------------------------
show_usage() {
echo -e "$(bold USAGE):"
echo " ./docker/run.sh [OPTIONS]"
Expand Down Expand Up @@ -93,13 +94,15 @@ show_usage() {
# -- Debug option:
echo " --debug
Enable debug mode to print additional debug information."
echo " --unittest
Run all unit tests in src/server/tests, src/commons/tests and src/client/tests and exit."
echo " -h, --help
Output a usage message and exit."
}

# --------------------------------
# ------------------------------------------
# Command line parsing function
# --------------------------------
# ------------------------------------------
parse_arguments() {
while [ "$1" != "" ]; do
case $1 in
Expand Down Expand Up @@ -132,6 +135,9 @@ parse_arguments() {
DEBUG_MODE=true
log_debug "Debug mode enabled!"
;;
--unittest)
UNITTEST_MODE=true
;;
-h | --help)
show_usage
exit 0
Expand All @@ -145,9 +151,31 @@ parse_arguments() {
done
}

# --------------------------------
# ------------------------------------------
# Unit‑test helper
# ------------------------------------------
run_unittests() {
log_info "Running unit tests for src/server/tests, src/commons/tests and src/client/tests"
# Use python -m unittest discover for each test directory
for test_dir in src/server/tests src/commons/tests src/client/tests; do
if [ -d "$test_dir" ]; then
log_info "Discovering tests in $test_dir"
python -m unittest discover -s "$test_dir"
test_status=$?
if [ $test_status -ne 0 ]; then
log_error "Tests failed in $test_dir (status $test_status)"
exit $test_status
fi
else
log_warning "Test directory $test_dir does not exist, skipping."
fi
done
log_info "All tests passed successfully."
}

# ------------------------------------------
# Database setup functions
# --------------------------------
# ------------------------------------------
check_database_environment() {
if [ -z ${ROMI_DB+x} ] ; then
log_warning "Environment variable 'ROMI_DB' is not defined, set it to use as default database location!"
Expand Down Expand Up @@ -177,9 +205,9 @@ setup_user_group() {
fi
}

# --------------------------------
# ------------------------------------------
# Check if netstat is available
# --------------------------------
# ------------------------------------------
check_netstat_installed() {
if ! command -v netstat &> /dev/null; then
log_warning "netstat command not found. This is required to find available ports."
Expand All @@ -190,9 +218,9 @@ check_netstat_installed() {
return 0
}

# --------------------------------
# ------------------------------------------
# Port finder function
# --------------------------------
# ------------------------------------------
find_available_port() {
if [ ${port_specified} -eq 0 ]; then
log_info "Finding available port in range 5000-5100..."
Expand Down Expand Up @@ -226,9 +254,9 @@ find_available_port() {
fi
}

# --------------------------------
# ------------------------------------------
# Terminal handling function
# --------------------------------
# ------------------------------------------
check_terminal() {
if [ -t 1 ]; then
USE_TTY="-t"
Expand All @@ -237,9 +265,9 @@ check_terminal() {
fi
}

# --------------------------------
# ------------------------------------------
# Docker run functions
# --------------------------------
# ------------------------------------------
create_docker_run_cmd() {
# Base docker run command
docker_cmd="docker run"
Expand Down Expand Up @@ -271,7 +299,7 @@ create_docker_run_cmd() {
if [ "$1" = "development" ]; then
docker_cmd+=" \"fsdb_rest_api --port 5000\""
elif [ "$1" = "production" ]; then
# Run uWSGI to serve the application on port 5000.
# Run uWSGI to serve the application on port 5000.
docker_cmd+=" \"uwsgi --http :5000 --module plantdb.server.cli.wsgi:application --callable application --master\""
elif [ "$1" = "command" ]; then
docker_cmd+=" \"${cmd}\""
Expand Down Expand Up @@ -329,7 +357,7 @@ run_docker_command() {
# Print the full command that will be executed
log_debug "Executing command: ${docker_cmd}"

# Get the date to estimate command execution time:
# Get date to estimate command execution time:
start_time=$(date +%s)

# Execute the docker run command
Expand All @@ -349,14 +377,18 @@ run_docker_command() {
exit ${cmd_status}
}


# --------------------------------
# ------------------------------------------
# Main script execution
# --------------------------------
# ------------------------------------------
main() {
setup_colors
initialize_variables
parse_arguments "$@"

if [ "${UNITTEST_MODE}" = true ]; then
run_unittests
exit 0
fi
check_database_environment
setup_database_mount
setup_user_group
Expand Down
Loading