Skip to content

Keywords with context input#513

Open
jesper-friis wants to merge 21 commits intomasterfrom
keywords-with-context-input
Open

Keywords with context input#513
jesper-friis wants to merge 21 commits intomasterfrom
keywords-with-context-input

Conversation

@jesper-friis
Copy link
Contributor

@jesper-friis jesper-friis commented Mar 9, 2026

Description

Added context argument to get_keywords().

Some functionality that should have been in PR #513 has leaked into this PR

Type of change

  • Bug fix and code cleanup
  • New feature
  • Documentation update
  • Testing

Checklist for the reviewer

This checklist should be used as a help for the reviewer.

  • Is the change limited to one issue?
  • Does this PR close the issue?
  • Is the code easy to read and understand?
  • Do all new feature have an accompanying new test?
  • Has the documentation been updated as necessary?
  • Is the code properly tested?

@jesper-friis jesper-friis mentioned this pull request Mar 9, 2026
10 tasks
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 97.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.02%. Comparing base (b793b49) to head (5b51fb5).

Files with missing lines Patch % Lines
tripper/datadoc/dataset.py 96.66% 1 Missing ⚠️
tripper/datadoc/keywords.py 97.36% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
+ Coverage   84.58%   85.02%   +0.44%     
==========================================
  Files          30       30              
  Lines        4890     4963      +73     
==========================================
+ Hits         4136     4220      +84     
+ Misses        754      743      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

from tripper.datadoc.errors import InvalidDatadocError
from tripper.datadoc.utils import getlabel

assert getlabel({"@id": "ex:A", "prefLabel": "a"}) == "a"
Copy link
Contributor

Choose a reason for hiding this comment

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

Add check for precendence of labels

context = get_context(default_theme=None)
update_context(sources, context)
c = context.get_context_dict()
assert c["instr"] == {"@id": EX.instr, "@type": HUME.Device}
Copy link
Contributor

Choose a reason for hiding this comment

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

No instances in context

c = context.get_context_dict()
assert c["instr"] == {"@id": EX.instr, "@type": HUME.Device}
assert c["MyDevice"] == {"@id": EX.MyDevice, "@type": OWL.Class}
assert c["Device"] == {"@id": HUME.Device, "@type": OWL.Class}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should have som check on what happens if there is mismatch between previously added context and updated_context.

DCTERMS.creator: "some",
DCTERMS.hasPart: "value",
DCTERMS.issued: "value",
# DCTERMS.issued: "value",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this commented out?

# "@type": "owl:Class",
"subClassOf": HUME.Device,
"hasPart": HUME.MeasuringInstrument,
"hasPart": [HUME.MeasuringInstrument, "ex:MyDevice"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it have itself as part?

Comment on lines +616 to +622
{
# An individial relating to two classes and an individual.
# Should be converted to an existential restriction.
"@id": "ex:instr3",
"@type": HUME.Device,
"hasPart": [HUME.MeasuringInstrument, "MyDevice", "ex:instr"],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

For completeness we should have individual relating to one individual and individual related to a list of individuals

Comment on lines +669 to +670
# WRONG! Should be converted to restrictions
"@id": "ex:instr3",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be fixed

)

with warnings.catch_warnings():
warnings.simplefilter("ignore", category=TripperWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

What kind of tripperwarnings. I think it would be useful to write a comment on what kid of warnings we expect and why it is OK to ignore them

Comment on lines +14 to +15
##

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
##

)
if prefixes:
context.add_context({k: str(v) for k, v in prefixes.items()})

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

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.

2 participants