Skip to content

WIP: RDF prefix issue fix in rdflib dumper#184

Merged
cmungall merged 3 commits intomainfrom
rdf_prefixes_issue_429
Jun 27, 2022
Merged

WIP: RDF prefix issue fix in rdflib dumper#184
cmungall merged 3 commits intomainfrom
rdf_prefixes_issue_429

Conversation

@victoriasoesanto
Copy link
Contributor

@victoriasoesanto victoriasoesanto commented Jun 8, 2022

self.assertIn((ORCID['4567'], personinfo.phone, Literal("555-555-5555")), g)

def test_prefixes(self):
with open(OUT, encoding='UTF-8') as file:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this introduces dependencies between tests. It assumes the tests will be executed by the test framework in order, and that the developer who it iteratively testing will run things in order.

I would just move this into test_rdflib_dumper

with open(OUT, encoding='UTF-8') as file:
for line in file:
if 'prefix' in line:
print(line)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should avoid prints in tests, as this makes the test output very verbose and hard to debug

you can use logging.info

But more importantly, this test doesn't test for anything! Recall that this PR is to ensure certain behavior at the turtle syntactic level. I think you want to be testing:

  1. that orcid and sdo prefixes are in the prefix with the expected short form. E.g. check for strings prefix: ORCID and prefix: SDO
  2. that CURIEs are used in the main body of the turtle. E.g. check for strings sdo:Person and ORCID:1234

SDO = Namespace('http://schema.org/')


class RdfLibDumperTestCase(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's good to name the class and tests to something specific to what is being tested (we need to update our guidelines on this)


class RdfLibDumperTestCase(unittest.TestCase):

def test_rdflib_dumper(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good test to have to ensure that rdflib_dumper is working as expected - but note this isn't actually testing the issue at hand, which is specifically about prefixes.

I think it's good to keep these tests, but just add a note that this is testing generic rdflib dumper functionality

@codecov-commenter
Copy link

codecov-commenter commented Jun 9, 2022

Codecov Report

Merging #184 (5597c29) into main (2bd6d6b) will increase coverage by 0.46%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
+ Coverage   62.60%   63.06%   +0.46%     
==========================================
  Files          49       50       +1     
  Lines        5447     5491      +44     
  Branches     1551     1558       +7     
==========================================
+ Hits         3410     3463      +53     
+ Misses       1651     1605      -46     
- Partials      386      423      +37     
Impacted Files Coverage Δ
linkml_runtime/dumpers/rdflib_dumper.py 97.61% <100.00%> (+0.11%) ⬆️
linkml_runtime/utils/schema_as_dict.py 91.30% <100.00%> (ø)
linkml_runtime/utils/yamlutils.py 74.78% <100.00%> (+0.43%) ⬆️
linkml_runtime/__init__.py 89.47% <0.00%> (-10.53%) ⬇️
linkml_runtime/utils/eval_utils.py 73.40% <0.00%> (-6.39%) ⬇️
linkml_runtime/dumpers/rdf_dumper.py 69.23% <0.00%> (-2.57%) ⬇️
linkml_runtime/utils/schemaops.py 72.00% <0.00%> (-2.00%) ⬇️
linkml_runtime/utils/namespaces.py 70.25% <0.00%> (-0.64%) ⬇️
linkml_runtime/utils/pattern.py 85.71% <0.00%> (ø)
linkml_runtime/utils/schemaview.py 84.19% <0.00%> (+0.03%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76c01a4...5597c29. Read the comment docs.

personinfo = Namespace('https://w3id.org/linkml/examples/personinfo/')
SDO = Namespace('http://schema.org/')

def __init__(self, *args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might want to consider setUp() here, see https://docs.python.org/3/library/unittest.html#organizing-test-code

@cmungall cmungall merged commit 678decc into main Jun 27, 2022
@amc-corey-cox amc-corey-cox deleted the rdf_prefixes_issue_429 branch October 20, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

turtle output from various generators and dumpers should use canonical prefixes

3 participants