Skip to content
Open
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
12 changes: 5 additions & 7 deletions .github/workflows/python_actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ jobs:
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v7
- uses: actions/setup-python@v5
with:
python-version: '3.8'
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade wheel setuptools==57 pip
pip install -r requirements.txt
pip install -r dev-requirements.txt

pip install ".[dev]"

- name: Run unittests
run: |
py.test
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
IMAGE_PROXY_RETRIES = 1 # Number of retries for failed upstream image requests (Cantaloupe cold-cache)
IMAGE_PROXY_RETRY_DELAY = 2 # Seconds to wait between retries

SQLALCHEMY_DATABASE_URI = 'postgres://scan_explorer:scan_explorer@postgres_service/scan_explorer_service'
SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://scan_explorer:scan_explorer@postgres_service/scan_explorer_service'
SQLALCHEMY_TRACK_MODIFICATIONS = False

OPEN_SEARCH_URL = 'http://opensearch-node1:9200'
Expand Down
5 changes: 0 additions & 5 deletions dev-requirements.txt

This file was deleted.

54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[project]
name = "scan_explorer_service"
version = "0.0.1"
description = "ADS Scan Explorer Service"
authors = [{ name = "ADS Team", email = "adshelp@cfa.harvard.edu" }]
license = { text = "MIT" }
readme = "README.md"
dependencies = [
"adsmutils @ git+https://github.com/adsabs/ADSMicroserviceUtils.git@v2.0.0",
"Flask-Limiter==3.8.0",
"Flask-Compress==1.24",
"iiif-prezi==0.3.0",
"SQLAlchemy-Utils==0.42.1",
"Jinja2==3.1.6",
"markupsafe==3.0.3",
"itsdangerous==2.2.0",
"werkzeug==2.3.8",
"psycopg2-binary==2.9.12",
"opensearch-py==3.2.0",
"alembic==1.19.1",
"img2pdf==0.6.3",
"appmap==3.0.1",
"boto3==1.43.67",
"redis==5.0.8"
]

[project.optional-dependencies]
dev = [
"Flask-Testing==0.8.1",
"testing.postgresql==1.3.0",
"pytest==9.1.1",
"pytest-cov==7.1.0",
"coverage==7.15.4"
]

[build-system]
requires = ["setuptools>=62.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
include = ["scan_explorer_service*"]
exclude = ["scan_explorer_service.tests*"]

[tool.pytest.ini_options]
addopts = "--cov=scan_explorer_service --cov-report=term-missing"
testpaths = ["scan_explorer_service/tests"]
pythonpath = ["."]

[tool.black]
line-length = 88
target-version = ['py312']

[tool.isort]
profile = "black"
17 changes: 0 additions & 17 deletions requirements.txt

This file was deleted.

3 changes: 1 addition & 2 deletions scan_explorer_service/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from flask import current_app
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, ForeignKey, Integer, String, Table, UniqueConstraint, Enum, Index, or_
from sqlalchemy.orm import relationship
from sqlalchemy.orm import declarative_base, relationship
from sqlalchemy_utils.models import Timestamp
from scan_explorer_service.utils.utils import url_for_proxy
import enum
Expand Down
4 changes: 2 additions & 2 deletions scan_explorer_service/tests/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,15 @@ def setUp(self):
def test_collection_serialized_no_pages(self):
"""S3: Collection.serialized returns thumbnail=None when no pages exist."""
with self.app.app_context():
col = self.app.db.session.query(Collection).get(self.collection_id)
col = self.app.db.session.get(Collection, self.collection_id)
data = col.serialized
self.assertIsNone(data['thumbnail'])
self.assertEqual(data['pages'], 0)

def test_article_serialized_no_pages(self):
"""S3: Article.serialized returns thumbnail=None when no pages exist."""
with self.app.app_context():
art = self.app.db.session.query(Article).get(self.article_id)
art = self.app.db.session.get(Article, self.article_id)
data = art.serialized
self.assertIsNone(data['thumbnail'])
self.assertEqual(data['pages'], 0)
Expand Down
4 changes: 2 additions & 2 deletions scan_explorer_service/utils/search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class OrderOptions(str, enum.Enum):

def parse_query_args(args):
"""Parse HTTP request args into a search query string, field dict, pagination, and sort order."""
qs = re.sub(':\s*', ':', args.get('q', '', str))
qs = re.sub(r':\s*', ':', args.get('q', '', str))
if not qs or not qs.strip():
raise ValueError('Query string is required')

Expand Down Expand Up @@ -88,7 +88,7 @@ def parse_query_string(qs):

check_query(qs_dict)
#Adds a () around each free search to force OS to look for each individual entry against all default fields
for parameter in re.split('\s+', qs_only_free):
for parameter in re.split(r'\s+', qs_only_free):
if parameter.upper() not in ['AND', 'OR', '']:
qs = qs.replace(str(parameter), "(" + str(parameter) + ")")

Expand Down
2 changes: 1 addition & 1 deletion scan_explorer_service/views/image_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def fetch_article(item, memory_limit):
return send_file(
file_stream,
as_attachment=True,
attachment_filename=object_name,
download_name=object_name,
mimetype='application/pdf'
)
except Exception as e:
Expand Down
Loading