Skip to content

Commit 94baec0

Browse files
committed
Add single record affiliation enhancement script
1 parent 64e3001 commit 94baec0

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

ames/matchers/caltechauthors.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ def process_link_updates(input_csv):
563563
return results
564564

565565

566-
def add_authors_affiliations(record, token, dimensions_key, allowed_identifiers=None):
566+
def add_authors_affiliations(
567+
record, token, dimensions_key, allowed_identifiers=None, ignore_mismatch=False
568+
):
567569
# Add dimensions affiliations to a record
568570

569571
record_id = record["id"]
@@ -592,7 +594,7 @@ def add_authors_affiliations(record, token, dimensions_key, allowed_identifiers=
592594
publication = publication[0]
593595
dimensions_authors = publication.get("authors", [])
594596
existing_authors = record["metadata"]["creators"]
595-
if len(dimensions_authors) == len(existing_authors):
597+
if len(dimensions_authors) == len(existing_authors) or ignore_mismatch:
596598
for position in range(len(dimensions_authors)):
597599
author = existing_authors[position]
598600
dimensions_author = dimensions_authors[position]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os, sys, argparse, json
2+
from ames.matchers import add_authors_affiliations
3+
from caltechdata_api import get_metadata
4+
5+
token = os.environ["CTATOK"]
6+
dimensions_key = os.environ["DIMKEY"]
7+
8+
parser = argparse.ArgumentParser(
9+
prog="authors_affitiliation_enhancement_singlerecord",
10+
description="Adds affiliations from dimensions to single authors record, ignoring any mismatch in author numbers",
11+
)
12+
13+
parser.add_argument(
14+
"record_identifier", type=str, help="The rdm record identifier to enhance"
15+
)
16+
17+
args = parser.parse_args()
18+
record_identifier = args.record_identifier
19+
record = get_metadata(record_identifier, authors=True)
20+
21+
add_authors_affiliations(record, token, dimensions_key, ignore_mismatch=True)

0 commit comments

Comments
 (0)