Skip to content

fix(harvester): skip harvest when metadata did not change - #968

Open
TahaKhan998 wants to merge 1 commit into
CERNDocumentServer:masterfrom
TahaKhan998:fix/harvester-skip-unchanged-metadata
Open

fix(harvester): skip harvest when metadata did not change#968
TahaKhan998 wants to merge 1 commit into
CERNDocumentServer:masterfrom
TahaKhan998:fix/harvester-skip-unchanged-metadata

Conversation

@TahaKhan998

Copy link
Copy Markdown

closes #941

inspire 2970770 / cds mat8t-f6991, skip compared these custom fields and thought they changed:

stored:
{
"cern:programmes": {"id": "None"},
"thesis:thesis": {"university": "KIT", "type": "PhD"}
}

merged:
{
"cern:programmes": {"id": "None"},
"thesis:thesis": {"university": "KIT", "type": "phd"},
"cern:accelerators": [],
"cern:experiments": []
}

empty lists vs missing keys, and phd vs PhD. we published, dump dropped the empty lists and put PhD back, view changes only showed revision_id and updated.

same thing for cds dois:

stored: {"doi": {"identifier": "10.17181/CERN.ABCD", "provider": "datacite", "client": "datacite"}}
merged: {"doi": {"identifier": "10.17181/CERN.ABCD", "provider": "datacite"}}

now we ignore empty list vs missing, treat phd/PhD as the same, and for dois only compare identifier + provider.

return left == right


def _present_keys(value):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename this to be more readable, wdyt?

return False
return all(compare_metadata(x, y) for x, y in zip(a, b))

if isinstance(a, str) and isinstance(b, str):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add some comments for context

for pids in (left, right):
doi = pids.get("doi")
if doi:
pids["doi"] = {k: doi[k] for k in ("identifier", "provider") if k in doi}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loop seems like an overkill decreasing readability just for 2 keys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[INSPIRE Harvester] Skip harvest when metadata did not change

2 participants