Feature 170 upload taxon interpretations #172
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: