:py:mod:`api.admin` =================== .. py:module:: api.admin Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 actions/index.rst models/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: api.admin.ReportErrorModelAdminMixin api.admin.DatasetAdmin api.admin.ProjectAnnotateEntitiesAdmin api.admin.ProjectGroupAdmin api.admin.AnnotatedEntityAdmin api.admin.ConceptDBAdmin api.admin.VocabularyAdmin api.admin.ModelPackAdmin api.admin.MetaCATModelAdmin api.admin.MetaAnnotationAdmin api.admin.DocumentAdmin api.admin.ExportedProjectAdmin api.admin.ProjectMetricsAdmin api.admin.AnnotatedEntity api.admin.MetaAnnotation api.admin.EntityRelation api.admin.Document api.admin.ConceptDB api.admin.ModelPack api.admin.Vocabulary api.admin.MetaCATModel api.admin.Dataset api.admin.DatasetForm api.admin.ProjectFields api.admin.Project api.admin.Entity api.admin.Relation api.admin.MetaTaskValue api.admin.MetaTask api.admin.ProjectAnnotateEntitiesFields api.admin.ProjectAnnotateEntities api.admin.ProjectGroup api.admin.ExportedProject api.admin.ProjectMetrics api.admin.AnnotatedEntity api.admin.MetaAnnotation api.admin.EntityRelation api.admin.Document api.admin.ConceptDB api.admin.ModelPack api.admin.ConceptDB api.admin.Vocabulary api.admin.MetaCATModel api.admin.Dataset api.admin.DatasetForm api.admin.Document api.admin.ProjectFields api.admin.Project api.admin.Entity api.admin.Relation api.admin.EntityRelation api.admin.AnnotatedEntity api.admin.MetaTaskValue api.admin.MetaTask api.admin.ProjectAnnotateEntitiesFields api.admin.ProjectAnnotateEntities api.admin.ProjectGroup api.admin.MetaAnnotation api.admin.ExportedProject api.admin.ProjectMetrics Functions ~~~~~~~~~ .. autoapisummary:: api.admin.drop_collection api.admin.import_all_concepts api.admin.clear_cdb_cnf_addons api.admin.reset_project api.admin.download_without_text api.admin.download_without_text_with_doc_names api.admin.download_projects_without_text api.admin.download api.admin.download_projects_with_text api.admin.retrieve_project_data api.admin.clone_projects api.admin.dataset_document_counts api.admin._reset_cdb_filters api.admin.import_concepts_from_cdb api.admin.reset_cdb_filters api.admin.import_concepts api.admin.delete_indexed_concepts api.admin.remove_all_documents api.admin.auto_delete_cdb_file_on_delete api.admin.auto_delete_vocab_file_on_delete api.admin.auto_delete_dataset_file_on_delete api.admin._remove_file api.admin.drop_collection api.admin.import_all_concepts api.admin.clear_cdb_cnf_addons api.admin.reset_project api.admin.download_without_text api.admin.download_without_text_with_doc_names api.admin.download_projects_without_text api.admin.download api.admin.download_projects_with_text api.admin.retrieve_project_data api.admin.clone_projects api.admin.dataset_document_counts api.admin._reset_cdb_filters api.admin.import_concepts_from_cdb api.admin.reset_cdb_filters api.admin.import_concepts api.admin.delete_indexed_concepts api.admin.remove_all_documents api.admin.auto_delete_cdb_file_on_delete api.admin.auto_delete_vocab_file_on_delete api.admin.auto_delete_dataset_file_on_delete api.admin._remove_file Attributes ~~~~~~~~~~ .. autoapisummary:: api.admin._PROJECT_ANNO_ENTS_SETTINGS_FIELD_ORDER api.admin._PROJECT_FIELDS_ORDER api.admin.logger api.admin._dt_fmt api.admin.STATUS_CHOICES api.admin.BOOL_CHOICES api.admin.cdb_name_validator api.admin.logger api.admin._dt_fmt api.admin.STATUS_CHOICES api.admin.BOOL_CHOICES api.admin.cdb_name_validator api.admin.logger .. py:data:: _PROJECT_ANNO_ENTS_SETTINGS_FIELD_ORDER :value: ('concept_db', 'vocab', 'model_pack', 'cdb_search_filter', 'deid_model_annotation',... .. py:data:: _PROJECT_FIELDS_ORDER :value: ('cuis', 'cuis_file', 'annotation_classification', 'project_locked', 'project_status') .. py:class:: ReportErrorModelAdminMixin Mixin to catch all errors in the Django Admin and map them to user-visible errors. .. py:method:: changeform_view(request, object_id=None, form_url='', extra_context=None) .. py:class:: DatasetAdmin Bases: :py:obj:`ReportErrorModelAdminMixin`, :py:obj:`django.contrib.admin.ModelAdmin` Mixin to catch all errors in the Django Admin and map them to user-visible errors. .. py:attribute:: model .. py:attribute:: form .. py:attribute:: list_display .. py:class:: ProjectAnnotateEntitiesAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: model .. py:attribute:: actions .. py:attribute:: list_filter :value: ('members', 'project_status', 'project_locked', 'annotation_classification') .. py:attribute:: list_display :value: ['name'] .. py:attribute:: fields .. py:method:: formfield_for_foreignkey(db_field, request, **kwargs) .. py:method:: formfield_for_manytomany(db_field, request, **kwargs) .. py:class:: ProjectGroupAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:class:: Meta .. py:attribute:: model .. py:attribute:: model .. py:attribute:: list_display :value: ('name', 'description') .. py:attribute:: fields .. py:method:: get_form(request, obj=None, change=False, **kwargs) .. py:method:: _set_proj_from_group(proj, group, annotator, admins, cdb_search_filters, tasks, relations) .. py:method:: save_model(request, obj, form, change) .. py:class:: AnnotatedEntityAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: list_display :value: ('user', 'project', 'entity', 'value', 'deleted', 'validated') .. py:attribute:: list_filter :value: ('user', 'project', 'deleted', 'validated') .. py:attribute:: model .. py:class:: ConceptDBAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: model .. py:attribute:: actions .. py:attribute:: list_display :value: ('name', 'use_for_training', 'create_time', 'last_modified', 'last_modified_by') .. py:attribute:: fields :value: ('name', 'cdb_file', 'use_for_training') .. py:method:: save_model(request, obj, form, change) .. py:class:: VocabularyAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: model .. py:attribute:: list_display :value: ('name', 'create_time', 'last_modified', 'last_modified_by') .. py:attribute:: fields :value: ('name', 'vocab_file', 'create_time', 'last_modified', 'last_modified_by') .. py:method:: save_model(request, obj, form, change) .. py:class:: ModelPackAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: model .. py:attribute:: list_display :value: ('name', 'model_pack', 'concept_db', 'vocab', 'metacats') .. py:attribute:: fields :value: ['name', 'model_pack'] .. py:method:: metacats(obj) .. py:method:: save_model(request, obj, form, change) .. py:class:: MetaCATModelAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: model .. py:attribute:: list_display :value: ('name', 'meta_cat_dir') .. py:class:: MetaAnnotationAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: model .. py:attribute:: list_display :value: ('annotated_entity', 'meta_task', 'meta_task_value', 'acc', 'predicted_meta_task_value',... .. py:attribute:: list_filter :value: ('meta_task', 'meta_task_value', 'predicted_meta_task_value', 'validated') .. py:class:: DocumentAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: model .. py:attribute:: actions .. py:attribute:: list_filter :value: ('dataset',) .. py:attribute:: list_display :value: ['name', 'create_time', 'dataset', 'last_modified'] .. py:class:: ExportedProjectAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: model .. py:class:: ProjectMetricsAdmin Bases: :py:obj:`django.contrib.admin.ModelAdmin` .. py:attribute:: model .. py:attribute:: list_display :value: ('report_name', 'report_name_generated') .. py:attribute:: list_filter :value: ['projects'] .. py:class:: AnnotatedEntity Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: user .. py:attribute:: project .. py:attribute:: document .. py:attribute:: entity .. py:attribute:: value .. py:attribute:: start_ind .. py:attribute:: end_ind .. py:attribute:: acc .. py:attribute:: comment .. py:attribute:: validated .. py:attribute:: correct .. py:attribute:: alternative .. py:attribute:: manually_created .. py:attribute:: deleted .. py:attribute:: killed .. py:attribute:: irrelevant .. py:attribute:: create_time .. py:attribute:: last_modified .. py:method:: save(*args, **kwargs) .. py:method:: __str__() .. py:class:: MetaAnnotation Bases: :py:obj:`django.db.models.Model` .. py:attribute:: annotated_entity .. py:attribute:: meta_task .. py:attribute:: meta_task_value .. py:attribute:: acc .. py:attribute:: predicted_meta_task_value .. py:attribute:: validated .. py:attribute:: last_modified .. py:method:: save(*args, **kwargs) .. py:method:: __str__() .. py:class:: EntityRelation Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: user .. py:attribute:: project .. py:attribute:: document .. py:attribute:: relation .. py:attribute:: start_entity .. py:attribute:: end_entity .. py:attribute:: validated .. py:attribute:: create_time .. py:attribute:: last_modified .. py:method:: save(*args, **kwargs) .. py:method:: __str__() .. py:class:: Document Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: name .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: text .. py:attribute:: dataset .. py:method:: __str__() .. py:class:: ConceptDB(*args, **kwargs) Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: cdb_file .. py:attribute:: use_for_training .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: last_modified_by .. py:method:: __init__(*args, **kwargs) .. py:method:: from_db(db, field_names, values) :classmethod: .. py:method:: save(*args, skip_load=False, **kwargs) .. py:method:: __str__() .. py:function:: drop_collection(cdb_model) .. py:function:: import_all_concepts(cdb, cdb_model) .. py:function:: clear_cdb_cnf_addons(cdb, cdb_id) .. py:data:: logger .. py:data:: _dt_fmt :value: '%Y-%m-%d %H:%M:%S.%f' .. py:function:: reset_project(modeladmin, request, queryset) .. py:function:: download_without_text(modeladmin, request, queryset) .. py:function:: download_without_text_with_doc_names(modeladmin, request, queryset) .. py:function:: download_projects_without_text(projects, with_doc_name) .. py:function:: download(modeladmin, request, queryset) .. py:function:: download_projects_with_text(projects) .. py:function:: retrieve_project_data(projects) A function to convert a list of projects and: - their associated documents, - their associated annotations, - their associated Meta annotations and Relation Annotations for serialization. Output schema is as follows: ((optional) indicates this field isn't required for training a MedCAT model) { "projects": [ { "name": "" # the auto-generated id of the project (optional) "project_group_id": "" # the auto-generated id of the project - nullable "project_group_name": "" # the name of the project group if set. "project_status": "" # status - either annotating, discontinued, complete "project_locked": "" # locked - for no further annotations "cuis": ["cui_1", "cui_2" ... ] # the CUI filter for the project, includes those from file / and text-box "meta_anno_defs": [ # list of meta annotation tasks configured for this project. { "name": "Name of meta annotation task", "values": [ "", "" ... ], }, ... more meta_annotation tasks configured for this project ], "relation_anno_defs": [ "", "" ... more relation annotation task names configured for this project ] "documents": [ { "id": "" # the auto-generated id of the document (optional) "name": "" # the name of the document (optional), but used in stat printing during training "text": "" # the text of the document "last_modified": "" # the last modified-time (optional) "annotations": [{ "id": "" # the auto-generated id of the document (optional) "name": "" # the user who made the annotation (optional) "cui": "" # the cui label for this annotation "value": "" # the text span for this annotation "start": # the start index of this annotation with respect to the document text "end": # the end index of this annotation with respect to the document text "validated": # if the annotation has been marked by a human annotator "correct": # if the text span is correctly linked to the CUI of this annotation "deleted": # if the text span was incorrectly linked or 'not' linked by MedCAT due to low scores "alternative": # if the text span was incorrectly linked by MedCAT, then correctly linked by a human annotator "killed": # if a human annotator 'terminated' this annotation "irrelevant": # if a human annotator has marked an annotation as irrelevant (optional) "acc": # accuracy provided by MedCAT (optional) "comment": "" # the text entered by an annotator during annotation (optional) "meta_anns": [ # list of meta annotations if applicable to project { "name": # Meta anno task name, i.e. temporality "value": # the selected meta anno task value for, ie. "past" or "present" "acc": # default 1, (optional) "validated": # Meta annotation has been made by a human annotator, default (true) }, ... ]}, ... ] "relations": [ { "start_entity": # id of above annotation that is the start of this relation "start_entity_cui": "" # the cui label of the start of this relation "start_entity_value": # value of the start annotation for this relation "start_entity_start_idx": # start index of text span of start of relation "start_entity_end_idx": # end index of text span of start of relation "end_entity": # id of the above annotation that is the end of this relation "end_entity_cui": "" # the cui label of the end of this relation "end_entity_value": # value of the end annotation for this relation "end_entity_start_idx": # end index of text span of end of relation "end_entity_end_idx": # end index of text span of end of relation "user": # username of annotator for relation (optional) "relation": # label for this relation "validated": # if the annotation has been validated by a human annotator, default true. } ... < more relations of the samve above structure> ] ... ] ] } Args: projects (QuerySet): the projects to export data for. .. py:function:: clone_projects(modeladmin, request, queryset) .. py:function:: dataset_document_counts(dataset) .. py:function:: _reset_cdb_filters(id) .. py:function:: import_concepts_from_cdb(cdb_model_id) .. py:function:: reset_cdb_filters(modeladmin, request, queryset) .. py:function:: import_concepts(modeladmin, request, queryset) .. py:function:: delete_indexed_concepts(modeladmin, request, queryset) .. py:function:: remove_all_documents(modeladmin, request, queryset) .. py:data:: STATUS_CHOICES :value: [(0, 'Not Validated'), (1, 'Validated')] .. py:data:: BOOL_CHOICES :value: [(0, 'False'), (1, 'True')] .. py:data:: cdb_name_validator .. py:class:: ModelPack Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: model_pack .. py:attribute:: concept_db .. py:attribute:: vocab .. py:attribute:: meta_cats .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: last_modified_by .. py:method:: save(*args, skip_load=False, **kwargs) .. py:method:: __str__() .. py:class:: Vocabulary Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: vocab_file .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: last_modified_by .. py:method:: save(*args, skip_load=False, **kwargs) .. py:method:: __str__() .. py:class:: MetaCATModel Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: meta_cat_dir .. py:method:: get_or_create_meta_tasks_and_values(meta_cat) .. py:method:: save(*args, unpack_load_meta_cat_dir=False, **kwargs) .. py:method:: __str__() .. py:class:: Dataset Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: original_file .. py:attribute:: create_time .. py:attribute:: description .. py:method:: __str__() .. py:class:: DatasetForm Bases: :py:obj:`django.forms.ModelForm` .. py:method:: clean() .. py:class:: ProjectFields Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: abstract :value: True .. py:attribute:: PROJECT_STATUSES :value: [('A', 'Annotating'), ('D', 'Discontinued (Fail)'), ('C', 'Complete')] .. py:attribute:: name .. py:attribute:: description .. py:attribute:: dataset .. py:attribute:: annotation_guideline_link .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: cuis .. py:attribute:: cuis_file .. py:attribute:: annotation_classification .. py:attribute:: meta_cat_predictions .. py:attribute:: project_locked .. py:attribute:: project_status .. py:class:: Project Bases: :py:obj:`polymorphic.models.PolymorphicModel`, :py:obj:`ProjectFields` .. py:attribute:: members .. py:attribute:: group .. py:attribute:: validated_documents .. py:attribute:: prepared_documents .. py:method:: __str__() .. py:class:: Entity Bases: :py:obj:`django.db.models.Model` .. py:attribute:: label .. py:method:: __str__() .. py:class:: Relation Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: label .. py:method:: __str__() .. py:class:: MetaTaskValue Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['ordering', 'name'] .. py:attribute:: name .. py:attribute:: ordering .. py:method:: __str__() .. py:class:: MetaTask Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['ordering', 'name'] .. py:attribute:: name .. py:attribute:: values .. py:attribute:: default .. py:attribute:: description .. py:attribute:: ordering .. py:attribute:: prediction_model .. py:method:: __str__() .. py:class:: ProjectAnnotateEntitiesFields Bases: :py:obj:`django.db.models.Model` Abstract class for all model fields for ProjectAnnotateEntities models. .. py:class:: Meta .. py:attribute:: abstract :value: True .. py:attribute:: concept_db .. py:attribute:: vocab .. py:attribute:: model_pack .. py:attribute:: cdb_search_filter .. py:attribute:: require_entity_validation .. py:attribute:: train_model_on_submit .. py:attribute:: add_new_entities .. py:attribute:: restrict_concept_lookup .. py:attribute:: terminate_available .. py:attribute:: irrelevant_available .. py:attribute:: deid_model_annotation .. py:attribute:: enable_entity_annotation_comments .. py:attribute:: tasks .. py:attribute:: relations .. py:attribute:: use_model_service .. py:attribute:: model_service_url .. py:method:: save(*args, **kwargs) .. py:class:: ProjectAnnotateEntities Bases: :py:obj:`Project`, :py:obj:`ProjectAnnotateEntitiesFields` Class for any single ProjectAnnotateEntities model fields that should not be inherited by ProjectGroup In practise its unlikely further fields are needed. .. py:class:: ProjectGroup Bases: :py:obj:`ProjectFields`, :py:obj:`ProjectAnnotateEntitiesFields` Abstract class for all model fields for ProjectAnnotateEntities models. .. py:attribute:: administrators .. py:attribute:: annotators .. py:attribute:: cdb_search_filter .. py:attribute:: create_associated_projects .. py:method:: __str__() .. py:class:: ExportedProject Bases: :py:obj:`django.db.models.Model` .. py:attribute:: trainer_export_file .. py:attribute:: import_project_name_suffix .. py:attribute:: members .. py:attribute:: cdb_id .. py:attribute:: vocab_id .. py:attribute:: modelpack_id .. py:attribute:: cdb_search_filter_id .. py:attribute:: set_validated_docs .. py:method:: __str__() .. py:class:: ProjectMetrics Bases: :py:obj:`django.db.models.Model` .. py:attribute:: report_name_generated .. py:attribute:: report_name .. py:attribute:: report .. py:attribute:: projects .. py:method:: __str__() .. py:function:: auto_delete_cdb_file_on_delete(sender, instance, **kwargs) .. py:function:: auto_delete_vocab_file_on_delete(sender, instance, **kwargs) .. py:function:: auto_delete_dataset_file_on_delete(sender, instance, **kwargs) .. py:function:: _remove_file(instance, prop) .. py:exception:: MedCATLoadException(message) Bases: :py:obj:`Exception` Common base class for all non-exit exceptions. .. py:method:: __init__(message) Initialize self. See help(type(self)) for accurate signature. .. py:class:: AnnotatedEntity Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: user .. py:attribute:: project .. py:attribute:: document .. py:attribute:: entity .. py:attribute:: value .. py:attribute:: start_ind .. py:attribute:: end_ind .. py:attribute:: acc .. py:attribute:: comment .. py:attribute:: validated .. py:attribute:: correct .. py:attribute:: alternative .. py:attribute:: manually_created .. py:attribute:: deleted .. py:attribute:: killed .. py:attribute:: irrelevant .. py:attribute:: create_time .. py:attribute:: last_modified .. py:method:: save(*args, **kwargs) .. py:method:: __str__() .. py:class:: MetaAnnotation Bases: :py:obj:`django.db.models.Model` .. py:attribute:: annotated_entity .. py:attribute:: meta_task .. py:attribute:: meta_task_value .. py:attribute:: acc .. py:attribute:: predicted_meta_task_value .. py:attribute:: validated .. py:attribute:: last_modified .. py:method:: save(*args, **kwargs) .. py:method:: __str__() .. py:class:: EntityRelation Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: user .. py:attribute:: project .. py:attribute:: document .. py:attribute:: relation .. py:attribute:: start_entity .. py:attribute:: end_entity .. py:attribute:: validated .. py:attribute:: create_time .. py:attribute:: last_modified .. py:method:: save(*args, **kwargs) .. py:method:: __str__() .. py:class:: Document Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: name .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: text .. py:attribute:: dataset .. py:method:: __str__() .. py:class:: ConceptDB(*args, **kwargs) Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: cdb_file .. py:attribute:: use_for_training .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: last_modified_by .. py:method:: __init__(*args, **kwargs) .. py:method:: from_db(db, field_names, values) :classmethod: .. py:method:: save(*args, skip_load=False, **kwargs) .. py:method:: __str__() .. py:function:: drop_collection(cdb_model) .. py:function:: import_all_concepts(cdb, cdb_model) .. py:function:: clear_cdb_cnf_addons(cdb, cdb_id) .. py:data:: logger .. py:data:: _dt_fmt :value: '%Y-%m-%d %H:%M:%S.%f' .. py:function:: reset_project(modeladmin, request, queryset) .. py:function:: download_without_text(modeladmin, request, queryset) .. py:function:: download_without_text_with_doc_names(modeladmin, request, queryset) .. py:function:: download_projects_without_text(projects, with_doc_name) .. py:function:: download(modeladmin, request, queryset) .. py:function:: download_projects_with_text(projects) .. py:function:: retrieve_project_data(projects) A function to convert a list of projects and: - their associated documents, - their associated annotations, - their associated Meta annotations and Relation Annotations for serialization. Output schema is as follows: ((optional) indicates this field isn't required for training a MedCAT model) { "projects": [ { "name": "" # the auto-generated id of the project (optional) "project_group_id": "" # the auto-generated id of the project - nullable "project_group_name": "" # the name of the project group if set. "project_status": "" # status - either annotating, discontinued, complete "project_locked": "" # locked - for no further annotations "cuis": ["cui_1", "cui_2" ... ] # the CUI filter for the project, includes those from file / and text-box "meta_anno_defs": [ # list of meta annotation tasks configured for this project. { "name": "Name of meta annotation task", "values": [ "", "" ... ], }, ... more meta_annotation tasks configured for this project ], "relation_anno_defs": [ "", "" ... more relation annotation task names configured for this project ] "documents": [ { "id": "" # the auto-generated id of the document (optional) "name": "" # the name of the document (optional), but used in stat printing during training "text": "" # the text of the document "last_modified": "" # the last modified-time (optional) "annotations": [{ "id": "" # the auto-generated id of the document (optional) "name": "" # the user who made the annotation (optional) "cui": "" # the cui label for this annotation "value": "" # the text span for this annotation "start": # the start index of this annotation with respect to the document text "end": # the end index of this annotation with respect to the document text "validated": # if the annotation has been marked by a human annotator "correct": # if the text span is correctly linked to the CUI of this annotation "deleted": # if the text span was incorrectly linked or 'not' linked by MedCAT due to low scores "alternative": # if the text span was incorrectly linked by MedCAT, then correctly linked by a human annotator "killed": # if a human annotator 'terminated' this annotation "irrelevant": # if a human annotator has marked an annotation as irrelevant (optional) "acc": # accuracy provided by MedCAT (optional) "comment": "" # the text entered by an annotator during annotation (optional) "meta_anns": [ # list of meta annotations if applicable to project { "name": # Meta anno task name, i.e. temporality "value": # the selected meta anno task value for, ie. "past" or "present" "acc": # default 1, (optional) "validated": # Meta annotation has been made by a human annotator, default (true) }, ... ]}, ... ] "relations": [ { "start_entity": # id of above annotation that is the start of this relation "start_entity_cui": "" # the cui label of the start of this relation "start_entity_value": # value of the start annotation for this relation "start_entity_start_idx": # start index of text span of start of relation "start_entity_end_idx": # end index of text span of start of relation "end_entity": # id of the above annotation that is the end of this relation "end_entity_cui": "" # the cui label of the end of this relation "end_entity_value": # value of the end annotation for this relation "end_entity_start_idx": # end index of text span of end of relation "end_entity_end_idx": # end index of text span of end of relation "user": # username of annotator for relation (optional) "relation": # label for this relation "validated": # if the annotation has been validated by a human annotator, default true. } ... < more relations of the samve above structure> ] ... ] ] } Args: projects (QuerySet): the projects to export data for. .. py:function:: clone_projects(modeladmin, request, queryset) .. py:function:: dataset_document_counts(dataset) .. py:function:: _reset_cdb_filters(id) .. py:function:: import_concepts_from_cdb(cdb_model_id) .. py:function:: reset_cdb_filters(modeladmin, request, queryset) .. py:function:: import_concepts(modeladmin, request, queryset) .. py:function:: delete_indexed_concepts(modeladmin, request, queryset) .. py:function:: remove_all_documents(modeladmin, request, queryset) .. py:data:: STATUS_CHOICES :value: [(0, 'Not Validated'), (1, 'Validated')] .. py:data:: BOOL_CHOICES :value: [(0, 'False'), (1, 'True')] .. py:data:: cdb_name_validator .. py:data:: logger .. py:class:: ModelPack Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: model_pack .. py:attribute:: concept_db .. py:attribute:: vocab .. py:attribute:: meta_cats .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: last_modified_by .. py:method:: save(*args, skip_load=False, **kwargs) .. py:method:: __str__() .. py:class:: ConceptDB(*args, **kwargs) Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: cdb_file .. py:attribute:: use_for_training .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: last_modified_by .. py:method:: __init__(*args, **kwargs) .. py:method:: from_db(db, field_names, values) :classmethod: .. py:method:: save(*args, skip_load=False, **kwargs) .. py:method:: __str__() .. py:class:: Vocabulary Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: vocab_file .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: last_modified_by .. py:method:: save(*args, skip_load=False, **kwargs) .. py:method:: __str__() .. py:class:: MetaCATModel Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: meta_cat_dir .. py:method:: get_or_create_meta_tasks_and_values(meta_cat) .. py:method:: save(*args, unpack_load_meta_cat_dir=False, **kwargs) .. py:method:: __str__() .. py:class:: Dataset Bases: :py:obj:`django.db.models.Model` .. py:attribute:: name .. py:attribute:: original_file .. py:attribute:: create_time .. py:attribute:: description .. py:method:: __str__() .. py:class:: DatasetForm Bases: :py:obj:`django.forms.ModelForm` .. py:method:: clean() .. py:class:: Document Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: name .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: text .. py:attribute:: dataset .. py:method:: __str__() .. py:class:: ProjectFields Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: abstract :value: True .. py:attribute:: PROJECT_STATUSES :value: [('A', 'Annotating'), ('D', 'Discontinued (Fail)'), ('C', 'Complete')] .. py:attribute:: name .. py:attribute:: description .. py:attribute:: dataset .. py:attribute:: annotation_guideline_link .. py:attribute:: create_time .. py:attribute:: last_modified .. py:attribute:: cuis .. py:attribute:: cuis_file .. py:attribute:: annotation_classification .. py:attribute:: meta_cat_predictions .. py:attribute:: project_locked .. py:attribute:: project_status .. py:class:: Project Bases: :py:obj:`polymorphic.models.PolymorphicModel`, :py:obj:`ProjectFields` .. py:attribute:: members .. py:attribute:: group .. py:attribute:: validated_documents .. py:attribute:: prepared_documents .. py:method:: __str__() .. py:class:: Entity Bases: :py:obj:`django.db.models.Model` .. py:attribute:: label .. py:method:: __str__() .. py:class:: Relation Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: label .. py:method:: __str__() .. py:class:: EntityRelation Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: user .. py:attribute:: project .. py:attribute:: document .. py:attribute:: relation .. py:attribute:: start_entity .. py:attribute:: end_entity .. py:attribute:: validated .. py:attribute:: create_time .. py:attribute:: last_modified .. py:method:: save(*args, **kwargs) .. py:method:: __str__() .. py:class:: AnnotatedEntity Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['id'] .. py:attribute:: user .. py:attribute:: project .. py:attribute:: document .. py:attribute:: entity .. py:attribute:: value .. py:attribute:: start_ind .. py:attribute:: end_ind .. py:attribute:: acc .. py:attribute:: comment .. py:attribute:: validated .. py:attribute:: correct .. py:attribute:: alternative .. py:attribute:: manually_created .. py:attribute:: deleted .. py:attribute:: killed .. py:attribute:: irrelevant .. py:attribute:: create_time .. py:attribute:: last_modified .. py:method:: save(*args, **kwargs) .. py:method:: __str__() .. py:class:: MetaTaskValue Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['ordering', 'name'] .. py:attribute:: name .. py:attribute:: ordering .. py:method:: __str__() .. py:class:: MetaTask Bases: :py:obj:`django.db.models.Model` .. py:class:: Meta .. py:attribute:: ordering :value: ['ordering', 'name'] .. py:attribute:: name .. py:attribute:: values .. py:attribute:: default .. py:attribute:: description .. py:attribute:: ordering .. py:attribute:: prediction_model .. py:method:: __str__() .. py:class:: ProjectAnnotateEntitiesFields Bases: :py:obj:`django.db.models.Model` Abstract class for all model fields for ProjectAnnotateEntities models. .. py:class:: Meta .. py:attribute:: abstract :value: True .. py:attribute:: concept_db .. py:attribute:: vocab .. py:attribute:: model_pack .. py:attribute:: cdb_search_filter .. py:attribute:: require_entity_validation .. py:attribute:: train_model_on_submit .. py:attribute:: add_new_entities .. py:attribute:: restrict_concept_lookup .. py:attribute:: terminate_available .. py:attribute:: irrelevant_available .. py:attribute:: deid_model_annotation .. py:attribute:: enable_entity_annotation_comments .. py:attribute:: tasks .. py:attribute:: relations .. py:attribute:: use_model_service .. py:attribute:: model_service_url .. py:method:: save(*args, **kwargs) .. py:class:: ProjectAnnotateEntities Bases: :py:obj:`Project`, :py:obj:`ProjectAnnotateEntitiesFields` Class for any single ProjectAnnotateEntities model fields that should not be inherited by ProjectGroup In practise its unlikely further fields are needed. .. py:class:: ProjectGroup Bases: :py:obj:`ProjectFields`, :py:obj:`ProjectAnnotateEntitiesFields` Abstract class for all model fields for ProjectAnnotateEntities models. .. py:attribute:: administrators .. py:attribute:: annotators .. py:attribute:: cdb_search_filter .. py:attribute:: create_associated_projects .. py:method:: __str__() .. py:class:: MetaAnnotation Bases: :py:obj:`django.db.models.Model` .. py:attribute:: annotated_entity .. py:attribute:: meta_task .. py:attribute:: meta_task_value .. py:attribute:: acc .. py:attribute:: predicted_meta_task_value .. py:attribute:: validated .. py:attribute:: last_modified .. py:method:: save(*args, **kwargs) .. py:method:: __str__() .. py:class:: ExportedProject Bases: :py:obj:`django.db.models.Model` .. py:attribute:: trainer_export_file .. py:attribute:: import_project_name_suffix .. py:attribute:: members .. py:attribute:: cdb_id .. py:attribute:: vocab_id .. py:attribute:: modelpack_id .. py:attribute:: cdb_search_filter_id .. py:attribute:: set_validated_docs .. py:method:: __str__() .. py:class:: ProjectMetrics Bases: :py:obj:`django.db.models.Model` .. py:attribute:: report_name_generated .. py:attribute:: report_name .. py:attribute:: report .. py:attribute:: projects .. py:method:: __str__() .. py:function:: auto_delete_cdb_file_on_delete(sender, instance, **kwargs) .. py:function:: auto_delete_vocab_file_on_delete(sender, instance, **kwargs) .. py:function:: auto_delete_dataset_file_on_delete(sender, instance, **kwargs) .. py:function:: _remove_file(instance, prop) .. py:exception:: MedCATLoadException(message) Bases: :py:obj:`Exception` Common base class for all non-exit exceptions. .. py:method:: __init__(message) Initialize self. See help(type(self)) for accurate signature.