Skip to content

Commit

Permalink
Merge pull request #872 from OnroerendErfgoed/release/855_2.1.0
Browse files Browse the repository at this point in the history
Release/855 2.1.0
  • Loading branch information
goessebr authored Jul 22, 2024
2 parents 4430803 + 7e5239a commit aa311ba
Show file tree
Hide file tree
Showing 27 changed files with 1,051 additions and 379 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/atramhasis_backend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Atramhasis backend tests

on:
push:
paths:
- atramhasis/**
- scripts/**
- tests/**
- '!atramhasis/static/**'
- .github/workflows/atramhasis_backend.yaml
- pyproject.toml
- requirements*.txt

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Install python requirements
env:
HATCH_BUILD_NO_HOOKS: true
working-directory: ./
run: |
pip --version
pip install pip-tools
pip-sync requirements-dev.txt
pip install -e .
- name: Python tests
run: pytest tests --exitfirst --capture=no -vvv --full-trace
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.1.0 (20-06-2023)
------------------

Migrated from setup.py to the hatchling build tool for improved packaging and distribution. (#854)
Benefits include faster builds, modern configuration, and enhanced flexibility for future enhancements.


2.0.0 (22-12-2023)
------------------

Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ keywords:
- vocabulary
- python
license: GPL-3.0
version: 2.0.0
date-released: '2023-12-22'
version: 2.1.0
date-released: '2024-06-20'
25 changes: 23 additions & 2 deletions atramhasis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,29 @@
from atramhasis.renderers import json_renderer_verbose


DEFAULT_SETTINGS = {
"cache.tree.backend": "dogpile.cache.memory",
"cache.tree.arguments.cache_size": "5000",
"cache.tree.expiration_time": "7000",
"cache.list.backend": "dogpile.cache.memory",
"cache.list.arguments.cache_size": "5000",
"cache.list.expiration_time": "7000",
"jinja2.extensions": "jinja2.ext.do",
"jinja2.filters": "label_sort = atramhasis.utils.label_sort",
"dojo.mode": "dist",
"layout.focus_conceptschemes": [],
"skosprovider.skosregistry_factory": "atramhasis.skos.create_registry",
"skosprovider.skosregistry_location": "request",
}


def includeme(config):
"""this function adds some configuration for the application"""
settings = config.registry.settings
for key, value in DEFAULT_SETTINGS.items():
if key not in settings:
settings[key] = value

config.include('pyramid_jinja2')
config.include('pyramid_tm')
config.add_static_view('static', 'static', cache_max_age=3600)
Expand All @@ -21,6 +42,8 @@ def includeme(config):
config.include('atramhasis.cache')
config.scan('pyramid_skosprovider')

config.add_translation_dirs('atramhasis:locale/')

config.scan()


Expand All @@ -45,8 +68,6 @@ def load_app(config, settings):

includeme(config)

config.add_translation_dirs('atramhasis:locale/')

config.include('atramhasis.data:db')

return config.make_wsgi_app()
4 changes: 2 additions & 2 deletions atramhasis/data/datamanagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def find(self, conceptscheme_id, query):
"""
db_query = (
select(Thing)
.options(joinedload('labels'))
.options(joinedload(Thing.labels))
.filter(Thing.conceptscheme_id == conceptscheme_id)
)
if 'type' in query and query['type'] in ['concept', 'collection']:
Expand Down Expand Up @@ -127,7 +127,7 @@ def get_all(self, conceptscheme_id):
"""
all_results = self.session.execute(
select(Thing)
.options(joinedload('labels'))
.options(joinedload(Thing.labels))
.filter(Thing.conceptscheme_id == conceptscheme_id)
).unique().scalars().all()
return all_results
Expand Down
8 changes: 4 additions & 4 deletions atramhasis/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ openapi: 3.0.3

info:
title: Atramhasis API
version: 2.0.0
version: 2.1.0

servers:
- url: '/'
Expand Down Expand Up @@ -1138,9 +1138,6 @@ components:

Provider:
type: object
required:
- conceptscheme_uri
- uri_pattern
properties:
id:
type: string
Expand Down Expand Up @@ -1189,6 +1186,9 @@ components:
type: object
additionalProperties: true
nullable: true
required:
- conceptscheme_uri
- uri_pattern
Error:
type: object
required:
Expand Down
4 changes: 2 additions & 2 deletions atramhasis/static/admin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion atramhasis/static/admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "atramhasis",
"version": "2.0.0",
"version": "2.1.0",
"description": "Node packages for building Atramhasis.",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions atramhasis/static/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion atramhasis/static/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "atramhasis",
"version": "2.0.0",
"version": "2.1.0",
"description": "Node packages for public part of Atramhasis.",
"repository": {
"type": "git",
Expand Down
15 changes: 6 additions & 9 deletions atramhasis/views/exception_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import logging
import sys

from openapi_core.unmarshalling.schemas.exceptions import InvalidSchemaValue
from openapi_core.validation.schemas.exceptions import InvalidSchemaValue
from pyramid.httpexceptions import HTTPMethodNotAllowed
from pyramid.view import notfound_view_config
from pyramid.view import view_config
from pyramid_openapi3 import RequestValidationError
from pyramid_openapi3 import ResponseValidationError
from pyramid_openapi3 import extract_errors
from pyramid_openapi3 import openapi_validation_error
from skosprovider.exceptions import ProviderUnavailableException
from sqlalchemy.exc import IntegrityError
Expand Down Expand Up @@ -117,17 +118,13 @@ def failed_openapi_validation(exc, request):
# noinspection PyTypeChecker
errors.extend(
[
str(error)
for error in exc.errors
if not isinstance(error, InvalidSchemaValue)
f'{error.get("field")}: {error.get("message")}'
for error in
list(extract_errors(request, exc.errors))
]
)
request.response.status_int = 400
if isinstance(exc, RequestValidationError):
subject = "Request"
else:
subject = "Response"
return {"message": f"{subject} was not valid for schema.", "errors": errors}
return {"message": "Request was not valid for schema.", "errors": errors}
except Exception:
log.exception("Issue with exception handling.")
return openapi_validation_error(exc, request)
Expand Down
17 changes: 17 additions & 0 deletions build_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import subprocess
from pathlib import Path

from hatchling.builders.hooks.plugin.interface import BuildHookInterface


class BuildHook(BuildHookInterface):
def initialize(self, version: str, build_data) -> None:
"""Build frontend when building the wheel."""
super().initialize(version, build_data)

root_dir = Path(__file__).parent
static = root_dir / "atramhasis" / "static"
static_admin = static / "admin"
subprocess.run(["npm", "install"], cwd=static)
subprocess.run(["npm", "install"], cwd=static_admin)
subprocess.run(["grunt", "-v", "build"], cwd=static_admin, check=True)
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
# built documents.
#
# The short X.Y version.
version = '2.0'
version = '2.1'
# The full version, including alpha/beta/rc tags.
release = '2.0.0'
release = '2.1.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
69 changes: 69 additions & 0 deletions docs/source/customisation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1044,3 +1044,72 @@ through code in this file. Your final code should looks somewhat like this:
register_providers_from_db(registry, request.db)
return registry
Application settings
====================
These are settings you can use to change the atramhasis behaviour.
When a setting is marked with DEFAULT then writing the setting is optional.
When a setting is marked with REQUIRED then it is strongly advised to fill in the
setting. Skipping these may not prevent the application from starting, but some
functionality might fail to run properly.
.. code-block:: ini
[app:main]
use = egg:my_app
pyramid.default_locale_name = nl
# DEFAULT - If you wish to add your own values you should append to these values
jinja2.extensions =
jinja2.ext.do
# DEFAULT - If you wish to add your own values you should append to these values
jinja2.filters =
label_sort = atramhasis.utils.label_sort
available_languages = en nl it
# REQUIRED
sqlalchemy.url = sqlite:///test.db
# sqlalchemy.url = postgresql://postgres:postgres@localhost:5432/atramhasis_test
# DEFAULT
skosprovider.skosregistry_location = request
# DEFAULT
skosprovider.skosregistry_factory = tests.create_registry
# DEFAULT - cache which caches the data used for /conceptschemes/{scheme_id}/tree
cache.tree.backend = dogpile.cache.memory
cache.tree.arguments.cache_size = 5000
cache.tree.expiration_time = 7000
# DEFAULT - cache which caches the data used for /labeltypes and /notetypes
cache.list.backend = dogpile.cache.memory
cache.list.arguments.cache_size = 5000
cache.list.expiration_time = 7000
# REQUIRED - Filesystem location to dump exports
atramhasis.dump_location = path/to/folder
# REQUIRED - Assume an LDF server is present?
atramhasis.ldf.enabled = True
# External url of the LDF server
atramhasis.ldf.baseurl = http://demo.atramhasis.org/ldf
# DEFAULT empty list
layout.focus_conceptschemes =
HERITAGETYPE
PERIOD
GEOGRAPHY
MATERIALS
# DEFAULT - Run dojo from source (src) or distribution (dist)
dojo.mode = dist
# The Twitter @username the card should be attributed to.
twitter.site =
# Enter your tracking snippet
tracking_snippet =
Loading

0 comments on commit aa311ba

Please sign in to comment.