Skip to content

Commit

Permalink
Merge branch 'develop' into release/4.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
stchris committed Jan 10, 2025
2 parents 44e458a + 96c0492 commit 68fdb79
Show file tree
Hide file tree
Showing 52 changed files with 1,090 additions and 20,741 deletions.
38 changes: 18 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
FROM ubuntu:20.04
FROM python:3.9
ENV DEBIAN_FRONTEND noninteractive

# build-essential
RUN apt-get -qq -y update \
&& apt-get -qq --no-install-recommends -y install locales \
ca-certificates postgresql-client libpq-dev curl jq \
python3-pip python3-icu python3-psycopg2 \
python3-lxml python3-crypto git \
&& apt-get -qq -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
&& apt-get -qq --no-install-recommends -y install locales \
postgresql-client jq python3-dev \
&& apt-get -qq -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

ENV LANG='en_US.UTF-8'

RUN groupadd -g 1000 -r app \
&& useradd -m -u 1000 -s /bin/false -g app app
&& useradd -m -u 1000 -s /bin/false -g app app

# Install Python dependencies
RUN pip3 install --no-cache-dir -q -U pip setuptools six
Expand All @@ -32,19 +30,19 @@ RUN pip install --no-cache-dir -q -e /aleph
ENV ALEPH_WORD_FREQUENCY_URI=https://public.data.occrp.org/develop/models/word-frequencies/word_frequencies-v0.4.1.zip
ENV ALEPH_FTM_COMPARE_MODEL_URI=https://public.data.occrp.org/develop/models/xref/glm_bernoulli_2e_wf-v0.4.1.pkl
RUN mkdir -p /opt/ftm-compare/word-frequencies/ && \
curl -L -o "/opt/ftm-compare/word-frequencies/word-frequencies.zip" "$ALEPH_WORD_FREQUENCY_URI" && \
python3 -m zipfile --extract /opt/ftm-compare/word-frequencies/word-frequencies.zip /opt/ftm-compare/word-frequencies/ && \
curl -L -o "/opt/ftm-compare/model.pkl" "$ALEPH_FTM_COMPARE_MODEL_URI"
curl -L -o "/opt/ftm-compare/word-frequencies/word-frequencies.zip" "$ALEPH_WORD_FREQUENCY_URI" && \
python3 -m zipfile --extract /opt/ftm-compare/word-frequencies/word-frequencies.zip /opt/ftm-compare/word-frequencies/ && \
curl -L -o "/opt/ftm-compare/model.pkl" "$ALEPH_FTM_COMPARE_MODEL_URI"

# Configure some docker defaults:
ENV ALEPH_ELASTICSEARCH_URI=http://elasticsearch:9200/ \
ALEPH_DATABASE_URI=postgresql://aleph:aleph@postgres/aleph \
FTM_STORE_URI=postgresql://aleph:aleph@postgres/aleph \
REDIS_URL=redis://redis:6379/0 \
ARCHIVE_TYPE=file \
ARCHIVE_PATH=/data \
FTM_COMPARE_FREQUENCIES_DIR=/opt/ftm-compare/word-frequencies/ \
FTM_COMPARE_MODEL=/opt/ftm-compare/model.pkl
ALEPH_DATABASE_URI=postgresql://aleph:aleph@postgres/aleph \
FTM_STORE_URI=postgresql://aleph:aleph@postgres/aleph \
REDIS_URL=redis://redis:6379/0 \
ARCHIVE_TYPE=file \
ARCHIVE_PATH=/data \
FTM_COMPARE_FREQUENCIES_DIR=/opt/ftm-compare/word-frequencies/ \
FTM_COMPARE_MODEL=/opt/ftm-compare/model.pkl

RUN mkdir /run/prometheus

Expand Down
4 changes: 2 additions & 2 deletions aleph/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
import warnings
from sqlalchemy.exc import SAWarning
from pkg_resources import get_distribution
from importlib.metadata import version

__version__ = get_distribution("aleph").version
__version__ = version("aleph")

