def ingest(document_id, role_id=None): """Process a given document by extracting its contents. This may include creating or updating child documents.""" document = Document.by_id(document_id) if document is None: log.error("Could not find document: %s", document_id) return get_manager().ingest_document(document, role_id=role_id) pending = Document.pending_count(collection_id=document.collection.id) if pending == 0: ingest_complete(document.collection, role_id=role_id)