Skip to content

Commit

Permalink
feat: upgrade to python3.12 and remove requirements.txt files in favo…
Browse files Browse the repository at this point in the history
…ur of poetry
  • Loading branch information
guillaume-sig committed Dec 19, 2024
1 parent 2fcab4f commit 07e210b
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 1,678 deletions.
Binary file added .github/images/ci.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 13 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,20 @@ DOCKER_COMPOSE := $(shell which docker-compose > /dev/null 2>&1 && echo docker-c

# Development

install-poetry:
python3.10 -m pip install poetry -U

generate-lockfiles:
python3.10 -m poetry lock
python3.10 -m poetry export --with=api,dashboard,dev -f requirements.txt --without-hashes -o requirements.txt
python3.10 -m poetry export --with=api -f requirements.txt -o portfolio_analytics/api/requirements.txt
python3.10 -m poetry export --with=dashboard -f requirements.txt -o portfolio_analytics/dashboard/requirements.txt

install-deps:
python3.10 -m pip install -e . -r requirements.txt

fmt:
python3.10 -m autoflake --remove-all-unused-imports --remove-unused-variables --in-place --recursive $(codebase) $(tests_dir)
python3.10 -m isort --profile black --line-length 89 $(codebase) $(tests_dir)
python3.10 -m black --line-length 89 --preview --enable-unstable-feature=string_processing $(codebase) $(tests_dir)
python3.10 -m ruff check --fix $(codebase) $(tests_dir)
python3.12 -m autoflake --remove-all-unused-imports --remove-unused-variables --in-place --recursive $(codebase) $(tests_dir)
python3.12 -m isort --profile black --line-length 89 $(codebase) $(tests_dir)
python3.12 -m black --line-length 89 --preview --enable-unstable-feature=string_processing $(codebase) $(tests_dir)
python3.12 -m ruff check --fix $(codebase) $(tests_dir)2

lint:
python3.10 -m autoflake --check --quiet --recursive $(codebase)
python3.10 -m isort --profile black --line-length 89 --check-only $(codebase)
python3.10 -m black --line-length 89 --check $(codebase)
python3.10 -m ruff check $(codebase)
python3.10 -m mypy $(codebase)
python3.10 -m flake8 --max-line-length 89 --max-doc-length 89 $(codebase)
python3.10 -m pylint --fail-under=9.9 $(codebase)
python3.12 -m autoflake --check --quiet --recursive $(codebase)
python3.12 -m isort --profile black --line-length 89 --check-only $(codebase)
python3.12 -m black --line-length 89 --check $(codebase)
python3.12 -m ruff check $(codebase)
python3.12 -m mypy $(codebase)
python3.12 -m flake8 --max-line-length 89 --max-doc-length 89 $(codebase)
python3.12 -m pylint --fail-under=9.9 $(codebase)

clean:
find . -type f \( -name "*.pyc" -o -name ".DS_Store" -o -name "coverage.xml" \) -delete
Expand All @@ -41,10 +29,10 @@ clean:
# Unit Testing

test:
python3.10 -m pytest --cov=$(codebase) -m "not integration" --cov-report html --cov-report xml
python3.12 -m pytest --cov=$(codebase) -m "not integration" --cov-report html --cov-report xml

test-coverage: test
cd htmlcov && python3.10 -m http.server
cd htmlcov && python3.12 -m http.server


# Docker build
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Portfolio Analytics

[![CI/CD](https://github.com/gbourniq/portfolio-analytics/actions/workflows/ci.yml/badge.svg)](https://github.com/gbourniq/portfolio-analytics/actions/workflows/ci.yml)
[![Python Version](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/)
[![Python Version](https://img.shields.io/badge/python-3.12-blue.svg)](https://www.python.org/downloads/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Pylint Score](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/gbourniq/b149841cbef1088a8bf7671efee16734/raw/pylint.txt)](https://github.com/gbourniq/portfolio-analytics/actions)
[![Code Coverage](https://codecov.io/gh/gbourniq/portfolio-analytics/graph/badge.svg?token=O5LIL4YV9L)](https://codecov.io/gh/gbourniq/portfolio-analytics)
Expand Down Expand Up @@ -55,7 +55,8 @@ make up
1. Install dependencies:

```bash
python3.10 -m pip install -e . -r requirements.txt
python3.12 -m pip install poetry -U
poetry install
```

2. Start services:
Expand All @@ -65,6 +66,10 @@ python portfolio_analytics/dashboard/dashboard_main.py
python portfolio_analytics/api/api_main.py
```

### CI

![CI](.github/images/ci.png)

## Future Improvements

### Data Pipeline
Expand Down
11 changes: 5 additions & 6 deletions api.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
FROM python:3.10-slim
FROM python:3.12-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPATH=/app/portfolio_analytics

# Add labels
LABEL maintainer="[email protected]" \
version="1.0" \
description="Portfolio Analytics API"

# Install curl for healthcheck
Expand All @@ -19,11 +17,12 @@ RUN groupadd -r appuser && useradd -r -g appuser appuser
WORKDIR /app

# Install dependencies
COPY portfolio_analytics/api/requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
COPY pyproject.toml ./pyproject.toml
RUN python3.12 -m pip install poetry==1.8.5 && \
poetry config virtualenvs.create false && \
poetry install --with=api

# Copy source code to the container
COPY pyproject.toml ./pyproject.toml
COPY portfolio_analytics/common/utils portfolio_analytics/common/utils
COPY portfolio_analytics/api portfolio_analytics/api

Expand Down
10 changes: 5 additions & 5 deletions dashboard.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-slim
FROM python:3.12-slim

# Set environment variables
ENV PYTHONUNBUFFERED=1 \
Expand All @@ -7,7 +7,6 @@ ENV PYTHONUNBUFFERED=1 \

# Add labels
LABEL maintainer="[email protected]" \
version="1.0" \
description="Portfolio Analytics Dashboard"

# Install curl for healthcheck
Expand All @@ -19,11 +18,12 @@ RUN groupadd -r appuser && useradd -r -g appuser appuser
WORKDIR /app

# Install dependencies
COPY portfolio_analytics/dashboard/requirements.txt ./requirements.txt
RUN pip install -r requirements.txt
COPY pyproject.toml ./pyproject.toml
RUN python3.12 -m pip install poetry==1.8.5 && \
poetry config virtualenvs.create false && \
poetry install --with=dashboard

# Copy source code to the container
COPY pyproject.toml ./pyproject.toml
COPY portfolio_analytics/common/utils portfolio_analytics/common/utils
COPY portfolio_analytics/dashboard portfolio_analytics/dashboard

Expand Down
85 changes: 0 additions & 85 deletions docs/HINTS.md

This file was deleted.

64 changes: 0 additions & 64 deletions docs/TASK.md

This file was deleted.

Loading

0 comments on commit 07e210b

Please sign in to comment.