greenelab/lab-website-template

ORCID plugin AttributeError 'NoneType' object has no attribute 'get'

hyphaltip opened this issue · 2 comments

Checks

Link to your website repo

https://lab.stajich.org

Version of Lab Website Template you are using

1.1.4

Description

I see this error from running _cite/cite.py locally or via github workflow:

Running orcid plugin
    Found 1 orcid* data file(s)
    Processing data file orcid.yaml
        Processing entry 1 of 1, orcid: 0000-0002-7591-0020 (from cache)
            'NoneType' object has no attribute 'get'

I assume you're talking about this repo:
https://github.com/stajichlab/stajichlab.github.io
And this is the failed run:
https://github.com/stajichlab/stajichlab.github.io/actions/runs/4983047368/jobs/8919574313

First off, it looks like you have a mix between the old pre-release (<1.0.0) version of the template and the new version (v1+) of the template. There are a bunch of files and options you're using that are no longer needed, your Gemfile.lock doesn't seem to completely match the current upstream one (it's missing platforms), first-time-setup doesn't appear to have been run, etc. These things could be the source of the many errors you're seeing in your Actions runs. The new docs strongly suggest starting fresh with a new repo when going from pre-release to v1+, rather than doing a merge conflict resolution, because the process is just too error prone and too many things were changed.

As for the particular run error in question...

Luckily I can reproduce this issue locally with the latest blank version of the template, and it appears to be an issue with the ORCID api not returning expected or consistent formatted results.

here is the data ORCID is returning for that id number
[
  {
    "put-code": 30820353,
    "created-date": { "value": 1488524763608 },
    "last-modified-date": { "value": 1653488129380 },
    "source": {
      "source-orcid": None,
      "source-client-id": {
        "uri": "https://orcid.org/client/0000-0002-9157-3431",
        "path": "0000-0002-9157-3431",
        "host": "orcid.org"
      },
      "source-name": { "value": "Europe PubMed Central" },
      "assertion-origin-orcid": {
        "uri": "https://orcid.org/0000-0002-7591-0020",
        "path": "0000-0002-7591-0020",
        "host": "orcid.org"
      },
      "assertion-origin-client-id": None,
      "assertion-origin-name": { "value": "Jason Stajich" }
    },
    "title": {
      "title": {
        "value": "RelocaTE2: a high resolution transposable element insertion site mapping tool for population resequencing."
      },
      "subtitle": None,
      "translated-title": None
    },
    "external-ids": {
      "external-id": [
        {
          "external-id-type": "pmid",
          "external-id-value": "28149701",
          "external-id-normalized": { "value": "28149701", "transient": True },
          "external-id-normalized-error": None,
          "external-id-url": None,
          "external-id-relationship": "self"
        },
        {
          "external-id-type": "pmc",
          "external-id-value": "PMC5274521",
          "external-id-normalized": { "value": "5274521", "transient": True },
          "external-id-normalized-error": None,
          "external-id-url": None,
          "external-id-relationship": "self"
        }
      ]
    },
    "url": { "value": "http://europepmc.org/abstract/med/28149701" },
    "type": "journal-article",
    "publication-date": {
      "year": { "value": "2017" },
      "month": None,
      "day": None
    },
    "journal-title": None,
    "visibility": "public",
    "path": "/0000-0002-7591-0020/work/30820353",
    "display-index": "0"
  }
]

And here is a traceback from the error:

Traceback (most recent call last):
  File "/Users/vincerubinetti/Desktop/lab-website-template/_cite/cite.py", line 67, in <module>
    entry = import_module(f"plugins.{plugin.stem}").main(entry)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincerubinetti/Desktop/lab-website-template/_cite/plugins/orcid.py", line 83, in main
    publisher = first(lambda s: s.get("journal-title", {}).get("value", ""))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincerubinetti/Desktop/lab-website-template/_cite/plugins/orcid.py", line 75, in first
    return next(value for value in map(get_func, summaries) if value)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincerubinetti/Desktop/lab-website-template/_cite/plugins/orcid.py", line 75, in <genexpr>
    return next(value for value in map(get_func, summaries) if value)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vincerubinetti/Desktop/lab-website-template/_cite/plugins/orcid.py", line 83, in <lambda>
    publisher = first(lambda s: s.get("journal-title", {}).get("value", ""))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'

You can compare that to the accessions orcid.py is doing. I'll need to add more checks to avoid these types of errors. I'll work to fix this as soon as I can.

I have a working fix in this branch:
https://github.com/greenelab/lab-website-template/tree/v1.1.5

I'll have a PR opened, reviewed, and merged this week.