Skip to content

Conversation

@RWShelton
Copy link
Contributor

What

This PR implements the upload_to_table function to create an endpoint/method for uploading taxon interpretations, according to the taxon interpretation file format in the loader module. It follows the same pattern established for the previous PR for strata definitions, #135.

Why

This method comprises another portion of the process for performing bulk uploads. It has also been made available as a separate endpoint for ease of testing.

How

This change uses the same pattern as the previous upload PRs. It calls a utility to validate the incoming data according to the file's requirements, then passes the data into an upload_to_table call for taxon interpretations. Since the taxon interpretation file only contains one table's worth of data, there are no subsequent joins for vb_codes. It takes all resulting vb_codes and passes them back to the user, correlating them to the user_codes they provided.

This method also supports a new dry_run query parameter, for ease of testing. dry_run defaults to false, but if it's set to true, the transaction will automatically roll back at the end, and return to the user what the codes created would have looked like. NB: If there is an error during the process, the response will not include the dry run message, as the transaction is rolled back anyway. the dry run message will show if the transaction would have been successful.

Testing

The following test cases have been executed locally:

  • A successful run with all fields, with both a commit and a dry run rollback
  • A successful run with optional fields omitted, with both a commit and dry run rollback
  • A run that fails because of an incorrect foreign key
  • A run that fails because unsupported additional fields are included in the file
  • A run that fails because required fields are missing

@RWShelton RWShelton requested a review from regetz November 19, 2025 23:50
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.

2 participants