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

Fix notebook report poetry #1853

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
62 changes: 58 additions & 4 deletions jobs/notebook-report/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,77 @@ ARG BUILD_DATE="missing"

ENV VCS_REF=${VCS_REF}
ENV BUILD_DATE=${BUILD_DATE}
ENV PORT=8080

LABEL org.label-schema.vcs-ref=${VCS_REF} \
org.label-schema.build-date=${BUILD_DATE}

USER root

LABEL maintainer="travissemple"
LABEL vendor="BCROS"

ARG APP_ENV \
# Needed for fixing permissions of files created by Docker:
UID=1000 \
GID=1000

ENV APP_ENV=${APP_ENV} \
# python:
PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PYTHONDONTWRITEBYTECODE=1 \
# pip:
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_DEFAULT_TIMEOUT=100 \
PIP_ROOT_USER_ACTION=ignore \
# poetry:
POETRY_VERSION=1.8.3 \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
POETRY_HOME='/usr/local'

SHELL ["/bin/bash", "-eo", "pipefail", "-c"]

RUN apt-get update && apt-get upgrade -y \
&& apt-get install --no-install-recommends -y \
bash \
brotli \
build-essential \
curl \
gettext \
git \
libpq-dev \
wait-for-it \
&& curl -sSL 'https://install.python-poetry.org' | python - \
&& poetry --version \
# Cleaning cache:
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# Create working directory
RUN mkdir /opt/app-root && chmod 755 /opt/app-root
RUN mkdir /opt/app-root/data && chmod 777 /opt/app-root/data
WORKDIR /opt/app-root

# Install the requirements
COPY ./requirements.txt .

RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
COPY ./poetry.lock .
COPY ./pyproject.toml .

# Project initialization:
RUN --mount=type=cache,target="$POETRY_CACHE_DIR" \
echo "$APP_ENV" \
&& poetry version \
&& poetry config installer.max-workers 1 \
# Install deps:
&& poetry run pip install -U pip \
&& poetry install \
$(if [ -z ${APP_ENV+x} ] | [ "$APP_ENV" = 'production' ]; then echo '--only main'; fi) \
--no-interaction --no-ansi

COPY . .

USER 1001
Expand Down
45 changes: 22 additions & 23 deletions jobs/notebook-report/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ license: ## Verify source code license headers.
#################################################################################
# COMMANDS -- Setup #
#################################################################################
setup: install install-dev ## Setup the project
setup: install ## Setup the project

clean: clean-build clean-pyc clean-test ## Clean the project
rm -rf venv/
Expand All @@ -42,39 +42,38 @@ clean-test: ## clean test files
rm -f .coverage
rm -fr htmlcov/

build-req: clean ## Upgrade requirements
test -f venv/bin/activate || python3.8 -m venv $(CURRENT_ABS_DIR)/venv ;\
. venv/bin/activate ;\
pip install --upgrade pip ;\
pip install -Ur requirements/prod.txt ;\
pip freeze | sort > requirements.txt

install: clean ## Install python virtrual environment
test -f venv/bin/activate || python3.8 -m venv $(CURRENT_ABS_DIR)/venv ;\
. venv/bin/activate ;\
pip install --upgrade pip ;\
pip install -Ur requirements.txt

install-dev: ## Install local application
. venv/bin/activate ; \
pip install -Ur requirements/dev.txt; \
pip install -e .
install: clean
pip install poetry ;\
poetry config installer.max-workers 1
poetry install

#################################################################################
# COMMANDS - CI #
#################################################################################
ci: pylint flake8 test ## CI flow
ci: isort-ci black-ci lint flake8 test ## CI flow

isort:
poetry run isort .

isort-ci:
poetry run isort --check .

black: ## Linting with black
poetry run black .

black-ci:
poetry run black --check .

pylint: ## Linting with pylint
. venv/bin/activate && pylint --rcfile=setup.cfg notebookreport.py
poetry run pylint notebookreport.py

flake8: ## Linting with flake8
. venv/bin/activate && flake8 notebookreport.py
poetry run flake8 notebookreport.py

lint: pylint flake8 ## run all lint type scripts
lint: isort black pylint flake8 ## run all lint type scripts

test: ## Unit testing
. venv/bin/activate && pytest
poetry run pytest

mac-cov: local-test ## Run the coverage report and display in a browser window (mac)
open -a "Google Chrome" htmlcov/index.html
Expand Down
45 changes: 23 additions & 22 deletions jobs/notebook-report/config.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
import os
from dotenv import load_dotenv, find_dotenv

from dotenv import find_dotenv, load_dotenv

# this will load all the envars from a .env file located in the project root (api)
load_dotenv(find_dotenv())


