proycon / codemetapy

A Python package for generating and working with codemeta
https://codemeta.github.io/
GNU General Public License v3.0
24 stars 5 forks source link

Bug: codemetapy incorrectly expands a url into a nested Person inside of a Person #46

Closed apirogov closed 11 months ago

apirogov commented 1 year ago

Inputs:

package.json:

{
  "name": "somesy",
  "version": "0.1.0",
  "description": "A cli tool for synchronizing CITATION.CFF with project files.",
  "keywords": [
    "metadata",
    "FAIR"
  ],
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/Materials-Data-Science-and-Informatics/somesy"
  },
  "homepage": "https://materials-data-science-and-informatics.github.io/somesy",
  "author": {
    "name": "Mustafa Soylu",
    "email": "m.soylu@fz-juelich.de",
    "url": "https://orcid.org/0000-0003-2637-0432"
  },
  "contributors": [
    {
      "name": "Mustafa Soylu",
      "email": "m.soylu@fz-juelich.de",
      "url": "https://orcid.org/0000-0003-2637-0432"
    },
    {
      "name": "Anton Pirogov",
      "email": "a.pirogov@fz-juelich.de",
      "url": "https://orcid.org/0000-0002-5077-7497"
    },
    {
      "name": "Jens Br\u00f6der",
      "email": "j.broeder@fz-juelich.de",
      "url": "https://orcid.org/0000-0001-7939-226X"
    }
  ],
  "main": "index.js",
  "scripts": {
    "test": "echo \"No tests available\""
  },
  "dependencies": {
    "lodash": "^4.17.21",
    "axios": "^0.21.1"
  },
  "devDependencies": {
    "jest": "^27.0.6"
  }
}

extra_codemeta.json:

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "author": [
    {
      "@id": "https://orcid.org/0000-0003-2637-0432",
      "@type": "Person",
      "familyName": "Soylu",
      "givenName": "Mustafa"
    },
    {
      "@id": "https://orcid.org/0000-0002-5077-7497",
      "@type": "Person",
      "familyName": "Pirogov",
      "givenName": "Anton"
    }
  ],
  "codeRepository": "https://github.com/Materials-Data-Science-and-Informatics/somesy",
  "description": "A cli tool for synchronizing CITATION.CFF with project files.",
  "keywords": [
    "metadata",
    "FAIR"
  ],
  "license": "https://spdx.org/licenses/MIT",
  "name": "somesy",
  "url": "https://materials-data-science-and-informatics.github.io/somesy",
  "version": "0.1.0"
}

Output (codemetapy package.json extra_codemeta.json):

[...]
    "contributor": [
        {
            "@type": "Person",
            "email": "m.soylu@fz-juelich.de",
            "familyName": "Soylu",
            "givenName": "Mustafa",
            "url": {
                "@id": "https://orcid.org/0000-0003-2637-0432",
                "@type": "Person",
                "familyName": "Soylu",
                "givenName": "Mustafa"
            }
        },
        {
            "@type": "Person",
            "email": "a.pirogov@fz-juelich.de",
            "familyName": "Pirogov",
            "givenName": "Anton"
        },
        {
            "@type": "Person",
            "email": "j.broeder@fz-juelich.de",
            "familyName": "Bröder",
            "givenName": "Jens"
        }
    ],
[...]

The fact that the Orcid / URL field vanishes for other contributors I reported in #45

but the other independent problem is that apparently something in the merge goes wrong - the url is expanded into another person object, leading to this weird and incorrect nested Person entry.

Expected: The url is not expanded into a nested Person. Either map it to @id, or keep it as url (because url could also be a homepage, and that is a bad @id if you merge from different sources could cause problems assuming that url is a good Person @id, unless its an ORCID), I don't know, but it should remain a string.

proycon commented 11 months ago

Ouch, this is indeed problematic. Codemetapy is a bit eager to turn strings into resource references if there is such @id in the graph. It's a bit hacky but it removes a certain class of errors. This however is a clear case where it goes wrong. I'll probably exempt the url property (and some more like it) from this behaviour so that it will solve at least this case.

proycon commented 11 months ago

Fixed and released now