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

Feature/SK-1265 | Implement SQL store #785

Merged
merged 74 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
2710e6e
added graphql server
niklastheman Dec 20, 2024
bab877e
sessions added
niklastheman Dec 20, 2024
9c4ad30
get single session
niklastheman Dec 20, 2024
0fe3cfd
added models
niklastheman Dec 20, 2024
a29f0a1
added validations
niklastheman Dec 20, 2024
750cf3a
statuses added
niklastheman Dec 20, 2024
6dcb6af
added plura/singular naming to follow convention
niklastheman Dec 20, 2024
0e596dc
added abstract parent class, Store along with MongoDBStore
niklastheman Dec 23, 2024
9271df6
removed use_typings option
niklastheman Dec 23, 2024
e55ad72
clean up
niklastheman Dec 23, 2024
b069844
merged SK-1109
niklastheman Dec 23, 2024
0ec6d6c
removed use_typings, changes to complie with feature/SK-1109
niklastheman Dec 23, 2024
4ebb1eb
started on replacing mongostatestore
niklastheman Dec 27, 2024
eaf75c0
removed get_combiners from mongostatestore and started using combiner…
niklastheman Dec 27, 2024
08f8583
removed add/delete combiner from network and mongostatestore
niklastheman Dec 28, 2024
fab412a
moved get and list clients from mongostatestore
niklastheman Dec 28, 2024
328217b
update sessions with session_store
niklastheman Dec 30, 2024
5a5303f
removed set_session_status from mongostatestore
niklastheman Dec 30, 2024
1ac6880
added round_store to combiner
niklastheman Dec 30, 2024
9d9bfa8
clean up
niklastheman Dec 30, 2024
010528f
upload model moved to api/v1/models
niklastheman Dec 30, 2024
d0df714
removed get model
niklastheman Dec 30, 2024
70fc83d
moved add client to api/v1/clients/add
niklastheman Dec 30, 2024
d542140
moved download package to api/v1/packages/download
niklastheman Dec 30, 2024
a1ac5b1
moved get checksum to api/v1/packages/checksum
niklastheman Dec 30, 2024
839bf39
removed old client and old package runtime class
niklastheman Dec 30, 2024
db14426
mongostatestore dependecy to control removed and repository dependecy…
niklastheman Dec 30, 2024
57ba8d1
get_client_config moved to api/v1/clients/config
niklastheman Jan 1, 2025
5fdc75c
removed API (interface) class
niklastheman Jan 1, 2025
64fdd83
added indexes to mogno stores
niklastheman Jan 1, 2025
392c4ad
removed mongostatestore completely
niklastheman Jan 1, 2025
d8d28f0
removed old api tests
niklastheman Jan 1, 2025
6824cf8
deprecate old endpoint
niklastheman Jan 1, 2025
c02703b
Added sqlalchemy and used sql for storing package info
niklastheman Jan 2, 2025
c5fdaa9
added where clause to list packages
niklastheman Jan 2, 2025
df1ac2a
package sql store v1
niklastheman Jan 2, 2025
1ddeaa0
added count to package sql store
niklastheman Jan 2, 2025
da59555
fixed some typings
niklastheman Jan 2, 2025
4481245
added sql session store
niklastheman Jan 3, 2025
878fc1b
session sql store v1
niklastheman Jan 3, 2025
f71d10c
added count to session sql store
niklastheman Jan 3, 2025
62b8a4c
started on models sql store
niklastheman Jan 3, 2025
a47616a
sql model store works for training
niklastheman Jan 5, 2025
14fb7d0
added ancestors and descendants to sql models store and thus model st…
niklastheman Jan 6, 2025
9ea7304
added postgres
niklastheman Jan 6, 2025
2df0655
started on rounds sql store
niklastheman Jan 6, 2025
caa1add
added sql round store
niklastheman Jan 8, 2025
6a6b283
added get_latest_round_id to round store
niklastheman Jan 8, 2025
420e12f
added session and model id as foregin keys in round config model
niklastheman Jan 8, 2025
420f347
added status store
niklastheman Jan 8, 2025
099ff2e
added validations sql store
niklastheman Jan 8, 2025
dbf3f5a
added client store
niklastheman Jan 8, 2025
fd1c34b
started on prediction store
niklastheman Jan 8, 2025
633d7cf
prediction store v1
niklastheman Jan 8, 2025
51c463c
create sql tables only if sql stores
niklastheman Jan 8, 2025
6920404
linting fix
niklastheman Jan 8, 2025
34a5818
sqllite postgres or mongo based on env:s. moved table creation to cot…
niklastheman Jan 9, 2025
a7d7e08
implemented connected_client_count for client sql store
niklastheman Jan 9, 2025
361d967
clean up
niklastheman Jan 9, 2025
b8f89b7
client_store update should be like every other update
niklastheman Jan 9, 2025
669c154
run table creation script from combiner to fix timing issue
niklastheman Jan 9, 2025
fdc77d9
merge of master
niklastheman Jan 10, 2025
ab7eafc
removed debug logging
niklastheman Jan 10, 2025
6816327
This SQL query depends on a user-provided value fix.
niklastheman Jan 10, 2025
d734c55
ruff linting fix#
niklastheman Jan 10, 2025
72bff6a
api client should use api/v1
niklastheman Jan 13, 2025
1de8855
should be able to upload package without name and description
niklastheman Jan 13, 2025
8dd9a5b
Api client, set_active_model fix
niklastheman Jan 14, 2025
ac8b46f
fixed set_active_model for sql mode
niklastheman Jan 14, 2025
31fa959
set_active_package fix
niklastheman Jan 15, 2025
223e4bf
fixed client.start_session()
niklastheman Jan 15, 2025
23f70cb
add comment with supported DBs
Wrede Jan 15, 2025
d7d270e
default db should still be mongo
niklastheman Jan 16, 2025
e7fefe2
remove postgres from main compose file
Wrede Jan 20, 2025
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
54 changes: 54 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Base image
ARG BASE_IMG=python:3.10-slim
FROM $BASE_IMG

