Skip to content

Commit

Permalink
Update requirements and Dockerfile to fix issues (#414)
Browse files Browse the repository at this point in the history
with Docker build.
- remove Pandas
- remove psycopg2
- update typing-extensions for Pydantic
  • Loading branch information
DMalone87 authored Nov 4, 2024
1 parent d1cb0d3 commit b49b4b3
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 105 deletions.
14 changes: 13 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
FROM python:3-slim-bookworm AS base

RUN apt-get update && apt-get install curl -y && apt-get install g++ libpq-dev gcc python3-dev -y
# Install dependencies
RUN apt-get update -y && apt-get install -y \
curl \
g++ \
libpq-dev \
gcc \
python3-dev \
libffi-dev

# Install Rust
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"


ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.12.1/wait /wait
RUN chmod +x /wait
Expand Down
2 changes: 1 addition & 1 deletion backend/database/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flake8: noqa: F401
from backend.database.core import db_cli, execute_query
from backend.database.core import db_cli

# Neo4j / NeoModel related imports
from neomodel import config as neo_config
Expand Down
10 changes: 4 additions & 6 deletions backend/database/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from typing import Optional

import click
import pandas as pd
from flask import current_app
from flask.cli import AppGroup, with_appcontext
from werkzeug.utils import secure_filename
from neomodel import install_all_labels
from neo4j import Driver
from typing import List, Dict, Any

from ..utils import dev_only

Expand All @@ -23,10 +23,10 @@
)


def execute_query(filename: str) -> Optional[pd.DataFrame]:
def execute_query(filename: str) -> Optional[List[Dict[str, Any]]]:
"""Run a Cypher query from a file using the provided Neo4j connection.
It returns a Pandas DataFrame if the query yields results; otherwise,
It returns a list of dictionaries if the query yields results; otherwise,
it returns None.
"""
# Read the query from the file
Expand All @@ -45,9 +45,7 @@ def execute_query(filename: str) -> Optional[pd.DataFrame]:
if records:
# Convert Neo4j records to a list of dictionaries
data = [record.data() for record in records]
# Create a DataFrame
df = pd.DataFrame(data)
return df
return data
else:
return None

