Skip to content

add(scripts): combine dumping duplicated record methods and search ep report number duplicates - #578

Open
zubeydecivelek wants to merge 1 commit into
CERNDocumentServer:masterfrom
zubeydecivelek:redirect-script
Open

add(scripts): combine dumping duplicated record methods and search ep report number duplicates#578
zubeydecivelek wants to merge 1 commit into
CERNDocumentServer:masterfrom
zubeydecivelek:redirect-script

Conversation

@zubeydecivelek

@zubeydecivelek zubeydecivelek commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

combined duplicated record search so we have one step in https://gitlab.cern.ch/cds-team/cds-rdm-openshift/-/blob/master/.gitlab/issue_templates/migration.md

added a new script to check if there is any ep report number in the collection has duplicates


UPDATE: combined script added, redirect and ep report number script will be removed
45143ed

update here after this pr merged: https://gitlab.cern.ch/digital-repositories/internal-docs/-/merge_requests/251
and update migration issue template: https://gitlab.cern.ch/cds-team/cds-rdm-openshift/-/blob/master/.gitlab/issue_templates/migration.md?ref_type=heads

@zubeydecivelek zubeydecivelek moved this to In review 🔍 in Sprint Q3 2026 ☀️ Aug 18, 2026
@zubeydecivelek zubeydecivelek changed the title (scripts): combine dumping duplicated record methods add(scripts): combine dumping duplicated record methods and search ep report number duplicates Aug 18, 2026
@zubeydecivelek
zubeydecivelek requested review from kpsherva and zzacharo and removed request for kpsherva August 18, 2026 12:09
Comment thread scripts/search_ep_report_number_dups.py Outdated
Comment thread scripts/search_ep_report_number_dups.py Outdated

EP_RE = re.compile(r"^(?:CERN-EP|CERN-PH-EP|CERN-PPE|CERN-TH-EP)-\d{2}(?:\d{2})?-\d+$")
RN_TAGS = ("037__a", "037__9", "088__a", "088__9", "9031_b", "909C0r")
SEARCH_FIELDS = ("reportnumber", "037", "088", "9031_", "909C0r")

@kpsherva kpsherva Aug 18, 2026

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.

why 909C0r field?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's added report number in legacy i was trying to find all the fields can have report number. I dont know if we have any example, i added just in case, if you think it's not needed i can remove

