Skip to content

Commit

Permalink
Merge pull request #111 from offspot/upgrade_deps
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 authored Feb 5, 2024
2 parents d7c534c + 3991de0 commit ad94ab3
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 128 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ repos:
- --config
- frontend/.eslintrc.cjs
- repo: https://github.com/psf/black
rev: "23.12.1"
rev: "24.1.1"
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.2.0
hooks:
- id: ruff
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.345
rev: v1.1.349
hooks:
- id: pyright
name: pyright (system)
Expand Down
22 changes: 12 additions & 10 deletions backend/dev_tools/synthetic_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ class AggKindAndValue:


periods_in_db: list[int] = [] # store list of periods already injected in DB
dimensions_in_db: list[
IndicatorData
] = [] # store list of dimensions already injected in DB
dimensions_in_db: list[IndicatorData] = (
[]
) # store list of dimensions already injected in DB


def clear_db():
Expand Down Expand Up @@ -151,13 +151,15 @@ def scale_and_randomize_value(
factor = (
1
if agg_kind == AggKind.YEAR or agg_kind is None
else 12
if agg_kind == AggKind.MONTH
else 52
if agg_kind == AggKind.WEEK
else 365
if agg_kind == AggKind.DAY
else 0
else (
12
if agg_kind == AggKind.MONTH
else (
52
if agg_kind == AggKind.WEEK
else 365 if agg_kind == AggKind.DAY else 0
)
)
)

return max(
Expand Down
28 changes: 15 additions & 13 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ classifiers = [
]
dependencies = [
"alembic == 1.13.1",
"fastapi[all] == 0.108.0",
"fastapi[all] == 0.109.2",
"fastapi-pagination == 0.12.14",
"pydantic == 2.5.3", # this is also a sub-dep of fastapi but we rely a lot on it
"pydantic == 2.6.0", # this is also a sub-dep of fastapi but we rely a lot on it
"pyhumps==3.8.0",
"python-dateutil == 2.8.2",
"PyYAML == 6.0.1",
Expand All @@ -35,22 +35,22 @@ scripts = [
"invoke == 2.2.0",
]
lint = [
"black == 23.12.1",
"ruff == 0.1.11",
"black == 24.1.1",
"ruff == 0.2.0",
]
check = [
"pyright == 1.1.345",
"pyright == 1.1.349",
]
test = [
"coverage == 7.4.0",
"coverage == 7.4.1",
"httpx == 0.26.0",
"pytest == 7.4.4",
"pytest-asyncio == 0.23.3",
"pytest == 7.4.4", # 8.0.0 not yet available due to pytest-asyncio constraint <8
"pytest-asyncio == 0.23.4",
]
dev = [
"pre-commit == 3.6.0",
"debugpy == 1.8.0",
"ipykernel == 6.28.0",
"ipykernel == 6.29.0",
"offspot_metrics_backend[scripts]",
"offspot_metrics_backend[lint]",
"offspot_metrics_backend[test]",
Expand Down Expand Up @@ -113,6 +113,8 @@ target-version = ['py312']
target-version = "py312"
line-length = 88
src = ["src"]

[tool.ruff.lint]
select = [
"A", # flake8-builtins
# "ANN", # flake8-annotations
Expand Down Expand Up @@ -191,17 +193,17 @@ unfixable = [
"F401",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["offspot_metrics_backend"]

[tool.ruff.flake8-bugbear]
[tool.ruff.lint.flake8-bugbear]
# add exceptions to B008 for fastapi.
extend-immutable-calls = ["fastapi.Depends", "fastapi.Query"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]
# Synthetic data generator is using pseudo-random generator on purpose
Expand Down
29 changes: 18 additions & 11 deletions backend/src/offspot_metrics_backend/business/caddy_log_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,28 @@ def process(self, line: str) -> ProcessingResult:

ts = datetime.datetime.fromtimestamp(log.ts)
log_data = LogData(
content_type=log.resp_headers.content_type[0]
if log.resp_headers.content_type and len(log.resp_headers.content_type) > 0
else None,
content_type=(
log.resp_headers.content_type[0]
if log.resp_headers.content_type
and len(log.resp_headers.content_type) > 0
else None
),
status=log.status,
uri=log.request.uri,
method=log.request.method,
ts=ts,
x_tfm_files_added=int(log.resp_headers.x_tfm_files_added[0])
if log.resp_headers.x_tfm_files_added
and len(log.resp_headers.x_tfm_files_added) > 0
else None,
x_tfm_files_deleted=int(log.resp_headers.x_tfm_files_deleted[0])
if log.resp_headers.x_tfm_files_deleted
and len(log.resp_headers.x_tfm_files_deleted) > 0
else None,
x_tfm_files_added=(
int(log.resp_headers.x_tfm_files_added[0])
if log.resp_headers.x_tfm_files_added
and len(log.resp_headers.x_tfm_files_added) > 0
else None
),
x_tfm_files_deleted=(
int(log.resp_headers.x_tfm_files_deleted[0])
if log.resp_headers.x_tfm_files_deleted
and len(log.resp_headers.x_tfm_files_deleted) > 0
else None
),
)
inputs: list[Input] = []
for generator in self.generators:
Expand Down
8 changes: 4 additions & 4 deletions backend/src/offspot_metrics_backend/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class IndicatorDimension(Base):
It might have up to 3 values for now, meaning a 3 dimensional indicator"""

__tablename__ = "indicator_dimension"
id: Mapped[int] = mapped_column(init=False, primary_key=True) # noqa: A003
id: Mapped[int] = mapped_column(init=False, primary_key=True)
# only 3 dimension values are supported for now, this is supposed to be way enough
value0: Mapped[str | None] = mapped_column(index=True)
value1: Mapped[str | None]
Expand All @@ -161,7 +161,7 @@ class IndicatorRecord(Base):
"""

__tablename__ = "indicator_record"
id: Mapped[int] = mapped_column(init=False, primary_key=True) # noqa: A003
id: Mapped[int] = mapped_column(init=False, primary_key=True)
indicator_id: Mapped[int] = mapped_column(index=True)
value: Mapped[int]

Expand All @@ -188,7 +188,7 @@ class IndicatorState(Base):
"""

__tablename__ = "indicator_state"
id: Mapped[int] = mapped_column(init=False, primary_key=True) # noqa: A003
id: Mapped[int] = mapped_column(init=False, primary_key=True)
indicator_id: Mapped[int] = mapped_column(index=True)
state: Mapped[str]

Expand All @@ -213,7 +213,7 @@ class KpiRecord(Base):
The kind of aggregration is either D (day), W (week), M (month) or Y (year)"""

__tablename__ = "kpi"
id: Mapped[int] = mapped_column(init=False, primary_key=True) # noqa: A003
id: Mapped[int] = mapped_column(init=False, primary_key=True)
kpi_id: Mapped[int] = mapped_column(index=True)
agg_kind: Mapped[str]
agg_value: Mapped[str]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-07-24 09:52:15.031073
"""

import sqlalchemy as sa
from alembic import op

Expand Down
8 changes: 5 additions & 3 deletions backend/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def call_alembic(ctx: Context, cmd: str, *, test_db: bool = False):
f"alembic {cmd}",
pty=use_pty,
env={
"DATABASE_URL": os.getenv("TEST_DATABASE_URL")
if test_db
else os.getenv("DATABASE_URL")
"DATABASE_URL": (
os.getenv("TEST_DATABASE_URL")
if test_db
else os.getenv("DATABASE_URL")
)
},
)

Expand Down
16 changes: 8 additions & 8 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-regular-svg-icons": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
"@fortawesome/vue-fontawesome": "^3.0.5",
"@fortawesome/vue-fontawesome": "^3.0.6",
"apexcharts": "^3.45.2",
"axios": "^1.6.0",
"axios": "^1.6.7",
"pinia": "^2.1.4",
"vite-plugin-vuetify": "^2.0.1",
"vue": "^3.4.15",
"vue-router": "4",
"vue3-apexcharts": "^1.4.4",
"vuetify": "^3.5.1"
"vuetify": "^3.5.2"
},
"devDependencies": {
"@types/glob": "^8.1.0",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@vitejs/plugin-vue": "^5.0.3",
"@vue/eslint-config-prettier": "^9.0.0",
"@vue/eslint-config-standard": "^8.0.1",
Expand All @@ -34,9 +34,9 @@
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vue": "^9.20.1",
"marked": "^11.1.1",
"prettier": "^3.2.4",
"eslint-plugin-vue": "^9.21.1",
"marked": "^12.0.0",
"prettier": "^3.2.5",
"ts-node": "^10.9.1",
"typescript": "^5.3.3",
"vite": "^5.0.12",
Expand Down
Loading

0 comments on commit ad94ab3

Please sign in to comment.