ARG GRPC_HEALTH_PROBE_VERSION=""

# Requirements (use MNIST Keras as default)
ARG REQUIREMENTS=""

# Add FEDn and default configs
COPY . /app
COPY config/settings-client.yaml.template /app/config/settings-client.yaml
COPY config/settings-combiner.yaml.template /app/config/settings-combiner.yaml
COPY config/settings-hooks.yaml.template /app/config/settings-hooks.yaml
COPY config/settings-reducer.yaml.template /app/config/settings-reducer.yaml
COPY $REQUIREMENTS /app/config/requirements.txt

# Install developer tools (needed for psutil)
RUN apt-get update && apt-get install -y python3-dev gcc

# Install grpc health probe checker
RUN if [ ! -z "$GRPC_HEALTH_PROBE_VERSION" ]; then \
apt-get install -y wget && \
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
chmod +x /bin/grpc_health_probe && \
apt-get remove -y wget && apt autoremove -y; \
else \
echo "No grpc_health_probe version specified, skipping installation"; \
fi

# Setup working directory
WORKDIR /app

# Create FEDn app directory
SHELL ["/bin/bash", "-c"]
RUN mkdir -p /app \
&& mkdir -p /app/client \
&& mkdir -p /app/certs \
&& mkdir -p /app/client/package \
&& mkdir -p /app/certs \
#
# Install FEDn and requirements
&& python -m venv /venv \
&& /venv/bin/pip install --upgrade pip \
&& /venv/bin/pip install --no-cache-dir 'setuptools>=65' \
&& /venv/bin/pip install --no-cache-dir -e . \
&& if [[ ! -z "$REQUIREMENTS" ]]; then \
/venv/bin/pip install --no-cache-dir -r /app/config/requirements.txt; \
fi \
#
# Clean up
&& rm -r /app/config/requirements.txt

ENTRYPOINT [ "/venv/bin/fedn" ]
7 changes: 6 additions & 1 deletion config/settings-combiner.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ statestore:
password: password
host: mongo
port: 6534

postgres_config:
username: fedn_admin
password: password
host: fedn_postgres
port: 5432

storage:
storage_type: S3
storage_config:
Expand Down
5 changes: 5 additions & 0 deletions config/settings-reducer.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ statestore:
password: password
host: mongo
port: 6534
postgres_config:
username: fedn_admin
password: password
host: fedn_postgres
port: 5432

storage:
storage_type: S3
Expand Down
173 changes: 173 additions & 0 deletions docker-compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
# Compose schema version
version: '3.4'

# Setup network
networks:
default:
name: fedn_default

services:
# Base services
minio:
image: minio/minio:14128-5ee91dc
hostname: minio
environment:
- GET_HOSTS_FROM=dns
- MINIO_HOST=minio
- MINIO_PORT=9000
- MINIO_ROOT_USER=fedn_admin
- MINIO_ROOT_PASSWORD=password
command: server /data --console-address minio:9001
healthcheck:
test: [ "CMD", "curl", "-f", "http://minio:9000/minio/health/live" ]
interval: 30s
timeout: 20s
retries: 3
ports:
- 9000:9000
- 9001:9001

