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

Update rml_mapper.py #469

Merged
merged 1 commit into from
Mar 28, 2023
Merged
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 ted_sws/notice_transformer/adapters/rml_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ class RMLMapper(RMLMapperABC):
"""
This class is a concrete implementation of the rml-mapper adapter.
"""
def __init__(self, rml_mapper_path: Path, serialization_format: SerializationFormat = TURTLE_SERIALIZATION_FORMAT):
def __init__(self, rml_mapper_path: Path, serialization_format: SerializationFormat = TURTLE_SERIALIZATION_FORMAT,
transformation_timeout: float = None
):
"""
:param rml_mapper_path: the path to the rml-mapper executable
:param serialization_format: serialization format
:param serialization_format: transformation_timeout
"""
self.rml_mapper_path = rml_mapper_path
self.serialization_format = serialization_format
self.transformation_timeout = transformation_timeout

def execute(self, package_path: Path) -> str:
"""
Expand All @@ -87,7 +91,7 @@ def execute(self, package_path: Path) -> str:
"""
# java -jar ./rmlmapper.jar -m rml.ttl -s turtle -o output.ttl
bash_script = f"cd {package_path} && java -jar {self.rml_mapper_path} -m {package_path / MS_TRANSFORM_FOLDER_NAME / MS_MAPPINGS_FOLDER_NAME / '*'} -s {self.get_serialization_format_value()}"
script_result = subprocess.run(bash_script, shell=True, capture_output=True)
script_result = subprocess.run(bash_script, shell=True, capture_output=True, timeout=self.transformation_timeout)
error = script_result.stderr.decode('utf-8')
if error:
raise Exception(error)
Expand Down