Skip to content

Commit

Permalink
Convert project to poetry (#6423)
Browse files Browse the repository at this point in the history
* poetry init

* add all dependencies

* update pyproject.toml

* add poetry.lock

* remove requirements txt fixer

* add ldap3 group and make all groups optional

* remove requirements files

* convert dockerfile to use poetry instead of pip

* fix ldap 3 dependency group typo

* update ldap3 inline error

* update cypress to install only main poetry group

* convert test_all_deps

* update redis/rq

* don't create virtualenv

* add -dev suffix and make version snapshot work

* fix typo in snapshot commit message

* remove importlib-resources
  • Loading branch information
guidopetri authored Sep 8, 2023
1 parent b1f738f commit c97afeb
Show file tree
Hide file tree
Showing 12 changed files with 5,060 additions and 160 deletions.
3 changes: 1 addition & 2 deletions .ci/docker-compose.cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ x-redash-service: &redash-service
build:
context: ../
args:
skip_dev_deps: "true"
skip_ds_deps: "true"
install_groups: "main"
code_coverage: ${CODE_COVERAGE}
x-redash-environment: &redash-environment
REDASH_LOG_LEVEL: "INFO"
Expand Down
2 changes: 1 addition & 1 deletion .ci/docker_build
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DOCKERHUB_REPO="redash/redash"
DOCKER_TAGS="-t redash/redash:preview -t redash/preview:${VERSION_TAG}"

# Build the docker container
docker build --build-arg test_all_deps=true ${DOCKER_TAGS} .
docker build --build-arg install_groups="main,all_ds,dev" ${DOCKER_TAGS} .

# Push the container to the preview build locations
docker push "${DOCKERHUB_REPO}:preview"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Build Docker Images
run: |
set -x
docker-compose build --build-arg test_all_deps=true --build-arg skip_frontend_build=true
docker-compose build --build-arg install_groups="main,all_ds,dev" --build-arg skip_frontend_build=true
docker-compose up -d
sleep 10
- name: Create Test Database
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/periodic-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ jobs:
date="$(date +%y.%m).0-dev"
gawk -i inplace -F: -v q=\" -v tag=$date '/^ "version": / { print $1 FS, q tag q ","; next} { print }' package.json
gawk -i inplace -F= -v q=\" -v tag=$date '/^__version__ =/ { print $1 FS, q tag q; next} { print }' redash/__init__.py
gawk -i inplace -F= -v q=\" -v tag=$date '/^version =/ { print $1 FS, q tag q; next} { print }' pyproject.toml
git config user.name github-actions
git config user.email [email protected]
git add package.json redash/__init__.py
git commit -m "Shapshot: ${date}"
git add package.json redash/__init__.py pyproject.toml
git commit -m "Snapshot: ${date}"
git push origin
git tag $date
git push origin $date
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ repos:
hooks:
- id: flake8
exclude: "migration/.*|.git|viz-lib|node_modules|migrations|bin/upgrade"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: requirements-txt-fixer
33 changes: 10 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ FROM python:3.8-slim-buster

EXPOSE 5000

# Controls whether to install extra dependencies needed for all data sources.
ARG skip_ds_deps
# Controls whether to install dev dependencies.
ARG skip_dev_deps
# Controls whether to install all dependencies for testing.
ARG test_all_deps

RUN useradd --create-home redash

# Ubuntu packages
Expand Down Expand Up @@ -85,24 +78,18 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \

WORKDIR /app

# Disable PIP Cache and Version Check
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
ENV PIP_NO_CACHE_DIR=1

RUN pip install pip==23.1.2;

# We first copy only the requirements file, to avoid rebuilding on every file change.
COPY requirements_all_ds.txt ./
RUN if [ "x$skip_ds_deps" = "x" ] ; then cat requirements_all_ds.txt | sed -e '/^\s*#.*$/d' -e '/^\s*$/d' | xargs -n 1 pip install || true ; else echo "Skipping pip install -r requirements_all_ds.txt" ; fi


COPY requirements_dev.txt ./
RUN if [ "x$skip_dev_deps" = "x" ] ; then pip install -r requirements_dev.txt ; fi
ENV POETRY_VERSION=1.6.1
ENV POETRY_HOME=/etc/poetry
ENV POETRY_VIRTUALENVS_CREATE=false
RUN curl -sSL https://install.python-poetry.org | python3 -

COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY pyproject.toml poetry.lock ./

RUN if [ "x$test_all_deps" != "x" ] ; then pip3 install -r requirements.txt -r requirements_dev.txt -r requirements_all_ds.txt ; fi
ARG POETRY_OPTIONS="--no-root --no-interaction --no-ansi"
# for LDAP authentication, install with `ldap3` group
# disabled by default due to GPL license conflict
ARG install_groups="main,all_ds,dev"
RUN /etc/poetry/bin/poetry install --only $install_groups $POETRY_OPTIONS

COPY --chown=redash . /app
COPY --from=frontend-builder --chown=redash /frontend/client/dist /app/client/dist
Expand Down
4,895 changes: 4,895 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,151 @@ multi_line_output = 3
include_trailing_comma = true
use_parentheses = true
skip = "migrations"

[tool.poetry]
name = "redash"
version = "23.09.0-dev"
description = "Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data."
authors = ["Your Name <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.8,<3.9"
advocate = "1.0.0"
aniso8601 = "8.0.0"
authlib = "0.15.5"
blinker = "1.6.2"
click = "8.1.3"
cryptography = "41.0.3"
disposable-email-domains = ">=0.0.52"
flask = "2.3.2"
flask-limiter = "3.3.1"
flask-login = "0.6.0"
flask-mail = "0.9.1"
flask-migrate = "2.5.2"
flask-restful = "0.3.10"
flask-sqlalchemy = "2.5.1"
flask-talisman = "0.7.0"
flask-wtf = "1.1.1"
funcy = "1.13"
gevent = "22.10.1"
greenlet = "1.1.3"
gunicorn = "20.0.4"
httplib2 = "0.19.0"
itsdangerous = "2.1.2"
jinja2 = "3.1.2"
jsonschema = "3.1.1"
markupsafe = "2.1.1"
maxminddb-geolite2 = "2018.703"
parsedatetime = "2.4"
passlib = "1.7.3"
psycopg2-binary = "2.9.6"
pyjwt = "2.4.0"
pyopenssl = "23.2.0"
pypd = "1.1.0"
pysaml2 = "7.3.1"
pystache = "0.6.0"
python-dateutil = "2.8.0"
python-dotenv = "0.19.2"
pytz = ">=2019.3"
pyyaml = "6.0.1"
redis = "4.6.0"
regex = "2023.8.8"
requests = "2.31.0"
restrictedpython = "6.2"
rq = "1.9.0"
rq-scheduler = "0.11.0"
semver = "2.8.1"
sentry-sdk = "1.28.1"
simplejson = "3.16.0"
sqlalchemy = "1.3.24"
sqlalchemy-searchable = "1.2.0"
sqlalchemy-utils = "0.34.2"
sqlparse = "0.4.4"
sshtunnel = "0.1.5"
statsd = "3.3.0"
supervisor = "4.1.0"
supervisor-checks = "0.8.1"
ua-parser = "0.18.0"
urllib3 = "1.26.16"
user-agents = "2.0"
werkzeug = "2.3.6"
wtforms = "2.2.1"
xlsxwriter = "1.2.2"

[tool.poetry.group.all_ds]
optional = true

[tool.poetry.group.all_ds.dependencies]
atsd-client = "3.0.5"
azure-kusto-data = "0.0.35"
boto3 = "1.28.8"
botocore = "1.31.8"
cassandra-driver = "3.21.0"
certifi = ">=2019.9.11"
cmem-cmempy = "21.2.3"
databend-py = "0.4.6"
databend-sqlalchemy = "0.2.4"
google-api-python-client = "1.7.11"
gspread = "3.1.0"
impyla = "0.16.0"
influxdb = "5.2.3"
memsql = "3.2.0"
mysqlclient = "2.1.1"
nzalchemy = "^11.0.2"
nzpy = ">=1.15"
oauth2client = "4.1.3"
openpyxl = "3.0.7"
oracledb = "1.4.0"
pandas = "1.3.4"
phoenixdb = "0.7"
pinotdb = ">=0.4.5"
protobuf = "3.18.3"
pyathena = ">=1.5.0,<=1.11.5"
pydgraph = "2.0.2"
pydruid = "0.5.7"
pyexasol = "0.12.0"
pygridgain = "1.4.0"
pyhive = "0.6.1"
pyignite = "0.6.1"
pymongo = {version = "4.3.3", extras = ["srv", "tls"]}
pymssql = "2.2.8"
pyodbc = "4.0.28"
python-arango = "6.1.0"
python-rapidjson = "1.1.0"
qds-sdk = ">=1.9.6"
requests-aws-sign = "0.1.5"
sasl = ">=0.1.3"
simple-salesforce = "0.74.3"
snowflake-connector-python = "3.1.0"
td-client = "1.0.0"
thrift = ">=0.8.0"
thrift-sasl = ">=0.1.0"
trino = ">=0.305,<1.0"
vertica-python = "1.1.1"
xlrd = "2.0.1"

[tool.poetry.group.ldap3]
optional = true

[tool.poetry.group.ldap3.dependencies]
ldap3 = "2.2.4"

[tool.poetry.group.dev]
optional = true

[tool.poetry.group.dev.dependencies]
pytest = "7.4.0"
coverage = "7.2.7"
freezegun = "1.2.1"
jwcrypto = "1.5.0"
mock = "5.0.2"
pre-commit = "3.3.3"
ptpython = "3.0.23"
ptvsd = "4.3.2"
pytest-cov = "4.1.0"
watchdog = "3.0.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion redash/authentication/ldap_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
except ImportError:
if settings.LDAP_LOGIN_ENABLED:
sys.exit(
"The ldap3 library was not found. This is required to use LDAP authentication (see requirements.txt)."
"The ldap3 library was not found. This is required to use LDAP authentication. Rebuild the Docker image installing the `ldap3` poetry dependency group."
)

from redash.authentication import (
Expand Down
64 changes: 0 additions & 64 deletions requirements.txt

This file was deleted.

52 changes: 0 additions & 52 deletions requirements_all_ds.txt

This file was deleted.

10 changes: 0 additions & 10 deletions requirements_dev.txt

This file was deleted.

0 comments on commit c97afeb

Please sign in to comment.