class Config(object):
PROJECT_ROOT = os.getcwd()
APP_FILE = os.getenv('APP_FILE', '')
SENDER_EMAIL = os.getenv('SENDER_EMAIL', '')
ERROR_EMAIL_RECIPIENTS = os.getenv('ERROR_EMAIL_RECIPIENTS', '')
DAILY_RECONCILIATION_RECIPIENTS = os.getenv('DAILY_RECONCILIATION_RECIPIENTS', '')
VS_DAILY_RECONCILIATION_RECIPIENTS = os.getenv('VS_DAILY_RECONCILIATION_RECIPIENTS', '')
CSO_DAILY_RECONCILIATION_RECIPIENTS = os.getenv('CSO_DAILY_RECONCILIATION_RECIPIENTS', '')
WEEKLY_PAY_RECIPIENTS = os.getenv('WEEKLY_PAY_RECIPIENTS', '')
MONTHLY_RECONCILIATION_RECIPIENTS = os.getenv('MONTHLY_RECONCILIATION_RECIPIENTS', '')
VS_MONTHLY_RECONCILIATION_RECIPIENTS = os.getenv('VS_MONTHLY_RECONCILIATION_RECIPIENTS', '')
CSO_MONTHLY_RECONCILIATION_RECIPIENTS = os.getenv('CSO_MONTHLY_RECONCILIATION_RECIPIENTS', '')
EMAIL_SMTP = os.getenv('EMAIL_SMTP', '')
ENVIRONMENT = os.getenv('ENVIRONMENT', '')
WEEKLY_REPORT_DATES = os.getenv('WEEKLY_REPORT_DATES', '[1]')
MONTHLY_REPORT_DATES = os.getenv('MONTHLY_REPORT_DATES', '[1]')
PARTNER_CODES = os.getenv('PARTNER_CODES', 'CSO,VS,RPT,ESRA')
APP_FILE = os.getenv("APP_FILE", "")
SENDER_EMAIL = os.getenv("SENDER_EMAIL", "")
ERROR_EMAIL_RECIPIENTS = os.getenv("ERROR_EMAIL_RECIPIENTS", "")
DAILY_RECONCILIATION_RECIPIENTS = os.getenv("DAILY_RECONCILIATION_RECIPIENTS", "")
VS_DAILY_RECONCILIATION_RECIPIENTS = os.getenv("VS_DAILY_RECONCILIATION_RECIPIENTS", "")
CSO_DAILY_RECONCILIATION_RECIPIENTS = os.getenv("CSO_DAILY_RECONCILIATION_RECIPIENTS", "")
WEEKLY_PAY_RECIPIENTS = os.getenv("WEEKLY_PAY_RECIPIENTS", "")
MONTHLY_RECONCILIATION_RECIPIENTS = os.getenv("MONTHLY_RECONCILIATION_RECIPIENTS", "")
VS_MONTHLY_RECONCILIATION_RECIPIENTS = os.getenv("VS_MONTHLY_RECONCILIATION_RECIPIENTS", "")
CSO_MONTHLY_RECONCILIATION_RECIPIENTS = os.getenv("CSO_MONTHLY_RECONCILIATION_RECIPIENTS", "")
EMAIL_SMTP = os.getenv("EMAIL_SMTP", "")
ENVIRONMENT = os.getenv("ENVIRONMENT", "")
WEEKLY_REPORT_DATES = os.getenv("WEEKLY_REPORT_DATES", "[1]")
MONTHLY_REPORT_DATES = os.getenv("MONTHLY_REPORT_DATES", "[1]")
PARTNER_CODES = os.getenv("PARTNER_CODES", "CSO,VS,RPT,ESRA")

# POSTGRESQL
PAY_USER = os.getenv('PAY_USER', '')
PAY_PASSWORD = os.getenv('PAY_PASSWORD', '')
PAY_DB_NAME = os.getenv('PAY_DB_NAME', '')
PAY_HOST = os.getenv('PAY_HOST', '')
PAY_PORT = os.getenv('PAY_PORT', '5432')
SQLALCHEMY_DATABASE_URI = 'postgresql://{user}:{password}@{host}:{port}/{name}'.format(
PAY_USER = os.getenv("PAY_USER", "")
PAY_PASSWORD = os.getenv("PAY_PASSWORD", "")
PAY_DB_NAME = os.getenv("PAY_DB_NAME", "")
PAY_HOST = os.getenv("PAY_HOST", "")
PAY_PORT = os.getenv("PAY_PORT", "5432")
SQLALCHEMY_DATABASE_URI = "postgresql://{user}:{password}@{host}:{port}/{name}".format(
user=PAY_USER,
password=PAY_PASSWORD,
host=PAY_HOST,
Expand Down
Loading