# shut up useless SA warning:
warnings.filterwarnings(
Expand Down
26 changes: 25 additions & 1 deletion aleph/manage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# coding: utf-8
import importlib.metadata
import platform
import sys
import json
import click
Expand All @@ -8,6 +10,7 @@
from itertools import count
from normality import slugify
from tabulate import tabulate
from typing import Any
from flask.cli import FlaskGroup
from followthemoney.cli.util import write_object
from servicelayer.taskqueue import flush_queues
Expand Down Expand Up @@ -85,7 +88,28 @@ def ensure_collection(foreign_id, label):
return collection


@click.group(cls=FlaskGroup, create_app=create_app)
def print_aleph_version(ctx: click.Context, _: click.Parameter, value: Any) -> None:
if not value or ctx.resilient_parsing:
return

click.echo(
f"Aleph {importlib.metadata.version('aleph')}\n"
f"Python {platform.python_version()}\n"
f"Flask {importlib.metadata.version('flask')}\n"
f"Werkzeug {importlib.metadata.version('werkzeug')}",
)
ctx.exit()


@click.group(cls=FlaskGroup, create_app=create_app, add_version_option=False)
@click.option(
"-v",
"--version",
help="Show the Aleph version.",
callback=print_aleph_version,
expose_value=False,
is_flag=True,
)
def cli():
"""Server-side command line for aleph."""

Expand Down
19 changes: 18 additions & 1 deletion aleph/tests/test_entities_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,4 +716,21 @@ def test_expand(self):
prop = res["property"]
assert prop == "holder", prop
assert res["count"] == 1, pformat(res)
assert len(res["entities"]) == 1, pformat(res)
assert len(res["entities"]) == 1, pformat(res)

def test_view_transliterate(self):
_, headers = self.login(is_admin=True)

data = {
"id": "1",
"schema": "Person",
"properties": {
"name": ["İlham Əliyev"],
},
}
entity = self.create_entity(data, self.col)
index_entity(entity)

res = self.client.get(f"/api/2/entities/{entity.id}", headers=headers)
assert res.json["properties"]["name"][0] == "İlham Əliyev"
assert res.json["latinized"]["İlham Əliyev"] == "Ilham Aliyev"
6 changes: 6 additions & 0 deletions aleph/tests/test_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,9 @@ def test_userdel_nonexistent_group(self):
)
assert result.exit_code != 0
assert isinstance(result.exception, SystemExit)

def test_version_option_shows_aleph_version(self):
for option in ["-v", "--version"]:
result = self.runner.invoke(manage.cli, option)
assert result.exit_code == 0
assert "Aleph" in result.output
8 changes: 4 additions & 4 deletions contrib/aleph-traefik-minio-keycloak/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ services:
- "traefik.enable=false"

worker:
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
command: aleph worker
restart: on-failure
links:
Expand All @@ -79,7 +79,7 @@ services:
- "traefik.enable=false"

shell:
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
command: /bin/bash
depends_on:
- postgres
Expand All @@ -99,7 +99,7 @@ services:
- "traefik.enable=false"

api:
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
command: gunicorn -w 6 -b 0.0.0.0:8000 --log-level debug --log-file - aleph.wsgi:app
expose:
- 8000
Expand All @@ -121,7 +121,7 @@ services:
- "traefik.enable=false"

ui:
image: ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
image: ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG:-4.0.2}
depends_on:
- api
- traefik
Expand Down
8 changes: 4 additions & 4 deletions contrib/keycloak/docker-compose.dev-keycloak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
elasticsearch:
build:
context: services/elasticsearch
image: ghcr.io/alephdata/aleph-elasticsearch:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
image: ghcr.io/alephdata/aleph-elasticsearch:${ALEPH_TAG:-4.0.2}
hostname: elasticsearch
environment:
- discovery.type=single-node
Expand Down Expand Up @@ -55,7 +55,7 @@ services:
app:
build:
context: .
image: alephdata/aleph:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
image: alephdata/aleph:${ALEPH_TAG:-4.0.2}
hostname: aleph
command: /bin/bash
links:
Expand Down Expand Up @@ -83,7 +83,7 @@ services:
api:
build:
context: .
image: alephdata/aleph:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
image: alephdata/aleph:${ALEPH_TAG:-4.0.2}
command: aleph run -h 0.0.0.0 -p 5000 --with-threads --reload --debugger
ports:
- "127.0.0.1:5000:5000"
Expand Down Expand Up @@ -117,7 +117,7 @@ services:
ui:
build:
context: ui
image: alephdata/aleph-ui:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
image: alephdata/aleph-ui:${ALEPH_TAG:-4.0.2}
links:
- api
command: npm run start
Expand Down
2 changes: 1 addition & 1 deletion contrib/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
psql -c "DROP DATABASE IF EXISTS aleph_test;" $ALEPH_DATABASE_URI
psql -c "CREATE DATABASE aleph_test;" $ALEPH_DATABASE_URI

pytest aleph/ --cov=aleph --cov-report html --cov-report term $@
PYTHONDEVMODE=1 PYTHONTRACEMALLOC=1 pytest aleph/ --cov=aleph --cov-report html --cov-report term $@
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ services:
- aleph.env

worker:
<<<<<<< HEAD
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
=======
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
>>>>>>> develop
command: aleph worker
restart: on-failure
depends_on:
Expand All @@ -62,7 +66,11 @@ services:
- aleph.env

shell:
<<<<<<< HEAD
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
=======
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
>>>>>>> develop
command: /bin/bash
depends_on:
- postgres
Expand All @@ -80,7 +88,11 @@ services:
- aleph.env

api:
<<<<<<< HEAD
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
=======
image: ghcr.io/alephdata/aleph:${ALEPH_TAG:-4.0.2}
>>>>>>> develop
expose:
- 8000
depends_on:
Expand All @@ -97,7 +109,11 @@ services:
- aleph.env

ui:
<<<<<<< HEAD
image: ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG:-ALEPH_TAG:-4.1.0-rc4}
=======
image: ghcr.io/alephdata/aleph-ui-production:${ALEPH_TAG:-4.0.2}
>>>>>>> develop
depends_on:
- api
ports:
Expand Down
Loading

0 comments on commit 68fdb79

Please sign in to comment.