Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added broader concept to vocprez test data #220

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e01505d
progress commit
recalcitrantsupplant Dec 2, 2023
f70c120
MVP working with all flavours
recalcitrantsupplant Dec 6, 2023
21bde00
MVP CQL
recalcitrantsupplant Dec 8, 2023
380320d
further ingetration
recalcitrantsupplant Dec 11, 2023
81a1b5e
changes towards a single set of endpoints
recalcitrantsupplant Jan 22, 2024
40799e7
further ingetration
recalcitrantsupplant Jan 23, 2024
21deaee
further ingetration
recalcitrantsupplant Jan 23, 2024
afbf20e
incomplete changes
recalcitrantsupplant Jan 28, 2024
b5a09a3
progress
recalcitrantsupplant Feb 1, 2024
43a171f
working main endpoints
recalcitrantsupplant Feb 7, 2024
7ead742
Working profiles page
recalcitrantsupplant Feb 9, 2024
4f52e8d
Update compose file
recalcitrantsupplant Feb 12, 2024
17b12dc
Reorganise repo
recalcitrantsupplant Feb 13, 2024
1084863
split out node selection
recalcitrantsupplant Feb 19, 2024
75c285d
Updates
recalcitrantsupplant Feb 21, 2024
5e0df3d
minimally working annotations using same repo abstraction
recalcitrantsupplant Mar 4, 2024
d7b708e
connegp refactor
lalewis1 Feb 19, 2024
baa0384
connegp refactor complete
lalewis1 Mar 4, 2024
2e612e3
fix incorrect relative file paths in test suite
lalewis1 Mar 4, 2024
8275dc2
black all code and update imports
recalcitrantsupplant Mar 4, 2024
89781dd
Clean up tests add language tag handling to annotations query
recalcitrantsupplant Mar 7, 2024
25283e2
progress commit
recalcitrantsupplant Mar 15, 2024
b9ace76
progress
recalcitrantsupplant Apr 3, 2024
f061a3c
all current tests passing
recalcitrantsupplant Apr 4, 2024
20b2630
Added broader concept to vocprez test data
jamiefeiss Apr 4, 2024
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
Empty file modified .dockerignore
100644 → 100755
Empty file.
Empty file modified .env-template
100644 → 100755
Empty file.
Empty file modified .github/workflows/on_pr_to_main.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/on_push_to_feature.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/on_push_to_main.yaml
100644 → 100755
Empty file.
Empty file modified .github/workflows/on_release.yaml
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ __pycache__/
.pytest_cache/
.env*
!.env-template
http/
/.python-version
http/
rdf/
Empty file modified .pre-commit-config.yaml
100644 → 100755
Empty file.
4 changes: 3 additions & 1 deletion Dockerfile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ RUN curl -sSL https://install.python-poetry.org | python && \
chmod a+x /opt/poetry/bin/poetry

WORKDIR /app
COPY poetry.lock pyproject.toml connegp-0.1.5-py3-none-any.whl ./
COPY poetry.lock pyproject.toml ./
RUN poetry install --only main --no-root --no-ansi

FROM python:3.11-slim-buster
Expand All @@ -44,6 +44,8 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
PATH="/app/.venv/bin:$PATH"
WORKDIR /app
COPY ./prez /app/prez
COPY ./temp /app/temp
COPY ./test_data /app/test_data
# copy the pyproject.toml as the application reads the version from here
COPY pyproject.toml .

Expand Down
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README-Dev.md
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified changelog.md
100644 → 100755
Empty file.
Binary file removed connegp-0.1.5-py3-none-any.whl
Binary file not shown.
Empty file modified demo/docker-compose.yml
100644 → 100755
Empty file.
54 changes: 54 additions & 0 deletions demo/prez-v4-backend/config.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Licensed under the terms of http://www.apache.org/licenses/LICENSE-2.0

PREFIX : <#>
PREFIX fuseki: <http://jena.apache.org/fuseki#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ja: <http://jena.hpl.hp.com/2005/11/Assembler#>
PREFIX geosparql: <http://jena.apache.org/geosparql#>

