-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from factly/fix/memory-issue-test-1
Fix/memory issue test 1
- Loading branch information
Showing
31 changed files
with
3,548 additions
and
1,947 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
files: app/ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 22.3.0 | ||
hooks: | ||
- id: black | ||
language_version: python3 | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 4.0.1 | ||
rev: 7.0.0 | ||
hooks: | ||
- id: flake8 | ||
- repo: https://github.com/timothycrosley/isort | ||
rev: 5.9.3 | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,19 @@ | ||
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9 | ||
FROM python:3.9.16-buster | ||
|
||
WORKDIR /app | ||
|
||
ENV POETRY_VERSION=1.2.0 | ||
|
||
# Install Poetry | ||
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \ | ||
RUN curl -sSL https://install.python-poetry.org/ | POETRY_HOME=/opt/poetry python && \ | ||
cd /usr/local/bin && \ | ||
ln -s /opt/poetry/bin/poetry && \ | ||
poetry config experimental.new-installer false && \ | ||
poetry config virtualenvs.create false | ||
|
||
# Copy poetry.lock* in case it doesn't exist in the repo | ||
COPY ./pyproject.toml ./poetry.lock* / | ||
COPY ./pyproject.toml ./poetry.lock* / | ||
|
||
# Allow installing dev dependencies to run tests | ||
ARG INSTALL_DEV=false | ||
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi" | ||
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --only main ; fi" | ||
|
||
COPY . . | ||
ENV PYTHONPATH=/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9 | ||
FROM python:3.9.16-buster | ||
|
||
WORKDIR /app | ||
|
||
ENV POETRY_VERSION=1.2.0 | ||
ENV POETRY_VERSION=1.5.1 | ||
|
||
# Install Poetry | ||
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/opt/poetry python && \ | ||
cd /usr/local/bin && \ | ||
ln -s /opt/poetry/bin/poetry && \ | ||
poetry config experimental.new-installer false && \ | ||
export PATH="/opt/poetry/bin:$PATH" && \ | ||
poetry config virtualenvs.create false | ||
|
||
# Copy poetry.lock* in case it doesn't exist in the repo | ||
COPY ./pyproject.toml ./poetry.lock* / | ||
|
||
# Allow installing dev dependencies to run tests | ||
ARG INSTALL_DEV=false | ||
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then poetry install --no-root ; else poetry install --no-root --no-dev ; fi" | ||
RUN bash -c "if [ $INSTALL_DEV == 'true' ] ; then /opt/poetry/bin/poetry install --no-root ; else /opt/poetry/bin/poetry install --no-root --no-dev ; fi" | ||
|
||
COPY . . | ||
ENV PYTHONPATH=/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
FROM python:3.10-slim-buster as requirements-stage | ||
|
||
WORKDIR /tmp | ||
RUN pip install poetry | ||
COPY ./pyproject.toml ./poetry.lock* /tmp/ | ||
|
||
RUN mkdir -p /tmp/app | ||
COPY ./app /tmp/app | ||
|
||
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes | ||
|
||
|
||
FROM python:3.10-slim-buster | ||
|
||
WORKDIR /code | ||
|
||
COPY --from=requirements-stage /tmp/requirements.txt /code/requirements.txt | ||
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | ||
|
||
COPY --from=requirements-stage /tmp/app /code/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import logging | ||
import logging.config | ||
import os | ||
|
||
from app.core.config import Settings | ||
|
||
settings = Settings() | ||
|
||
# Create the logs directory if it doesn't exist | ||
log_directory = os.path.dirname(settings.LOG_FILE_PATH) | ||
if not os.path.exists(log_directory): | ||
os.makedirs(log_directory) | ||
|
||
# Configuration dictionary for logging | ||
LOGGING_CONFIG = { | ||
"version": 1, | ||
"disable_existing_loggers": False, | ||
"formatters": { | ||
"default": { | ||
"format": "%(asctime)s [%(levelname)s] [%(name)s:%(lineno)d] - %(message)s", # noqa: E501 | ||
"datefmt": "%Y-%m-%d %H:%M:%S", | ||
}, | ||
}, | ||
"handlers": { | ||
"console": { | ||
"class": "rich.logging.RichHandler", | ||
"level": settings.LOG_LEVEL, | ||
}, | ||
}, | ||
"loggers": { | ||
"": { | ||
"level": settings.LOG_LEVEL, | ||
"handlers": ["console"], | ||
"propagate": True, | ||
}, | ||
"celery": { | ||
"level": settings.LOG_LEVEL, | ||
"handlers": ["console"], | ||
"propagate": True, | ||
}, | ||
}, | ||
} | ||
|
||
# Load the logging configuration | ||
logging.config.dictConfig(LOGGING_CONFIG) | ||
|
||
|
||
def get_logger(name: str) -> logging.Logger: | ||
""" | ||
Get a logger with the specified name. | ||
Args: | ||
name (str): The name of the logger. | ||
Returns: | ||
logging.Logger: The logger instance. | ||
""" | ||
return logging.getLogger(name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from __future__ import annotations | ||
|
||
from typing import List | ||
from typing import List, Optional | ||
|
||
from pydantic import BaseModel | ||
from pydantic import RootModel | ||
|
||
|
||
class Alerts(BaseModel): | ||
__root__: List[str] | ||
class Alerts(RootModel[Optional[List[str]]]): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
from datetime import datetime, timedelta | ||
from datetime import datetime | ||
from typing import Optional | ||
|
||
from pydantic.main import BaseModel | ||
|
||
|
||
class Analysis(BaseModel): | ||
title: str | ||
date_start: datetime | ||
date_end: datetime | ||
duration: timedelta | ||
title: Optional[str] | ||
date_start: Optional[datetime] | ||
date_end: Optional[datetime] | ||
|
||
class Config: | ||
underscore_attrs_are_private = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from typing import Union | ||
from typing import Any | ||
|
||
from pydantic import BaseModel, Json | ||
from pydantic import RootModel | ||
|
||
|
||
class Duplicates(BaseModel): | ||
__root__: Union[Json, str] | ||
class Duplicates(RootModel[Any]): | ||
pass |
Oops, something went wrong.