Comment thread scripts/dump_legacy_recids_to_redirect.py Outdated
Comment on lines +107 to +110
"""Keep a live record; prefer SSO among live ones, else the first live.

Deleted recids become redirect keys. If every recid is deleted, fall
back to SSO then the first in the list.

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.

what does it mean that record is live? why do we prefer SSO?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it was already prefering SSO, i didnt changed that https://github.com/CERNDocumentServer/cds-migrator-kit/blob/master/scripts/dump_legacy_recids_to_redirect.py#L83-L85

but i had duplicates of the same recids for example:
2767378: 2766207,
2766207: 2767378,
and we should select the one is not deleted. I'll change the explanation

Comment thread scripts/dump_legacy_recids_to_redirect.py Outdated
Comment thread scripts/search_ep_report_number_dups.py Outdated


# Configure the collection before running.
collection_q = '980__a:ARTICLE or 980__a:PREPRINT or 980__a:CONFERENCENOTE or 980__a:SLIDE or 980:CONFERENCEPAPER or 980__a:NOTE and 693:"FASER" -980__a:SCICOMMPUBLLHCC'

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.

what if the duplicate is outside this collection, like it happened with one record of FASER?

@zubeydecivelek zubeydecivelek Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it searches the whole cds for any ep report number not the collection.

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.

how do I define the collection query then? If it is whole CDS, do we need the collection query?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

collection query is your selected collection query for migration. script is collecting all the ep report numbers using your query and searches whole cds to find if there is any duplicate

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.

Understood! Can we call this code using the query from the model I added and integrate it as part of the migration step? Like an analysis step, after extract and before transform? The point is to reduce the amount of extra manual steps we need to run apart from the migrate collection run...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I understand and I'm also trying to reduce the manual steps, but we need to run this in cds legacy so i think this has to be a manual step :( Or we can combine dump_legacy_recids_to_redirect.py and search_ep_report_number_dups.py` scripts. what do you think?

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 see, I forgot that these are running to legacy.... I think it would be nice to combine into one new script that does an analysis and outputs content that is then used as input to the migration. I would still make this running as e.g ./analyze_collection_migration.py --collection-query='....' --param a etc. and have a clear path of steps inside that produce a consistent output that is then copied over in the new under migraiton collection.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a new script, can we add the script to the legacy main node? so we'll just need to run the command?

    sudo -u apache python2 scripts/analyze_collection_migration.py \\
        --collection-name faser \\
        --collection-q '980__a:ARTICLE or 980__a:PREPRINT and 693:"FASER"'

I kept the previous scripts so you can compare, i just combined 2 scripts. if it looks ok i'll remove the other 2 scripts.

@kpsherva @zzacharo

@zubeydecivelek
zubeydecivelek force-pushed the redirect-script branch 2 times, most recently from e27a78c to 6b52ca7 Compare August 18, 2026 14:00
@kpsherva kpsherva moved this from In review 🔍 to In progress in Sprint Q3 2026 ☀️ Aug 18, 2026
@zubeydecivelek zubeydecivelek removed their assignment Aug 19, 2026
@zubeydecivelek zubeydecivelek moved this from In progress to In review 🔍 in Sprint Q3 2026 ☀️ Aug 19, 2026
Comment thread scripts/dump_legacy_recids_to_redirect.py Outdated
Comment thread scripts/search_ep_report_number_dups.py Outdated
Comment thread scripts/dump_legacy_recids_to_redirect.py Outdated
Comment thread scripts/search_ep_report_number_dups.py Outdated


# Configure the collection before running.
collection_q = '980__a:ARTICLE or 980__a:PREPRINT or 980__a:CONFERENCENOTE or 980__a:SLIDE or 980:CONFERENCEPAPER or 980__a:NOTE and 693:"FASER" -980__a:SCICOMMPUBLLHCC'

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.

how do I define the collection query then? If it is whole CDS, do we need the collection query?

@zzacharo zzacharo moved this from In review 🔍 to In progress in Sprint Q3 2026 ☀️ Aug 20, 2026
@zubeydecivelek
zubeydecivelek force-pushed the redirect-script branch 2 times, most recently from 6066b5b to 45143ed Compare August 20, 2026 13:54
@zubeydecivelek zubeydecivelek moved this from In progress to In review 🔍 in Sprint Q3 2026 ☀️ Aug 20, 2026
@zubeydecivelek zubeydecivelek removed their assignment Aug 21, 2026
Comment thread scripts/analyze_collection_migration.py
Comment thread scripts/analyze_collection_migration.py Outdated
Comment thread scripts/analyze_collection_migration.py Outdated
Comment on lines +290 to +292
"CDS search query for the collection. Do not use -980:DELETED "
"-980:HIDDEN -980__c:MIGRATED -980__a:DUMMY. Include any 710__g "
'clauses, e.g. 710__g:"IT" or 710__g:"CN".'

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.

Suggested change
"CDS search query for the collection. Do not use -980:DELETED "
"-980:HIDDEN -980__c:MIGRATED -980__a:DUMMY. Include any 710__g "
'clauses, e.g. 710__g:"IT" or 710__g:"CN".'
"CDS search query for the collection. Do not use -980__c:MIGRATED'

because we do want to exclude from duplicate searched hidden, deleted and dummy records

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i remember we want to mint the legacy recid of the deleted redirected records (for example duplicated record deleted and keeps the redirect record id in 970__d: example record) in the rdm record. if we want to do this we should not exclude the deleted records.

@palkerecsenyi palkerecsenyi moved this from In review 🔍 to In progress in Sprint Q3 2026 ☀️ Aug 24, 2026
@zubeydecivelek zubeydecivelek moved this from In progress to In review 🔍 in Sprint Q3 2026 ☀️ Aug 24, 2026
@zubeydecivelek zubeydecivelek removed their assignment Aug 24, 2026
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.

4 participants