Skip to content

Rewrite unique_ids.check() and enable for v3 - #220

Draft
ronja-koistinen wants to merge 3 commits into
IIIF:mainfrom
ronja-koistinen:unique-ids
Draft

Rewrite unique_ids.check() and enable for v3#220
ronja-koistinen wants to merge 3 commits into
IIIF:mainfrom
ronja-koistinen:unique-ids

Conversation

@ronja-koistinen

Copy link
Copy Markdown
  • Simplify the code and make it more idiomatic Python
  • Call it from validator.py so it runs for both v3 and v4

* Simplify the code and make it more idiomatic Python
* Call it from validator.py so it runs for both v3 and v4
@ronja-koistinen

Copy link
Copy Markdown
Author

Right now this checks that all id strings are globally unique in a manifest. I am unsure if this is as the spec intends. I ran into at least one manifest that uses the same id as the thumbnail for both a page in items and top-level thumbnail of the manifest itself. I feel like that should be completely okay, but it fails this check as it is currently written.

Comment thread presentation_validator/unique_ids.py Outdated
if depth > MAX_DEPTH:
raise MaxDepthExceeded(f"Max search depth {MAX_DEPTH} exceeded at {node}")
for key, value in filter(lambda x: x[0] not in IGNORE, node.items()):
if key == "id":

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I wonder if this should check for "@id" as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes I think that would be useful. Its only a v3 validator not a v2 but you can have v2 image @ids in the manifest.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 76.657% (+0.5%) from 76.16% — ronja-koistinen:unique-ids into IIIF:main

else:
result.passed = True

duplicate_ids = check(instance)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you mean to remove the check from v4? I think it should be in both v3 and v4

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I moved the callsite to validator.py, a place that at first glance looked version-independent, because the check doesn't rely on any behaviour of any particular version. Did I make a mistake?

"source",
"body",
"scope",
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add thumbnail?

Comment thread presentation_validator/unique_ids.py Outdated
if depth > MAX_DEPTH:
raise MaxDepthExceeded(f"Max search depth {MAX_DEPTH} exceeded at {node}")
for key, value in filter(lambda x: x[0] not in IGNORE, node.items()):
if key == "id":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes I think that would be useful. Its only a v3 validator not a v2 but you can have v2 image @ids in the manifest.

@ronja-koistinen

Copy link
Copy Markdown
Author

I added thumbnail to the IGNORE set, but I'm not sure this is the appropriate fix, as I mentioned on Slack.

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.

3 participants