Skip to content

Commit

Permalink
Merge pull request #704 from arXiv/develop
Browse files Browse the repository at this point in the history
Dockerfile and arxiv-base db changes
  • Loading branch information
bdc34 authored Aug 20, 2024
2 parents 2c28a0d + 2629db3 commit 1cc6207
Show file tree
Hide file tree
Showing 15 changed files with 695 additions and 574 deletions.
24 changes: 7 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
# UIs for browse.

FROM python:3.11.8-bookworm
RUN apt-get update && apt-get -y upgrade

ARG git_commit
# Do not update+upgrade. The base image is kept up to date. Also destroys
# ability to cache.

ARG git_commit

ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
Expand All @@ -16,14 +17,11 @@ ENV PYTHONFAULTHANDLER=1 \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.3.2 \
TRACE=1 \
LC_ALL=en_US.utf8 \
LANG=en_US.utf8 \
APP_HOME=/app
LANG=en_US.utf8

WORKDIR /app


RUN apt-get -y install default-libmysqlclient-dev

ENV VIRTUAL_ENV=/opt/venv
Expand All @@ -33,30 +31,22 @@ RUN pip install -U pip "poetry==$POETRY_VERSION"

COPY poetry.lock pyproject.toml ./
RUN poetry config virtualenvs.create false && \
poetry install --no-interaction --no-ansi

RUN pip install "gunicorn==20.1.0"
poetry install --no-interaction --no-ansi \
--without dev

ADD app.py /app/

ENV PATH "/app:${PATH}"

ADD browse /app/browse
ADD tests /app/tests
ADD wsgi.py /app/

RUN echo $git_commit > /git-commit.txt

EXPOSE 8080
ENV LC_ALL en_US.utf8
ENV LANG en_US.utf8
ENV LOGLEVEL 40
ENV FLASK_DEBUG 1
ENV FLASK_APP /opt/arxiv/app.py

RUN useradd e-prints
RUN chown e-prints:e-prints /app/tests/data/
RUN chmod 775 /app/tests/data/
USER e-prints

# Why is this command in an env var and not just run in CMD? So it can be used
Expand All @@ -67,4 +57,4 @@ ENV GUNICORN gunicorn --bind :8080 \
--workers 4 --threads 8 --timeout 0 \
"browse.factory:create_web_app()"

CMD exec $GUNICORN
CMD exec $GUNICORN
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
pytest tests
```
### Settinp up pytest in PyCharm
### Setting up pytest in PyCharm
![docs/development/pycharm-run-setting.png](docs/development/pycharm-pytest.png)
Expand Down
4 changes: 2 additions & 2 deletions browse/commands/check_paper_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import click

from arxiv.identifier import Identifier
from arxiv.db import session
from arxiv.db import Session
from arxiv.db.models import Metadata
from browse.services.dissemination import get_article_store, ArticleStore
from arxiv.formats import formats_from_source_flag
Expand All @@ -19,7 +19,7 @@
@click.argument("yymm")
def check_paper_formats(yymm: str) -> None:
"""Checks formats for yymm."""
query = (session.query(Metadata.paper_id, Metadata.version,
query = (Session.query(Metadata.paper_id, Metadata.version,
Metadata.source_format,
Metadata.source_flags, Metadata.source_size)
.filter(or_(Metadata.paper_id.like(f"%/{yymm}%"),
Expand Down
4 changes: 2 additions & 2 deletions browse/commands/invalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from google.cloud import compute_v1
from sqlalchemy.orm import scoped_session

from arxiv.db import session
from arxiv.db import Session
from arxiv.db.models import NextMail

bp = Blueprint("invalidate", __name__)
Expand Down Expand Up @@ -42,7 +42,7 @@ def invalidate_mailings(project: str, cdn: str, mailings: List[str], dry_run: bo
for mailing in mailings:
if v:
print(f"About to query for {mailing}")
papers = (session.query(NextMail.paper_id, NextMail.version)
papers = (Session.query(NextMail.paper_id, NextMail.version)
.filter(NextMail.mail_id == int(mailing)))

nn = 0
Expand Down
10 changes: 4 additions & 6 deletions browse/controllers/stats_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ def get_hourly_stats_page(business_tz: str, requested_date_str: Optional[str] =
response_data['requested_dt'] = requested_dt
except (TypeError, ValueError) as ex:
raise BadRequest from ex
try:
normal_count, admin_count, num_nodes = get_hourly_stats_count(
stats_date=requested_dt.date()
)
except Exception as ex:
raise InternalServerError from ex

normal_count, admin_count, num_nodes = get_hourly_stats_count(
stats_date=requested_dt.date()
)

response_data["normal_count"] = normal_count
response_data["admin_count"] = admin_count
Expand Down
3 changes: 1 addition & 2 deletions browse/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from arxiv.base import Base
from arxiv.base.urls import canonical_url, urlizer
from arxiv.base.filters import tidy_filesize
from arxiv.db import config_query_timing
from arxiv.db.models import configure_db
from arxiv.db import config_query_timing, configure_db
from flask import Flask
from flask_s3 import FlaskS3
# This gives the error on import
Expand Down
Loading

0 comments on commit 1cc6207

Please sign in to comment.