[] rdf:type fuseki:Server ;
fuseki:services (
:service
) .

:service rdf:type fuseki:Service ;
fuseki:name "dataset" ;

fuseki:endpoint [ fuseki:operation fuseki:query ; ] ;
fuseki:endpoint [
fuseki:operation fuseki:query ;
fuseki:name "sparql"
];
fuseki:endpoint [
fuseki:operation fuseki:query ;
fuseki:name "query"
] ;
fuseki:endpoint [
fuseki:operation fuseki:gsp-r ;
fuseki:name "get"
] ;
fuseki:dataset <#geo_ds> ;
.

<#geo_ds> rdf:type geosparql:GeosparqlDataset ;
geosparql:dataset :dataset ;
geosparql:inference true ;
geosparql:queryRewrite true ;
geosparql:indexEnabled true ;
geosparql:applyDefaultGeometry true ;
.

# Transactional in-memory dataset.
:dataset rdf:type ja:MemoryDataset ;
## Optional load with data on start-up
ja:data "/rdf/catprez.ttl";
ja:data "/rdf/vocprez.ttl";
ja:data "/rdf/catprez.ttl";
ja:data "/rdf/sandgate.ttl";
ja:data "/rdf/object_catalog_bblocks_catalog.ttl";
ja:data "/rdf/object_vocab_api_bblocks.ttl";
ja:data "/rdf/object_vocab_datatype_bblocks.ttl";
ja:data "/rdf/object_vocab_parameter_bblocks.ttl";
ja:data "/rdf/object_vocab_schema_bblocks.ttl";
.
33 changes: 33 additions & 0 deletions demo/prez-v4-backend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: "3"
services:

fuseki:
image: "ghcr.io/zazuko/fuseki-geosparql:v3.3.0"
ports:
- "3030:3030"
volumes:
- type: bind
source: config.ttl
target: /fuseki/config.ttl
- type: bind
source: ../../test_data
target: /rdf
environment:
ADMIN_PASSWORD: pw
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:3030 || exit 1"]
interval: 5s
timeout: 10s
retries: 3

prez:
build:
context: ../../
dockerfile: ./Dockerfile
ports:
- "8000:8000"
environment:
SPARQL_ENDPOINT: 'http://fuseki:3030/dataset'
depends_on:
fuseki:
condition: service_healthy
3 changes: 3 additions & 0 deletions demo/prez-v4-backend/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains a docker compose file which will run the Prez backend and Fuseki GeoSPARQL together with some sample data.

NB any data added to the test_data folder must also be specified in the fuseki config.ttl file.
Empty file modified dev/dev-config.ttl
100644 → 100755
Empty file.
Empty file modified dev/dev-setup.py
100644 → 100755
Empty file.
Empty file modified main.py
100644 → 100755
Empty file.
1,230 changes: 811 additions & 419 deletions poetry.lock
100644 → 100755

Large diffs are not rendered by default.

Empty file modified poetry.toml
100644 → 100755
Empty file.
Empty file modified prez-logo.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 14 additions & 35 deletions prez/app.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import logging
import os
import time
from textwrap import dedent

import uvicorn
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from rdflib import Graph
from starlette.middleware.cors import CORSMiddleware

Expand All @@ -15,30 +14,28 @@
load_local_data_to_oxigraph,
get_oxrdflib_store,
get_system_store,
load_profile_data_to_oxigraph,
load_system_data_to_oxigraph,
get_annotations_store,
load_annotations_data_to_oxigraph,
)
from prez.models.model_exceptions import (
ClassNotFoundException,
URINotFoundException,
NoProfilesException,
)
from prez.routers.catprez import router as catprez_router
from prez.repositories import RemoteSparqlRepo, PyoxigraphRepo, OxrdflibRepo
from prez.routers.cql import router as cql_router
from prez.routers.identifier import router as identifier_router
from prez.routers.management import router as management_router
from prez.routers.object import router as object_router
from prez.routers.profiles import router as profiles_router
from prez.routers.ogc_router import router as ogc_records_router
from prez.routers.search import router as search_router
from prez.routers.spaceprez import router as spaceprez_router
from prez.routers.sparql import router as sparql_router
from prez.routers.vocprez import router as vocprez_router
from prez.services.app_service import (
healthcheck_sparql_endpoints,
count_objects,
create_endpoints_graph,
populate_api_info,
add_prefixes_to_prefix_graph,
add_common_context_ontologies_to_tbox_cache,
)
from prez.services.exception_catchers import (
catch_400,
Expand All @@ -50,8 +47,6 @@
)
from prez.services.generate_profiles import create_profiles_graph
from prez.services.prez_logging import setup_logger
from prez.services.search_methods import get_all_search_methods
from prez.sparql.methods import RemoteSparqlRepo, PyoxigraphRepo, OxrdflibRepo

