Skip to content

Commit c6c47b7

Browse files
authored
Merge branch 'develop' into release/4.1.1
2 parents 0d8d7d6 + b623206 commit c6c47b7

File tree

71 files changed

+9062
-28546
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+9062
-28546
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Aleph Community Discourse
4+
url: https://aleph.discourse.group
5+
about: Get support for running and developing Aleph and related projects here.

.github/workflows/build-ui.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- name: Run tests
3939
run: make test-ui
4040

41+
- name: Build
42+
run: make build-ui
43+
4144
- name: Build production image
4245
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
4346
run: docker build -t ghcr.io/alephdata/aleph-ui-production:${GITHUB_SHA} -f ui/Dockerfile.production ui

Dockerfile

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
FROM ubuntu:20.04
1+
FROM python:3.9
22
ENV DEBIAN_FRONTEND noninteractive
33

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

1513
ENV LANG='en_US.UTF-8'
1614

1715
RUN groupadd -g 1000 -r app \
18-
&& useradd -m -u 1000 -s /bin/false -g app app
16+
&& useradd -m -u 1000 -s /bin/false -g app app
1917

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

3937
# Configure some docker defaults:
4038
ENV ALEPH_ELASTICSEARCH_URI=http://elasticsearch:9200/ \
41-
ALEPH_DATABASE_URI=postgresql://aleph:aleph@postgres/aleph \
42-
FTM_STORE_URI=postgresql://aleph:aleph@postgres/aleph \
43-
REDIS_URL=redis://redis:6379/0 \
44-
ARCHIVE_TYPE=file \
45-
ARCHIVE_PATH=/data \
46-
FTM_COMPARE_FREQUENCIES_DIR=/opt/ftm-compare/word-frequencies/ \
47-
FTM_COMPARE_MODEL=/opt/ftm-compare/model.pkl
39+
ALEPH_DATABASE_URI=postgresql://aleph:aleph@postgres/aleph \
40+
FTM_STORE_URI=postgresql://aleph:aleph@postgres/aleph \
41+
REDIS_URL=redis://redis:6379/0 \
42+
ARCHIVE_TYPE=file \
43+
ARCHIVE_PATH=/data \
44+
FTM_COMPARE_FREQUENCIES_DIR=/opt/ftm-compare/word-frequencies/ \
45+
FTM_COMPARE_MODEL=/opt/ftm-compare/model.pkl
4846

4947
RUN mkdir /run/prometheus
5048

SUPPORT.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The objective of the Aleph project is to provide powerful software to those who
88

99
## Eligible use cases
1010

11-
The maintainers of this project limit support and responses both on GitHub and in the Slack channel to authorised groups and individuals. In order to receive authorisation, we require that you disclose the manner in which you use our technology. **We will decide if that use falls within the intended uses of Aleph.**
11+
The maintainers of this project limit support and responses both on GitHub and on Discourse to authorised groups and individuals. In order to receive authorisation, we require that you disclose the manner in which you use our technology. **We will decide if that use falls within the intended uses of Aleph.**
1212

1313
Examples of intended uses could include:
1414

@@ -20,7 +20,7 @@ Support includes installation support, requests for new features or issues speci
2020

2121
Please submit a description of your use case along with your name, affiliation and email address using one of the following channels:
2222

