Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of control_number #501

Open
drjova opened this issue Jul 19, 2024 · 0 comments
Open

Add support of control_number #501

drjova opened this issue Jul 19, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@drjova
Copy link
Contributor

drjova commented Jul 19, 2024

Currently, the disambiguation command only supports triggering the disambiguation task using a uuid. To enhance functionality, we need to add support for control_number as an alternative identifier. This will allow users to trigger disambiguation using either uuid or control_number.

https://github.com/inspirehep/inspirehep/blob/8a8a92c9adb8a3dd9af82c6b6ebcc9b8ebe4a9be/backend/inspirehep/disambiguation/cli.py#L211

TECH NOTES:

  • Update the disambiguate_record_by_uuid function to:

    • Accept a new option --control_number (-cn) alongside the existing --uuid option.
    • Ensure that at least one identifier (uuid or control_number) is provided, making both options individually optional but collectively required.
    • Fetch the record based on the provided identifier (uuid or control_number).
    • Trigger the disambiguation task using the appropriate record identifier.
  • Implement the necessary logic to fetch records by control_number. Ensure that:

    • Use LiteratureRecord.get_record_by_control_number
  • Update error handling to provide appropriate messages when:

    • Neither uuid nor control_number is provided.
    • The record cannot be found for the provided identifier.

Example implementaion:

@disambiguation.command(name="record")
@with_appcontext
@click.option("-id", "--uuid", type=str, required=False, help="UUID of the record")
@click.option("-cn", "--control_number", type=int, required=False, help="Control number of the record")
def disambiguate_record_by_identifier(uuid, control_number):
    """
    if not uuid and not control_number:
        click.echo("Error: Either UUID or control_number must be provided.", err=True)
        return

    if uuid:
        record = LiteratureRecord.get_record(uuid)
    elif control_number:
        record = LiteratureRecord.get_record_by_control_number(control_number)

    if not record:
        click.echo(f"Error: Record not found for UUID: {uuid} or Control Number: {control_number}", err=True)
        return

    # Trigger disambiguation task
    disambiguate_authors.delay(
        record.id, 
        record.model.version_id,
        disambiguate_all_not_disambiguated=True
    )
@drjova drjova added the good first issue Good for newcomers label Jul 19, 2024
@DonHaul DonHaul assigned DonHaul and unassigned DonHaul Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants