Skip to content

Commit

Permalink
warn if a contextual entity looks like a data entity
Browse files Browse the repository at this point in the history
  • Loading branch information
simleo committed Sep 23, 2024
1 parent 074a3f0 commit 2ace3e1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rocrate/rocrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import os
import shutil
import tempfile
import warnings

from collections import OrderedDict
from pathlib import Path
Expand Down Expand Up @@ -174,7 +175,11 @@ def __add_parts(self, parts, entities, source):

def __read_contextual_entities(self, entities):
type_map = {_.__name__: _ for _ in subclasses(ContextEntity)}
# types *commonly* used for data entities
data_entity_types = {"File", "Dataset"}
for identifier, entity in entities.items():
if data_entity_types.intersection(as_list(entity.get("@type", []))):
warnings.warn(f"{entity['@id']} looks like a data entity but it's not listed in the root dataset's hasPart")
assert identifier == entity.pop('@id')
cls = pick_type(entity, type_map, fallback=ContextEntity)
self.add(cls(self, identifier, entity))
Expand Down

0 comments on commit 2ace3e1

Please sign in to comment.