-
Notifications
You must be signed in to change notification settings - Fork 555
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
Sort Turtle output #1978
base: main
Are you sure you want to change the base?
Sort Turtle output #1978
Conversation
This patch adds a test to start specifying what sorting Turtle output would look like. This is intended to start discussion about expectations of blank node sorting, and to set an initial interface for triggering sorted output with a propagated keyword argument in `Graph.serialize()`. This patch will fail CI, but should not fail for code-style reasons. The new test script was reviewed with black, flake8, isort, and mypy (--strict). References: * RDFLib#1890 Signed-off-by: Alex Nelson <[email protected]>
Something that may be of interest to you: class OrderedMemory(Memory):
def __init__(self, configuration=None, identifier=None):
super().__init__(configuration, identifier)
self.__spo = OrderedDict()
self.__pos = OrderedDict()
self.__osp = OrderedDict()
self.__namespace = OrderedDict()
self.__prefix = OrderedDict()
self.__context_obj_map = OrderedDict() I wanted stable output for test reports, so it is easier to diff them and so they are not just noisy spam when added to git, so I made that. Seems to work, but it depends on order that things are added, and I'm naming blank nodes to make it work. Doing something similar with SortedDict may also work. |
@aucampia - thanks for the strategy suggestion. I just gave After reviewing the code, there's a chance I think one end-result of this analysis is that making consistently-sorting Does this way of thinking sound like it's on the right track? Unrelatedly, I was using |
@ajnelson-nist do you want to pick this up again, now that we have R's being merged again? Also, is this in line with recent W3C work on canonical hashing of RDF graphs: |
Summary of changes
This patch series starts an API for sorting graph serializations, beginning with Turtle. The main objective is to produce consistent Turtle output, no matter the order of RDF triples being added to a
Graph
.This PR will close Issue 1890.
The initial pair of patches only starts the PR. Some discussion will be needed to design the remaining patches.
The PR's total effects are expected to be additive and preserve backward compatibility.
Checklist
./examples
for new features. (Not yet; unknown what to update. Hard-coded sorted graph in new unit test can be copied to desired location.)CHANGELOG.md
).