app = FastAPI(
exception_handlers={
Expand All @@ -64,19 +59,11 @@
}
)


app.include_router(cql_router)
app.include_router(management_router)
app.include_router(object_router)
app.include_router(sparql_router)
app.include_router(search_router)
app.include_router(profiles_router)
if "CatPrez" in settings.prez_flavours:
app.include_router(catprez_router)
if "VocPrez" in settings.prez_flavours:
app.include_router(vocprez_router)
if "SpacePrez" in settings.prez_flavours:
app.include_router(spaceprez_router)
app.include_router(ogc_records_router)
app.include_router(identifier_router)


Expand All @@ -100,25 +87,14 @@ async def add_cors_headers(request, call_next):
)


def prez_open_api_metadata():
return get_openapi(
title=settings.prez_title,
version=settings.prez_version,
description=settings.prez_desc,
routes=app.routes,
)


app.openapi = prez_open_api_metadata


@app.on_event("startup")
async def app_startup():
"""
This function runs at startup and will continually poll the separate backends until their SPARQL endpoints
are available. Initial caching can be triggered within the try block. NB this function does not check that data is
appropriately configured at the SPARQL endpoint(s), only that the SPARQL endpoint(s) are reachable.
"""
a = time.time()
setup_logger(settings)
log = logging.getLogger("prez")
log.info("Starting up")
Expand All @@ -140,15 +116,18 @@ async def app_startup():
)

await add_prefixes_to_prefix_graph(app.state.repo)
await get_all_search_methods(app.state.repo)
await create_profiles_graph(app.state.repo)
await create_endpoints_graph(app.state.repo)
await count_objects(app.state.repo)
await populate_api_info()
await add_common_context_ontologies_to_tbox_cache()

app.state.pyoxi_system_store = get_system_store()
await load_profile_data_to_oxigraph(app.state.pyoxi_system_store)
await load_system_data_to_oxigraph(app.state.pyoxi_system_store)

app.state.pyoxi_annotations_store = get_annotations_store()
await load_annotations_data_to_oxigraph(app.state.pyoxi_annotations_store)

log.info(f"Startup took {time.time() - a} seconds")


@app.on_event("shutdown")
Expand Down
Empty file modified prez/bnode.py
100644 → 100755
Empty file.
21 changes: 19 additions & 2 deletions prez/cache.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from aiocache import caches
from pyoxigraph.pyoxigraph import Store
from rdflib import Graph, ConjunctiveGraph, Dataset

tbox_cache = Graph()
from prez.repositories import PyoxigraphRepo

profiles_graph_cache = ConjunctiveGraph()
profiles_graph_cache = Dataset()
profiles_graph_cache.bind("prez", "https://prez.dev/")

endpoints_graph_cache = ConjunctiveGraph()
Expand All @@ -26,4 +27,20 @@

system_store = Store()

annotations_store = Store()
annotations_repo = PyoxigraphRepo(annotations_store)

oxrdflib_store = Graph(store="Oxigraph")

caches.set_config(
{
"default": {
"cache": "aiocache.SimpleMemoryCache",
"serializer": {"class": "aiocache.serializers.PickleSerializer"},
},
"curies": {
"cache": "aiocache.SimpleMemoryCache",
"serializer": {"class": "aiocache.serializers.PickleSerializer"},
},
}
)
Loading
Loading