CGSpace Notes

Documenting day-to-day work on the CGSpace repository.

February, 2023

2023-02-01

  • Export CGSpace to cross check the DOI metadata with Crossref
    • I want to try to expand my use of their data to journals, publishers, volumes, issues, etc…
  • First, extract a list of DOIs for use with crossref-doi-lookup.py:
$ csvcut -c 'cg.identifier.doi[en_US]' ~/Downloads/2023-02-01-cgspace.csv \
  | csvgrep -c 1 -m 'doi.org' \
  | csvgrep -c 1 -m ' ' -i \
  | csvgrep -c 1 -r '.*cifor.*' -i \
  | sed 1d > /tmp/2023-02-01-dois.txt
$ ./ilri/crossref-doi-lookup.py -e a.orth@cgiar.org -i /tmp/2023-02-01-dois.txt -o ~/Downloads/2023-01-31-crossref-results.csv -d
  • Then extract the ID, DOI, journal, volume, issue, publisher, etc from the CGSpace dump and rename the cg.identifier.doi[en_US] to doi so we can join on it with the Crossref results file:
$ csvcut -c 'id,cg.identifier.doi[en_US],cg.journal[en_US],cg.volume[en_US],cg.issue[en_US],dcterms.publisher[en_US],cg.number[en_US],dcterms.license[en_US]' ~/Downloads/2023-02-01-cgspace.csv \
  | csvgrep -c 'cg.identifier.doi[en_US]' -r '.*cifor.*' -i \
  | sed -e '1s/cg.identifier.doi\[en_US\]/doi/' \
    -e 's_https://doi.org/__g' \
    -e 's_https://dx.doi.org/__g' \
  > /tmp/2023-02-01-cgspace-doi-metadata.csv
$ csvjoin -c doi /tmp/2023-02-01-cgspace-doi-metadata.csv ~/Downloads/2023-02-01-crossref-results.csv > /tmp/2023-02-01-cgspace-crossref-check.csv
  • And import into OpenRefine for analysis and cleaning
  • I just noticed that Crossref also has types, so we could use that in the future too!
  • I got a few corrections after examining manually, but I didn’t manage to identify any patterns that I could use to do any automatic matching or cleaning

2023-02-05

  • Normalize text lang attributes in PostgreSQL, run a quick Discovery index, and then export CGSpace to check Initiative mappings and countries/regions
  • Run all system updates on CGSpace (linode18) and reboot it

2023-02-06

2023-02-07

  • IFPRI’s web developer Tony managed to get his Drupal harvester to have a useful user agent:
54.x.x.x - - [06/Feb/2023:10:10:32 +0100] "POST /rest/items/find-by-metadata-field?limit=%22100&offset=0 HTTP/1.1" 200 58855 "-" "IFPRI drupal POST harvester"
  • He also noticed that there is no pagination on POST requests to /rest/items/find-by-metadata-field, and that he needs to increase his timeout for requests that return 100+ results, ie:
curl -f -H "Content-Type: application/json" -X POST "https://dspacetest.cgiar.org/rest/items/find-by-metadata-field" -d '{"key":"cg.subject.actionArea", "value":"Systems Transformation", "language": "en_US"}'
  • I need to ask on the DSpace Slack about this POST pagination
  • Abenet and Udana noticed that the Handle server was not running
    • Looking in the error.log file I see that the service is complaining about a lock file being present
    • This is because Linode had to do emergency maintenance on the VM host this morning and the Handle server didn’t shut down properly
  • I’m having an issue with poetry update so I spent some time debugging and filed an issue
  • Proof and import nine items for the Digital Innovation Inititive for IFPRI
    • There were only some minor issues in the metadata
    • I also did a duplicate check with check-duplicates.py just in case
  • I did some minor updates on csv-metadata-quality
    • First, to reduce warnings on non-SPDX licenses like “Copyrighted; all rights reserved” and “Other” since they are very common for us and I’m sick of seeing the warnings
    • Second, to skip whitespace and newline fixes on the abstract field since so many times they are intended

2023-02-08

  • Make some edits to IFPRI records requested by Jawoo and Leigh
  • Help Alessandra upload a last minute report for SAPLING
  • Proof and upload twenty-seven IFPRI records to CGSpace
    • It’s a good thing I did a duplicate check because I found three duplicates!
  • Export CGSpace to update Initiative mappings and country/region mappings
    • Then start a harvest on AReS

2023-02-09

  • Do some minor work on the CSS on the DSpace 7 test

2023-02-10

  • I noticed a large number of PostgreSQL locks from dspaceWeb on CGSpace:
$ psql -c 'SELECT * FROM pg_locks pl LEFT JOIN pg_stat_activity psa ON pl.pid = psa.pid;' | grep -o -E '(dspaceWeb|dspaceApi|dspaceCli)' | sort | uniq -c
   2033 dspaceWeb
  • Looking at the lock age, I see some already 1 day old, including this curious query:
select nextval ('public.registrationdata_seq')
  • I killed all locks that were more than a few hours old
  • Export CGSpace to update Initiative collection mappings
  • Discuss adding dcterms.available to the submission form
    • I also looked in the dcterms.description field on CGSpace and found ~1,500 items where the is an indication of an online published date
    • Using some facets in OpenRefine I narrowed down the ones mentioning “online” and then extracted the dates to a new column:
cells['dcterms.description[en_US]'].value.replace(/.*?(\d+{2}) ([a-zA-Z]+) (\d+{2}).*/,"$3-$2-$1")
  • Then to handle formats like “2022-April-26” and “2021-Nov-11” I used some replacement GRELs (note the order so we don’t replace short patterns in longer strings prematurely):
value.replace("January","01").replace("February","02").replace("March","03").replace("April","04").replace("May","05").replace("June","06").replace("July","07").replace("August","08").replace("September","09").replace("October","10").replace("November","11").replace("December","12")
value.replace("Jan","01").replace("Feb","02").replace("Mar","03").replace("Apr","04").replace("May","05").replace("Jun","06").replace("Jul","07").replace("Aug","08").replace("Sep","09").replace("Oct","10").replace("Nov","11").replace("Dec","12")
  • This covered about 1,300 items, then I did about 100 more messier ones with some more regex wranling
    • I removed the dcterms.description[en_US] field from items where I updated the dates
  • Then I added dcterms.available to the submission form and the item view
    • We need to announce this to the editors