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

Feature/ted 886 #327

Merged
merged 5 commits into from
Oct 27, 2022
Merged
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
8 changes: 6 additions & 2 deletions dags/operators/DagBatchPipelineOperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
DEFAULT_NUBER_OF_CELERY_WORKERS = 144
NOTICE_PROCESS_WORKFLOW_DAG_NAME = "notice_process_workflow"
DEFAULT_START_WITH_TASK_ID = "notice_normalisation_pipeline"

DEFAULT_PIPELINE_NAME_FOR_LOGS = "unknown_pipeline_name"

class BatchPipelineCallable(Protocol):

Expand Down Expand Up @@ -59,7 +59,11 @@ def execute(self, context: Any):
mongodb_client = MongoClient(config.MONGO_DB_AUTH_URL)
notice_repository = NoticeRepository(mongodb_client=mongodb_client)
processed_notice_ids = []
pipeline_name = self.notice_pipeline_callable.__name__
pipeline_name = DEFAULT_PIPELINE_NAME_FOR_LOGS
if self.notice_pipeline_callable:
pipeline_name = self.notice_pipeline_callable.__name__
elif self.batch_pipeline_callable:
pipeline_name = self.batch_pipeline_callable.__name__
number_of_notices = len(notice_ids)
batch_event_message = EventMessage(
message=f"Batch processing for pipeline = [{pipeline_name}] with {number_of_notices} notices.",
Expand Down
4 changes: 4 additions & 0 deletions infra/airflow-cluster/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ RUN wget -c https://kumisystems.dl.sourceforge.net/project/saxon/Saxon-HE/10/Jav
RUN cd .saxon && unzip SaxonHE10-6J.zip && rm -rf SaxonHE10-6J.zip


RUN mkdir -p ./.limes
RUN wget -c https://github.com/dice-group/LIMES/releases/download/1.7.9/limes.jar -P ./.limes


RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.4.1/constraints-no-providers-3.8.txt"
1 change: 1 addition & 0 deletions infra/airflow-cluster/docker-compose-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ x-airflow-common:
AIRFLOW_HOME: /opt/airflow
RML_MAPPER_PATH: /opt/airflow/.rmlmapper/rmlmapper.jar
XML_PROCESSOR_PATH: /opt/airflow/.saxon/saxon-he-10.6.jar
LIMES_ALIGNMENT_PATH: /opt/airflow/.limes/limes.jar
DAG_LOGGER_CONFIG_HANDLERS: ${DAG_LOGGER_CONFIG_HANDLERS}
volumes:
# - ./config/airflow.cfg:/opt/airflow/airflow.cfg
Expand Down
1 change: 1 addition & 0 deletions infra/airflow-cluster/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ x-airflow-common:
AIRFLOW_HOME: /opt/airflow
RML_MAPPER_PATH: /opt/airflow/.rmlmapper/rmlmapper.jar
XML_PROCESSOR_PATH: /opt/airflow/.saxon/saxon-he-10.6.jar
LIMES_ALIGNMENT_PATH: /opt/airflow/.limes/limes.jar
DAG_LOGGER_CONFIG_HANDLERS: ${DAG_LOGGER_CONFIG_HANDLERS}
volumes:
# - ./config/airflow.cfg:/opt/airflow/airflow.cfg
Expand Down
3 changes: 3 additions & 0 deletions infra/airflow/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ RUN wget -c https://api.bitbucket.org/2.0/repositories/Dragos0000/rml-mapper/src
RUN wget -c https://kumisystems.dl.sourceforge.net/project/saxon/Saxon-HE/10/Java/SaxonHE10-6J.zip -P .saxon/
RUN cd .saxon && unzip SaxonHE10-6J.zip && rm -rf SaxonHE10-6J.zip

RUN mkdir -p ./.limes
RUN wget -c https://github.com/dice-group/LIMES/releases/download/1.7.9/limes.jar -P ./.limes


RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt --constraint "https://raw.githubusercontent.com/apache/airflow/constraints-2.4.1/constraints-no-providers-3.8.txt"
1 change: 1 addition & 0 deletions infra/airflow/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ x-airflow-common:
AIRFLOW_HOME: /opt/airflow
RML_MAPPER_PATH: /opt/airflow/.rmlmapper/rmlmapper.jar
XML_PROCESSOR_PATH: /opt/airflow/.saxon/saxon-he-10.6.jar
LIMES_ALIGNMENT_PATH: /opt/airflow/.limes/limes.jar
DAG_LOGGER_CONFIG_HANDLERS: ${DAG_LOGGER_CONFIG_HANDLERS}
volumes:
# - ./config/airflow.cfg:/opt/airflow/airflow.cfg
Expand Down
26 changes: 12 additions & 14 deletions tests/e2e/data_manager/test_fuseki_triple_store.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import pytest
from ted_sws.data_manager.adapters.triple_store import FusekiAdapter, FusekiException
from tests import TEST_DATA_PATH
Expand All @@ -19,27 +18,26 @@ def test_fuseki_triple_store_connection():
with pytest.raises(FusekiException):
triple_store.create_repository(repository_name=REPOSITORY_NAME)


def test_fuseki_triple_store_add_file_to_repository():
triple_store = FusekiAdapter()
rdf_file_path = TEST_DATA_PATH / "example.ttl"
assert rdf_file_path.exists()
triple_store.add_file_to_repository(rdf_file_path,
repository_name="unknown_repository_123456677")
triple_store.delete_repository(repository_name=REPOSITORY_NAME)


def test_fuseki_triple_store_get_sparql_endpoint(fuseki_triple_store):
sparql_endpoint = fuseki_triple_store.get_sparql_triple_store_endpoint(repository_name="unknown_repository_123456677")
if REPOSITORY_NAME not in fuseki_triple_store.list_repositories():
fuseki_triple_store.create_repository(repository_name=REPOSITORY_NAME)
rdf_file_path = TEST_DATA_PATH / "example.ttl"
assert rdf_file_path.exists()
fuseki_triple_store.add_file_to_repository(rdf_file_path,
repository_name=REPOSITORY_NAME)
sparql_endpoint = fuseki_triple_store.get_sparql_triple_store_endpoint(
repository_name=REPOSITORY_NAME)
assert sparql_endpoint is not None
df_query_result = sparql_endpoint.with_query(sparql_query=SPARQL_QUERY_TRIPLES).fetch_tabular()
assert df_query_result is not None
assert len(df_query_result) > 0

triple_store = FusekiAdapter()
triple_store.delete_repository(repository_name=REPOSITORY_NAME)
fuseki_triple_store.delete_repository(repository_name=REPOSITORY_NAME)

with pytest.raises(FusekiException):
triple_store.delete_repository(repository_name=REPOSITORY_NAME)

assert REPOSITORY_NAME not in triple_store.list_repositories()
fuseki_triple_store.delete_repository(repository_name=REPOSITORY_NAME)

assert REPOSITORY_NAME not in fuseki_triple_store.list_repositories()