From 169db54df23d1c8f13513696e5ca9dec2ac90106 Mon Sep 17 00:00:00 2001 From: Heiko Joerg Schick Date: Thu, 7 Sep 2023 16:02:09 +0200 Subject: [PATCH] Added query string as configurable (Docker) environment variable --- Dockerfile | 2 ++ arxiv_daemon.py | 6 +++++- compose.yaml | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index e20bc8c..af81d5b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,8 @@ ENV PYTHONDONTWRITEBYTECODE=1 # the application crashes without emitting any logs due to buffering. ENV PYTHONUNBUFFERED=1 +ENV ARXIV_QUERY="" + # Install required binary packages. RUN apt-get update && apt-get install -y \ imagemagick \ diff --git a/arxiv_daemon.py b/arxiv_daemon.py index 4239e79..3509d14 100644 --- a/arxiv_daemon.py +++ b/arxiv_daemon.py @@ -9,6 +9,7 @@ import time import random import logging import argparse +import os from aslite.arxiv import get_response, parse_response from aslite.db import get_papers_db, get_metas_db @@ -30,7 +31,10 @@ if __name__ == '__main__': """ # query string of papers to look for - q = 'cat:cs.CV+OR+cat:cs.LG+OR+cat:cs.CL+OR+cat:cs.AI+OR+cat:cs.NE+OR+cat:cs.RO+OR+cat:cs.AR+OR+cat:cs.DC' + q = os.environ.get('ARXIV_QUERY', '') + if not q: + print("No query string provided, will use default.") + q = 'cat:cs.CV+OR+cat:cs.LG+OR+cat:cs.CL+OR+cat:cs.AI+OR+cat:cs.NE+OR+cat:cs.RO+OR+cat:cs.AR+OR+cat:cs.DC' pdb = get_papers_db(flag='c') mdb = get_metas_db(flag='c') diff --git a/compose.yaml b/compose.yaml index 393dbee..7b58a41 100644 --- a/compose.yaml +++ b/compose.yaml @@ -16,7 +16,8 @@ services: volumes: - /Users/schihei/git/arxiv-sanity-lite/container-data/data/:/app/data - /Users/schihei/git/arxiv-sanity-lite/container-data/static/thumb/:/app/static/thumb - + environment: + - ARXIV_QUERY=cat:cs.CV+OR+cat:cs.LG+OR+cat:cs.CL+OR+cat:cs.AI+OR+cat:cs.NE+OR+cat:cs.RO+OR+cat:cs.AR+OR+cat:cs.DC # The commented out section below is an example of how to define a PostgreSQL # database that your application can use. `depends_on` tells Docker Compose to # start the database before your application. The `db-data` volume persists the @@ -49,4 +50,3 @@ services: # secrets: # db-password: # file: db/password.txt -