gsoc26: Mapping Conversion Layer (Layer 3), #60#63
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| # Sample Turtle with typed literals, blank nodes, multi-valued predicates | ||
| SAMPLE_TTL_CONTENT = """\ | ||
| @base <https://example.org/data/> . | ||
| @prefix ex: <https://example.org/vocab/> . | ||
| @prefix foaf: <http://xmlns.com/foaf/0.1/> . | ||
| @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | ||
|
|
||
| <alice> foaf:name "Alice" ; | ||
| ex:age 29 ; | ||
| ex:livesAt _:address1 . | ||
|
|
||
| _:address1 ex:city "Leipzig" ; | ||
| ex:country "Germany" . | ||
|
|
||
| <bob> foaf:name "Bob" ; | ||
| ex:age 34 ; | ||
| ex:knows <alice> . | ||
|
|
||
| <project1> ex:title "Databus Example Project" ; | ||
| ex:member <alice> . | ||
| """ | ||
|
|
||
| SAMPLE_NQ_CONTENT = """\ | ||
| <https://example.org/data/alice> <http://xmlns.com/foaf/0.1/name> "Alice" <https://example.org/graph/people> . | ||
| <https://example.org/data/alice> <https://example.org/vocab/age> "29"^^<http://www.w3.org/2001/XMLSchema#integer> <https://example.org/graph/people> . | ||
| <https://example.org/data/bob> <http://xmlns.com/foaf/0.1/name> "Bob" <https://example.org/graph/people> . | ||
| <https://example.org/data/project1> <https://example.org/vocab/title> "Databus Example Project" <https://example.org/graph/projects> . | ||
| <https://example.org/data/project1> <https://example.org/vocab/member> <https://example.org/data/alice> <https://example.org/graph/projects> . | ||
| """ |
There was a problem hiding this comment.
Please put test data in tests/resources
There was a problem hiding this comment.
We should align these tests more closely with the round-trip mapping idea from the paper:
Within a round trip mapping test, we take a file i and convert it to file c of
the format of another equivalence class before we convert c back to file o of the
same format as i. Therefore, i first has to be read into the internal data structure
of the equivalence class of i (see (1) in Fig. 3). Then this data is mapped to the
internal data structure of the equivalence class of c (2) before it is written out
to c (3). Next, c is read into the internal data structure of its equivalence class
(4). That resulting data is mapped back to the internal data structure of the
equivalence class i (5). In the last step (6), this internal data structure data is
written out to o. If the information of the input file i is equal to the information
of output file o, the round trip test succeeds.
The core test should not only check that each conversion direction works, files are created, or counts are non-zero. Instead, it should test:
So I would suggest adding explicit round-trip tests such as:
Triple → Quad → Triple
Triple → CSV/TSV → Triple
and compare the original RDF graph with the reconstructed RDF graph.
For mappings like Quad → Triple → Quad you have to be creative. When two files are created from one Quad file, they could be both separately converted back to Quad and merged and then compared.
Of course a test like Quad -> TSD -> QUAD does not work since TSD to QUAD does not exist
Pull Request
Description
Implements Layer 3 (cross-class mapping conversion) for the Databus Python Client download pipeline, building on the Layer 2 format handlers (TripleHandler, QuadHandler, TSDHandler) merged in #[link Layer 2 PR number]. Users can convert RDF triples to/from CSV, and convert between RDF triple and quad formats, using --format extended with --graph-name and --base-uri.
Related Issues
Issue #60
Type of change
Checklist:
poetry run pytest- all tests passedpoetry run ruff check- no linting errorsWhat was added:
Tests:
Closes #60