Skip to content

Commit

Permalink
Merge pull request #199 from simleo/warn_if_ctx_ent_looks_like_data_ent
Browse files Browse the repository at this point in the history
Warn if a contextual entity looks like a data entity
  • Loading branch information
simleo authored Sep 24, 2024
2 parents 074a3f0 + 2ace3e1 commit 5817375
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 5817375

Please sign in to comment.