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

Migrate to python3.13 and poetry #8

Merged
merged 5 commits into from
Jan 14, 2025
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
31 changes: 22 additions & 9 deletions .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,31 @@ jobs:
with:
lfs: 'true'

- name: Set up Python 3.12
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pipenv"
cache-dependency-path: |
Pipfile.lock
python-version: "3.13"

- name: Install pipenv and deps
run: |
python -m pip install --upgrade pipenv wheel
make deps
- name: Install and configure Poetry
uses: snok/install-poetry@v1
with:
version: 2.0.1
virtualenvs-create: true
virtualenvs-in-project: true

- name: Set up cache
uses: actions/cache@v3
id: cached-poetry-dependencies
with:
path: .venv
key: venv-${{ runner.os }}-python-3.13-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'

- name: Lint source code
run: make lint

- name: Run tests
run: make test
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.12
3.13
28 changes: 16 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ====================
# Build Neurobro Agent
# ====================
# =====================
# Build Python Template
# =====================

FROM python:3.12-slim
FROM python:3.13-slim
WORKDIR /src

ENV LANG=C.UTF-8
Expand All @@ -14,12 +14,18 @@ ENV PYTHONFAULTHANDLER=1
# Install system packages
# -----------------------

RUN apt-get update && apt-get install -y
curl \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/*

# Install poetry
RUN curl -sSL https://install.python-poetry.org | python3 -

RUN pip install pipenv
# Add Poetry to PATH
ENV PATH="/root/.local/bin:$PATH"

# Configure Poetry
RUN poetry config virtualenvs.create false

# -------------------------
# Create the logs directory
Expand All @@ -31,10 +37,9 @@ RUN mkdir logs
# Setup the environment
# ---------------------

COPY Pipfile .
COPY Pipfile.lock .
COPY pyproject.toml poetry.lock ./

RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
RUN poetry install --no-interaction --no-ansi --no-root

# ----------------------
# Runtime
Expand All @@ -43,7 +48,6 @@ RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy
COPY . /src

COPY entrypoint.sh /src/entrypoint.sh

RUN chmod +x /src/entrypoint.sh

# Command to run the application
Expand Down
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ help:
@echo " deps Install all dependencies"
@echo " format Format source code"
@echo " lint Run lint checks"
@echo " test Run tests"

.PHONY: deps
deps:
pipenv install --dev
poetry install --with dev

.PHONY: format
format: \
Expand All @@ -21,11 +22,11 @@ format: \

.PHONY: format-ruff
format-ruff:
pipenv run ruff format --line-length 100 $(DIRS_PYTHON)
poetry run ruff format --line-length 100 $(DIRS_PYTHON)

.PHONY: format-isort
format-isort:
pipenv run isort --profile=black --line-length 100 $(DIRS_PYTHON)
poetry run isort --profile=black --line-length 100 $(DIRS_PYTHON)

.PHONY: lint
lint: \
Expand All @@ -35,15 +36,23 @@ lint: \

.PHONY: lint-ruff
lint-ruff:
pipenv run ruff check --line-length 100 $(DIRS_PYTHON)
poetry run ruff check --line-length 100 $(DIRS_PYTHON)

.PHONY: lint-isort
lint-isort:
pipenv run isort --profile=black --line-length 100 --check-only --diff $(DIRS_PYTHON)
poetry run isort --profile=black --line-length 100 --check-only --diff $(DIRS_PYTHON)

.PHONY: lint-mypy
lint-mypy:
pipenv run mypy --check-untyped-defs $(DIRS_PYTHON)
poetry run mypy --check-untyped-defs $(DIRS_PYTHON)

.PHONY: test
test:
poetry run pytest tests/ -v

# .PHONY: dev
# dev:
# poetry run uvicorn src.main:app --reload --host 0.0.0.0 --port 8000

# .PHONY: jupyternotebook
# jupyternotebook:
Expand Down
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

Loading
Loading