Added import task to import a single annotated doc. Also added a test. #110
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.
Summary
This PR borrows code from the
import_corpus
task and creates a new task calledimport_document_to_corpus
. The new task is designed to import a single document with its annotations and labels into an existing corpus. To achieve this, we introduced a new data type calledOpenContractsAnnotatedDocumentImportType
, which represents the JSON data structure for importing a single document along with its annotations and labels. The PDF for the document is converted to a base64 string and provided as a property in this data type.Major changes in this PR include:
OpenContractsAnnotatedDocumentImportType
data type for importing a single document and its annotations and labels.import_corpus
task intoimport_document_to_corpus
task, which accepts the id of the target corpus and the new data typeOpenContractsAnnotatedDocumentImportType
.import_document_to_corpus
task intest_tasks.py
.UploadAnnotatedDocument
: This mutation is responsible for uploading a single annotated document to an existing corpus. It takes two required arguments:target_corpus_id
anddocument_import_data
. Thetarget_corpus_id
is the ID of the target corpus to which the document will be added. Thedocument_import_data
is a string representation of theOpenContractsAnnotatedDocumentImportType
object that contains the necessary information about the document, annotations, and labels. The mutation calls theimport_document_to_corpus
task with the provided arguments and applies it asynchronously.test_upload_annotated_document
: This test is designed to check whether theUploadAnnotatedDocument
mutation works as expected. It sets up the necessary test environment with prerequisites such as a user, a corpus, and sample import data. The test then prepares theupload_annotated_document_mutation
to be executed with the given variables (corpus ID and document import data). After executing the mutation, the test checks whether the response contains "ok" asTrue
and the message as "SUCCESS`, indicating that the task started successfully.