23-
- The Slack #intros channel
23+
- As part of the [Discourse](https://aleph.discourse.group/) signup process
2424
- As part of the first GitHub issue that you file
2525
- Via our [contact form](https://requests.occrp.org/datadesk)
2626

@@ -30,4 +30,4 @@ Make sure you describe your goals, rather than the set of techniques that define
3030

3131
The Aleph team supports feature versions for 12 months after the first major iteration of that version was released. For example, we support Aleph 3.12.x for 12 months after Aleph 3.12.0 was released. The Aleph team supports upgrades, but only from supported feature versions of the product. Support means helping to ensure that you can get your Aleph instance up and running. As we're a small team we don't have the capacity to backport bugs to supported versions. In the case of critical secruity vulnrabilities we'll endeavour to ensure that all currently supported versions, but we recommend administrators upgrade to the latest version as soon as possible.
3232

33-
For versions that are supported, if you are having problems, you can reach out to us in Slack or by raising an issue in Github.
33+
For versions that are supported, if you are having problems, you can reach out to us on Discourse or by raising an issue in Github.

aleph.env.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ ALEPH_OAUTH_SECRET=
9191
# Define a different ftm entity store:
9292
# FTM_STORE_URI=postgresql://<username>:<password>@<host>/<database>
9393

94+
# ingest-file uses a document cache to speed up operations
95+
# (it defaults to either one of the two above postgres connection strings)
96+
# TAGS_DATABASE_URI=postgresql://<username>:<password>@<host>/<database>
97+
9498
# Queue mechanism
9599
# REDIS_URL=redis://redis:6379/0
96100
# RABBITMQ_URL=rabbitmq

aleph/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import logging
22
import warnings
33
from sqlalchemy.exc import SAWarning
4-
from pkg_resources import get_distribution
4+
from importlib.metadata import version
55

6-
__version__ = get_distribution("aleph").version
6+
__version__ = version("aleph")
77

88
# shut up useless SA warning:
99
warnings.filterwarnings(

aleph/manage.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# coding: utf-8
2+
import importlib.metadata
3+
import platform
24
import sys
35
import json
46
import click
@@ -8,6 +10,7 @@
810
from itertools import count
911
from normality import slugify
1012
from tabulate import tabulate
13+
from typing import Any
1114
from flask.cli import FlaskGroup
1215
from followthemoney.cli.util import write_object
1316
from servicelayer.taskqueue import flush_queues
@@ -25,7 +28,6 @@
2528
hash_plaintext_api_keys as _hash_plaintext_api_keys,
2629
)
2730
from aleph.index.entities import iter_proxies
28-
from aleph.index.util import AlephOperationalException
2931
from aleph.logic.collections import create_collection, update_collection
3032
from aleph.logic.collections import delete_collection, reindex_collection
3133
from aleph.logic.collections import upgrade_collections, reingest_collection
@@ -85,7 +87,28 @@ def ensure_collection(foreign_id, label):
8587
return collection
8688

8789

88-
@click.group(cls=FlaskGroup, create_app=create_app)
90+
def print_aleph_version(ctx: click.Context, _: click.Parameter, value: Any) -> None:
91+
if not value or ctx.resilient_parsing:
92+
return
93+
94+
click.echo(
95+
f"Aleph {importlib.metadata.version('aleph')}\n"
96+
f"Python {platform.python_version()}\n"
97+
f"Flask {importlib.metadata.version('flask')}\n"
98+
f"Werkzeug {importlib.metadata.version('werkzeug')}",
99+
)
100+
ctx.exit()
101+
102+
103+
@click.group(cls=FlaskGroup, create_app=create_app, add_version_option=False)
104+
@click.option(
105+
"-v",
106+
"--version",
107+
help="Show the Aleph version.",
108+
callback=print_aleph_version,
109+
expose_value=False,
110+
is_flag=True,
111+
)
89112
def cli():
90113
"""Server-side command line for aleph."""
91114

@@ -503,11 +526,11 @@ def publish(foreign_id):
503526

504527
@cli.command()
505528
def upgrade():
506-
"""Create or upgrade the search index and database."""
507-
try:
508-
upgrade_system()
509-
except AlephOperationalException:
510-
log.exception("Failed to upgrade.")
529+
"""Create or upgrade the search index and database.
530+
531+
:raises AlephOperationalException:
532+
"""
533+
upgrade_system()
511534

512535

513536
@cli.command()

aleph/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ def __init__(self) -> None:
148148

149149
# API rate limiting (req/min for anonymous users)
150150
self.API_RATE_LIMIT = env.to_int("ALEPH_API_RATE_LIMIT", 30)
151-
self.API_RATE_WINDOW = 15 # minutes
151+
152+
# API rate window (in minutes)
153+
self.API_RATE_WINDOW = env.to_int("ALEPH_API_RATE_WINDOW", 15)
152154

153155
# Export file size limit
154156
self.EXPORT_MAX_SIZE = env.to_int(

aleph/tests/test_entities_api.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,4 +716,21 @@ def test_expand(self):
716716
prop = res["property"]
717717
assert prop == "holder", prop
718718
assert res["count"] == 1, pformat(res)
719-
assert len(res["entities"]) == 1, pformat(res)
719+
assert len(res["entities"]) == 1, pformat(res)
720+
721+
def test_view_transliterate(self):
722+
_, headers = self.login(is_admin=True)
723+
724+
data = {
725+
"id": "1",
726+
"schema": "Person",
727+
"properties": {
728+
"name": ["İlham Əliyev"],
729+
},
730+
}
731+
entity = self.create_entity(data, self.col)
732+
index_entity(entity)
733+
734+
res = self.client.get(f"/api/2/entities/{entity.id}", headers=headers)
735+
assert res.json["properties"]["name"][0] == "İlham Əliyev"
736+
assert res.json["latinized"]["İlham Əliyev"] == "Ilham Aliyev"

aleph/tests/test_manage.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,9 @@ def test_userdel_nonexistent_group(self):
308308
)
309309
assert result.exit_code != 0
310310
assert isinstance(result.exception, SystemExit)
311+
312+
def test_version_option_shows_aleph_version(self):
313+
for option in ["-v", "--version"]:
314+
result = self.runner.invoke(manage.cli, option)
315+
assert result.exit_code == 0
316+
assert "Aleph" in result.output

0 commit comments

Comments
 (0)