Expand Down
3 changes: 1 addition & 2 deletions requirements/_core.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ celery
flake8
flask
gunicorn
pandas>=2.2.2
pip-tools
pydantic==2.9.2
typing-extensions>=4.12.2 # Required for pydantic
pytest
pytest-env
pytest-cov
Expand All @@ -32,6 +32,5 @@ jupyter
mixpanel
ua-parser
ujson
testcontainers
neo4j
neomodel==5.3.3
4 changes: 1 addition & 3 deletions requirements/dev_unix.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
-r _core.in
psycopg2-binary
psycopg-binary
-r _core.in
34 changes: 5 additions & 29 deletions requirements/dev_unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ anyio==4.3.0
# via
# httpx
# jupyter-server
appnope==0.1.4
# via ipykernel
argon2-cffi==23.1.0
# via jupyter-server
argon2-cffi-bindings==21.2.0
Expand Down Expand Up @@ -94,8 +92,6 @@ defusedxml==0.7.1
# via nbconvert
dnspython==2.6.1
# via email-validator
docker==7.1.0
# via testcontainers
email-validator==2.1.1
# via -r requirements/_core.in
et-xmlfile==1.1.0
Expand Down Expand Up @@ -280,9 +276,7 @@ notebook-shim==0.2.4
# jupyterlab
# notebook
numpy==1.26.4
# via
# -r requirements/_core.in
# pandas
# via -r requirements/_core.in
openpyxl==3.0.9
# via -r requirements/_core.in
overrides==7.7.0
Expand All @@ -300,8 +294,6 @@ packaging==24.0
# pytest
# qtconsole
# qtpy
pandas==2.2.2
# via -r requirements/_core.in
pandocfilters==1.5.1
# via nbconvert
parso==0.8.3
Expand Down Expand Up @@ -329,10 +321,6 @@ prompt-toolkit==3.0.43
# jupyter-console
psutil==5.9.8
# via ipykernel
psycopg-binary==3.1.18
# via -r requirements/dev_unix.in
psycopg2-binary==2.9.9
# via -r requirements/dev_unix.in
ptyprocess==0.7.0
# via
# pexpect
Expand Down Expand Up @@ -381,15 +369,12 @@ python-dateutil==2.9.0
# botocore
# celery
# jupyter-client
# pandas
python-dotenv==1.0.1
# via -r requirements/_core.in
python-json-logger==2.0.7
# via jupyter-events
pytz==2024.1
# via
# neo4j
# pandas
# via neo4j
pyyaml==6.0.1
# via
# -r requirements/_core.in
Expand All @@ -413,7 +398,6 @@ referencing==0.34.0
requests==2.32.3
# via
# -r requirements/_core.in
# docker
# jupyterlab-server
# mixpanel
rfc3339-validator==0.1.4
Expand Down Expand Up @@ -455,8 +439,6 @@ terminado==0.18.1
# via
# jupyter-server
# jupyter-server-terminals
testcontainers==4.8.1
# via -r requirements/_core.in
tinycss2==1.2.1
# via nbconvert
tornado==6.4
Expand Down Expand Up @@ -486,15 +468,13 @@ traitlets==5.14.2
# qtconsole
types-python-dateutil==2.9.0.20240316
# via arrow
typing-extensions==4.10.0
typing-extensions==4.12.2
# via
# -r requirements/_core.in
# pydantic
# pydantic-core
# testcontainers
tzdata==2024.1
# via
# celery
# pandas
# via celery
ua-parser==0.18.0
# via -r requirements/_core.in
ujson==5.10.0
Expand All @@ -504,10 +484,8 @@ uri-template==1.3.0
urllib3==1.26.18
# via
# botocore
# docker
# mixpanel
# requests
# testcontainers
vine==5.1.0
# via
# amqp
Expand All @@ -531,8 +509,6 @@ wheel==0.43.0
# via pip-tools
widgetsnbextension==4.0.10
# via ipywidgets
wrapt==1.16.0
# via testcontainers
wtforms==2.3.3
# via
# -r requirements/_core.in
Expand Down
2 changes: 0 additions & 2 deletions requirements/dev_windows.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
-r _core.in
psycopg2
psycopg
35 changes: 5 additions & 30 deletions requirements/dev_windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ anyio==4.3.0
# via
# httpx
# jupyter-server
appnope==0.1.4
# via ipykernel
argon2-cffi==23.1.0
# via jupyter-server
argon2-cffi-bindings==21.2.0
Expand Down Expand Up @@ -94,8 +92,6 @@ defusedxml==0.7.1
# via nbconvert
dnspython==2.6.1
# via email-validator
docker==7.1.0
# via testcontainers
email-validator==2.1.1
# via -r requirements/_core.in
et-xmlfile==1.1.0
Expand Down Expand Up @@ -280,9 +276,7 @@ notebook-shim==0.2.4
# jupyterlab
# notebook
numpy==1.26.4
# via
# -r requirements/_core.in
# pandas
# via -r requirements/_core.in
openpyxl==3.0.9
# via -r requirements/_core.in
overrides==7.7.0
Expand All @@ -300,8 +294,6 @@ packaging==24.0
# pytest
# qtconsole
# qtpy
pandas==2.2.2
# via -r requirements/_core.in
pandocfilters==1.5.1
# via nbconvert
parso==0.8.3
Expand Down Expand Up @@ -329,10 +321,6 @@ prompt-toolkit==3.0.43
# jupyter-console
psutil==5.9.8
# via ipykernel
psycopg==3.1.18
# via -r requirements/dev_windows.in
psycopg2==2.9.9
# via -r requirements/dev_windows.in
ptyprocess==0.7.0
# via
# pexpect
Expand Down Expand Up @@ -381,15 +369,12 @@ python-dateutil==2.9.0
# botocore
# celery
# jupyter-client
# pandas
python-dotenv==1.0.1
# via -r requirements/_core.in
python-json-logger==2.0.7
# via jupyter-events
pytz==2024.1
# via
# neo4j
# pandas
# via neo4j
pyyaml==6.0.1
# via
# -r requirements/_core.in
Expand All @@ -413,7 +398,6 @@ referencing==0.34.0
requests==2.32.3
# via
# -r requirements/_core.in
# docker
# jupyterlab-server
# mixpanel
rfc3339-validator==0.1.4
Expand Down Expand Up @@ -455,8 +439,6 @@ terminado==0.18.1
# via
# jupyter-server
# jupyter-server-terminals
testcontainers==4.8.1
# via -r requirements/_core.in
tinycss2==1.2.1
# via nbconvert
tornado==6.4
Expand Down Expand Up @@ -486,16 +468,13 @@ traitlets==5.14.2
# qtconsole
types-python-dateutil==2.9.0.20240316
# via arrow
typing-extensions==4.10.0
typing-extensions==4.12.2
# via
# psycopg
# -r requirements/_core.in
# pydantic
# pydantic-core
# testcontainers
tzdata==2024.1
# via
# celery
# pandas
# via celery
ua-parser==0.18.0
# via -r requirements/_core.in
ujson==5.10.0
Expand All @@ -505,10 +484,8 @@ uri-template==1.3.0
urllib3==1.26.18
# via
# botocore
# docker
# mixpanel
# requests
# testcontainers
vine==5.1.0
# via
# amqp
Expand All @@ -532,8 +509,6 @@ wheel==0.43.0
# via pip-tools
widgetsnbextension==4.0.10
# via ipywidgets
wrapt==1.16.0
# via testcontainers
wtforms==2.3.3
# via
# -r requirements/_core.in
Expand Down
2 changes: 0 additions & 2 deletions requirements/prod.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
-r _core.in
psycopg2-binary==2.9.9
psycopg-binary==3.1.18
Loading

0 comments on commit b49b4b3

Please sign in to comment.