mongo:
image: mongo:7.0
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=fedn_admin
- MONGO_INITDB_ROOT_PASSWORD=password
ports:
- 6534:6534
command: mongod --port 6534

mongo-express:
image: mongo-express:latest
restart: always
depends_on:
- "mongo"
environment:
- ME_CONFIG_MONGODB_SERVER=mongo
- ME_CONFIG_MONGODB_PORT=6534
- ME_CONFIG_MONGODB_ADMINUSERNAME=fedn_admin
- ME_CONFIG_MONGODB_ADMINPASSWORD=password
- ME_CONFIG_BASICAUTH_USERNAME=fedn_admin
- ME_CONFIG_BASICAUTH_PASSWORD=password
ports:
- 8081:8081

fedn_postgres:
image: postgres:15
environment:
POSTGRES_USER: fedn_admin
POSTGRES_PASSWORD: password
POSTGRES_DB: fedn_db
ports:
- "5432:5432"

api-server:
environment:
- GET_HOSTS_FROM=dns
- USER=test
- PROJECT=project
- FLASK_DEBUG=1
- STATESTORE_CONFIG=/app/config/settings-reducer.yaml.template
- MODELSTORAGE_CONFIG=/app/config/settings-reducer.yaml.template
- FEDN_COMPUTE_PACKAGE_DIR=/app
- TMPDIR=/app/tmp
build:
context: .
dockerfile: Dockerfile.dev
args:
BASE_IMG: ${BASE_IMG:-python:3.12-slim}
working_dir: /app
volumes:
- ${HOST_REPO_DIR:-.}/fedn:/app/fedn
depends_on:
- minio
- mongo
- fedn_postgres
command:
- controller
- start
ports:
- 8092:8092

# Combiner
combiner:
environment:
- PYTHONUNBUFFERED=0
- GET_HOSTS_FROM=dns
- STATESTORE_CONFIG=/app/config/settings-combiner.yaml.template
- MODELSTORAGE_CONFIG=/app/config/settings-combiner.yaml.template
- HOOK_SERVICE_HOST=hook:12081
- TMPDIR=/app/tmp
build:
context: .
dockerfile: Dockerfile.dev
args:
BASE_IMG: ${BASE_IMG:-python:3.12-slim}
GRPC_HEALTH_PROBE_VERSION: v0.4.35
working_dir: /app
volumes:
- ${HOST_REPO_DIR:-.}/fedn:/app/fedn
command:
- combiner
- start
- --init
- config/settings-combiner.yaml.template
ports:
- 12080:12080
healthcheck:
test: [ "CMD", "/app/grpc_health_probe", "-addr=localhost:12080" ]
interval: 20s
timeout: 10s
retries: 5
depends_on:
- api-server
- hooks
# Hooks
hooks:
container_name: hook
environment:
- GET_HOSTS_FROM=dns
- TMPDIR=/app/tmp
build:
context: .
dockerfile: Dockerfile.dev
args:
BASE_IMG: ${BASE_IMG:-python:3.12-slim}
GRPC_HEALTH_PROBE_VERSION: v0.4.35
working_dir: /app
volumes:
- ${HOST_REPO_DIR:-.}/fedn:/app/fedn
entrypoint: [ "sh", "-c" ]
command:
- "/venv/bin/pip install --no-cache-dir -e . && /venv/bin/fedn hooks start"
ports:
- 12081:12081
healthcheck:
test: [ "CMD", "/bin/grpc_health_probe", "-addr=localhost:12081" ]
interval: 20s
timeout: 10s
retries: 5

# Client
client:
environment:
- GET_HOSTS_FROM=dns
- FEDN_PACKAGE_EXTRACT_DIR=package
build:
context: .
dockerfile: Dockerfile.dev
args:
BASE_IMG: ${BASE_IMG:-python:3.10-slim}
working_dir: /app
volumes:
- ${HOST_REPO_DIR:-.}/fedn:/app/fedn
command:
- client
- start
- --api-url
- http://api-server:8092
deploy:
replicas: 0
depends_on:
combiner:
condition: service_healthy
10 changes: 10 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ services:
- ME_CONFIG_BASICAUTH_PASSWORD=password
ports:
- 8081:8081

fedn_postgres:
image: postgres:15
environment:
POSTGRES_USER: fedn_admin
POSTGRES_PASSWORD: password
POSTGRES_DB: fedn_db
ports:
- "5432:5432"

api-server:
environment:
Expand All @@ -72,6 +81,7 @@ services:
depends_on:
- minio
- mongo
- fedn_postgres
command:
- controller
- start
Expand Down
Loading
Loading