From 2ace3e1dfcf5d6ac18ea2a1552e621d90383b543 Mon Sep 17 00:00:00 2001 From: simleo Date: Mon, 23 Sep 2024 16:32:21 +0200 Subject: [PATCH] warn if a contextual entity looks like a data entity --- rocrate/rocrate.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rocrate/rocrate.py b/rocrate/rocrate.py index 63f2eb3..2adefa2 100644 --- a/rocrate/rocrate.py +++ b/rocrate/rocrate.py @@ -24,6 +24,7 @@ import os import shutil import tempfile +import warnings from collections import OrderedDict from pathlib import Path @@ -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))