Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
lotif committed May 8, 2024
2 parents e59e0e3 + efe2ca7 commit 5cd8abb
Show file tree
Hide file tree
Showing 44 changed files with 3,787 additions and 7,957 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/node_modules/**
**/.next/**
tsconfig.json
*.min.js
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
4 changes: 2 additions & 2 deletions .github/workflows/docs_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected].1
- uses: actions/[email protected].5
- name: Install dependencies, build docs and coverage report
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/setup-python@v5.0.0
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.9'
cache: 'poetry'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected].1
- uses: actions/[email protected].5
with:
submodules: 'true'
- name: Install dependencies, build docs and coverage report
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/setup-python@v5.0.0
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.9'
cache: 'poetry'
Expand Down
29 changes: 23 additions & 6 deletions .github/workflows/integration_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected].1
- uses: actions/[email protected].5
- name: Install poetry
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/setup-python@v5.0.0
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.9'
- name: Setup redis
uses: supercharge/redis-github-action@1.2.0
uses: supercharge/redis-github-action@1.8.0
with:
redis-version: 7.2.4
- name: Setup MongoDB
Expand All @@ -56,13 +56,30 @@ jobs:
source $(poetry env info --path)/bin/activate
poetry install --with docs,test
coverage run -m pytest florist/tests/integration && coverage xml && coverage report -m
# - name: Upload coverage to Codecov
# uses: Wandalen/[email protected]
- name: Upload python coverage to Codecov
uses: Wandalen/[email protected]
with:
action: codecov/[email protected]
with: |
token: ${{ secrets.CODECOV_TOKEN }}
name: codecov-umbrella
fail_ci_if_error: true
attempt_limit: 5
attempt_delay: 30000

# TODO enable this once we have integration tests for the UI
# - name: Setup yarn
# uses: mskelton/setup-yarn@v1
# - name: Install nextjs dependencies and check code
# run: |
# yarn
# yarn integration-test
# - name: Upload js coverage to Codecov
# uses: Wandalen/[email protected]
# with:
# action: codecov/[email protected]
# with: |
# token: ${{ secrets.CODECOV_TOKEN }}
# file: ./coverage.xml
# name: codecov-umbrella
# fail_ci_if_error: true
# attempt_limit: 5
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install libcurl4-openssl-dev libssl-dev
- uses: actions/[email protected].1
- uses: actions/[email protected].5
- name: Install poetry
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/setup-python@v5.0.0
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.9'
- name: Build package
run: poetry build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
7 changes: 5 additions & 2 deletions .github/workflows/static_code_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ jobs:
run-code-check:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected].1
- uses: actions/[email protected].5
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- uses: actions/setup-python@v5.0.0
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.9'
cache: 'poetry'
- name: Setup yarn
uses: mskelton/setup-yarn@v1
- name: Install dependencies and check code
run: |
yarn
poetry env use '3.9'
source .venv/bin/activate
poetry install --with test --all-extras
Expand Down
44 changes: 30 additions & 14 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,42 @@ jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected].1
- uses: actions/[email protected].5
- name: Install poetry
run: python3 -m pip install --upgrade pip && python3 -m pip install poetry
- uses: actions/setup-python@v5.0.0
- uses: actions/setup-python@v5.1.0
with:
python-version: '3.9'
- name: Install dependencies and check code
cache: 'poetry'
- name: Install python dependencies and check code
run: |
poetry env use '3.9'
source $(poetry env info --path)/bin/activate
poetry install --with docs,test
coverage run -m pytest florist/tests/unit && coverage xml && coverage report -m
# - name: Upload coverage to Codecov
# uses: Wandalen/[email protected]
# with:
# action: codecov/[email protected]
# with: |
# token: ${{ secrets.CODECOV_TOKEN }}
# file: ./coverage.xml
# name: codecov-umbrella
# fail_ci_if_error: true
# attempt_limit: 5
# attempt_delay: 30000
- name: Upload python coverage to Codecov
uses: Wandalen/[email protected]
with:
action: codecov/[email protected]
with: |
token: ${{ secrets.CODECOV_TOKEN }}
name: codecov-umbrella
fail_ci_if_error: true
attempt_limit: 5
attempt_delay: 30000
- name: Setup yarn
uses: mskelton/setup-yarn@v1
- name: Install nextjs dependencies and check code
run: |
yarn
yarn unit-test
- name: Upload js coverage to Codecov
uses: Wandalen/[email protected]
with:
action: codecov/[email protected]
with: |
token: ${{ secrets.CODECOV_TOKEN }}
name: codecov-umbrella
fail_ci_if_error: true
attempt_limit: 5
attempt_delay: 30000
59 changes: 54 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 # Use the ref you want to point at
rev: v4.6.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
- id: check-ast
Expand All @@ -15,8 +15,8 @@ repos:
- id: check-yaml
- id: check-toml

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.2.2'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.3'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -25,7 +25,7 @@ repos:
types_or: [python, jupyter]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.10.0
hooks:
- id: mypy
entry: python3 -m mypy --config-file pyproject.toml
Expand All @@ -34,15 +34,64 @@ repos:
exclude: "florist/tests/"

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.1
rev: 1.8.5
hooks:
- id: nbqa-ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: local
hooks:
- id: nextjs-lint
name: nextjs-lint
entry: yarn lint-gh-action florist
files: "florist/app"
language: system

- repo: local
hooks:
- id: prettier-js-format
name: prettier-js-format
entry: yarn prettier
files: "florist/app"
language: node
types: [javascript]
additional_dependencies:
- yarn
- prettier

- repo: local
hooks:
- id: doctest
name: doctest
entry: python3 -m doctest -o NORMALIZE_WHITESPACE
files: "(^florist/api/|florist/tests/api/)"
language: system

- repo: local
hooks:
- id: pytest-unit
name: pytest-unit
entry: python -m pytest florist/tests/unit
language: system
pass_filenames: false
always_run: true

- repo: local
hooks:
- id: nextjs-unit
name: nextjs-unit
entry: yarn unit-test
language: system
pass_filenames: false
always_run: true

ci:
autofix_commit_msg: |
[pre-commit.ci] Add auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [pytest-unit,nextjs-unit,doctest,mypy,nextjs-lint]
submodules: false
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
florist/app/assets/css/material-dashboard.css
*.min.js
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"tabWidth": 4
}
9 changes: 7 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ using [Homebrew](https://brew.sh/):
brew install yarn
```

Then install the project dependencies:
Then install the project dependencies in development mode:
```shell
yarn
```
Expand All @@ -55,11 +55,16 @@ yarn dev

## Running the tests

To run the unit tests, simply execute:
To run the python unit tests, simply execute:
```shell
pytest florist/tests/unit
```

To run the nextjs unit tests, simply execute:
```shell
yarn unit-test
```

To run the integration tests, first make sure you:
- Have a Redis server running on your local machine on port 6379 by following [these instructions](README.md#start-servers-redis-instance).
- Have a MongoDB server running on your local machine on port 27017 by following [these instructions](README.md#start-mongodbs-instance).
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ using [Homebrew](https://brew.sh/):
brew install yarn
```

Then install the project dependencies:
Then install the project dependencies in production mode:
```shell
yarn
yarn --prod
```

### Pulling Redis' Docker
Expand Down
1 change: 1 addition & 0 deletions florist/api/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""FLorist client FastAPI endpoints."""

import json
import logging
import uuid
Expand Down
1 change: 1 addition & 0 deletions florist/api/clients/common.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Common functions and definitions for clients."""

from enum import Enum
from typing import List

Expand Down
1 change: 1 addition & 0 deletions florist/api/clients/mnist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Implementation of the MNIST client and model."""

from typing import Tuple

import torch
Expand Down
3 changes: 2 additions & 1 deletion florist/api/db/entities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Definitions for the MongoDB database entities."""

import json
import uuid
from enum import Enum
Expand Down Expand Up @@ -95,7 +96,7 @@ class Config:
"server_info": '{"n_server_rounds": 3, "batch_size": 8}',
"redis_host": "localhost",
"redis_port": "6879",
"client_info": [
"clients_info": [
{
"client": "MNIST",
"service_address": "locahost:8081",
Expand Down
1 change: 1 addition & 0 deletions florist/api/launchers/local.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Launcher functions for local clients and servers."""

import logging
import sys
import time
Expand Down
1 change: 1 addition & 0 deletions florist/api/models/mnist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Definitions for the MNIST model."""

from typing import List

import torch
Expand Down
1 change: 1 addition & 0 deletions florist/api/monitoring/logs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""General functions and definitions for monitoring."""

from pathlib import Path


Expand Down
1 change: 1 addition & 0 deletions florist/api/monitoring/metrics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Classes for the instrumentation of metrics reporting from clients and servers."""

import json
import time
from logging import DEBUG, Logger
Expand Down
Loading

0 comments on commit 5cd8abb

Please sign in to comment.