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

[No Ticket] Bulk Upload: More Task Fixes #9784

Conversation

cslzchen
Copy link
Contributor

@cslzchen cslzchen commented Oct 4, 2021

Purpose

Bulk Upload: Task Fixes

Changes

  • This PR contains three bug fixes that address release blocking issues
    • The first two are for bugs
      • 1 Added registration responses validation
      • 2 Only project admin can create registration from it, thus this bug is not triggered.
    • The 3rd completes the register and approval-require flow for non-auto-approval providers, which removes the pre-release blocker
      • 3 Moved .register() and .require_approval() out of the auto-approval flow and improved exception handling

There will be another PR for more minor improves

QA Notes

See https://www.notion.so/cos/Bugs-1802b3efdc92481ebb0fc437663cfb8f

Side Effects

N/A

Ticket

N/A

Copy link
Contributor Author

@cslzchen cslzchen left a comment

Choose a reason for hiding this comment

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

@fabmiz and @adlius , ready for CR. Feel free to merge if looks good so that @DougCorell can test

Comment on lines -349 to +351
if initiator_contributor.permission not in [WRITE, ADMIN]:
error = 'Initiator [{}] must at least have WRITE permission on the project [{}]'.format(initiator._id, node._id)
if initiator_contributor.permission != ADMIN:
error = 'Initiator [{}] must have admin permission on the project [{}]'.format(initiator._id, node._id)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only node admin can create from node

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to make sure CL knows about this.

Comment on lines 492 to 493
# TODO: figure out why validation fails when `required_fields=True`
draft.validate_registration_responses(responses, required_fields=False)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

First, draft.validate_metadata() fails as expected since the API code only log the exception.

In addition, draft.validate_registration_responses(responses, required_fields=False) actually caught an issue I had in the CSV template (empty answer to Q27).

However, draft.validate_registration_responses(responses, required_fields=True) fails even I have every cell populated.

Copy link
Contributor

Choose a reason for hiding this comment

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

So what is the ValidationError thrown when required_fields=True?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, removed.

Comment on lines 536 to 553
try:
registration = draft.register(auth, save=True)
except NodeStateError as e:
error = f'Fail to register draft: {repr(e)}'
raise RegistrationBulkCreationRowError(row.upload.id, row.id, row_title, row_external_id, error=error)
except Exception as e:
raise RegistrationBulkCreationRowError(row.upload.id, row.id, row_title, row_external_id, error=repr(e))
logger.info('Registration [{}] created from draft [{}]'.format(registration._id, row.draft_registration._id))

# Requires approval
try:
registration.require_approval(initiator)
except NodeStateError as e:
error = f'Fail to require approval: {repr(e)}'
raise RegistrationBulkCreationRowError(row.upload.id, row.id, row_title, row_external_id, error=error)
except Exception as e:
raise RegistrationBulkCreationRowError(row.upload.id, row.id, row_title, row_external_id, error=repr(e))
logger.info('Approval required for registration [{}]'.format(registration._id))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to catch all exceptions just in case since the tasks don't have the roll-back on exception that the API has.

@cslzchen cslzchen merged commit e05b6b8 into CenterForOpenScience:feature/bulk_upload Oct 4, 2021
@cslzchen cslzchen deleted the feature/bulk-upload-task-fixes branch March 18, 2022 04:18
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.

None yet

2 participants