openMetadataInitiative / openMINDS_Python

Python package for the openMINDS metadata models. The package contains all openMINDS schemas as Python classes in addition to schema base classes and utility methods.
MIT License
1 stars 2 forks source link

When reading a JSON-LD file, the attributes of LinkedMetadata nodes inside EmbeddedMetadata nodes are not set properly #26

Closed apdavison closed 1 year ago

apdavison commented 1 year ago

Example:

    uni1 = omcore.Organization(full_name="University of This Place", id="_:uthisp")
    person = omcore.Person(
        given_name="A",
        family_name="Professor",
        affiliation = [omcore.Affiliation(member_of=uni1)],
        id="_:ap"
    )

    c = Collection(person)

    # uni1 was not added explicitly, but should nevertheless be included in the JSON-LD export

    output_paths = c.save("issue0026.jsonld", individual_files=False, include_empty_properties=False)

    new_collection = Collection()
    new_collection.load(*output_paths)
    os.remove("issue0026.jsonld")

    person_again = [item for item in new_collection if isinstance(item, omcore.Person)][0]
    assert len(person_again.affiliation) == 1
    assert person_again.affiliation[0].member_of.full_name == "University of This Place"

gives

 >       assert person_again.affiliation[0].member_of.full_name == "University of This Place"
E       AssertionError: assert None == 'University of This Place'
E        +  where None = <openminds.latest.core.actors.organization.Organization object at 0x10230d1c0>.full_name
E        +    where <openminds.latest.core.actors.organization.Organization object at 0x10230d1c0> = <openminds.latest.core.actors.affiliation.Affiliation object at 0x10230d400>.member_of
apdavison commented 1 year ago

following [56282a4] the error message is now

>       assert person_again.affiliation[0].member_of.full_name == "University of This Place"
E       AttributeError: 'Link' object has no attribute 'full_name'