lx-annotate 1.3.2__tar.gz → 1.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/PKG-INFO +2 -2
  2. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/api_urls.py +22 -0
  3. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_envelope.py +2 -3
  4. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_transfer_client.py +1 -1
  5. lx_annotate-1.3.4/lx_annotate/middleware/request_throttle.py +155 -0
  6. lx_annotate-1.3.4/lx_annotate/migrations/0010_studycohort.py +50 -0
  7. lx_annotate-1.3.4/lx_annotate/migrations/max_migration.txt +1 -0
  8. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/models.py +41 -0
  9. lx_annotate-1.3.4/lx_annotate/schemas/study_cohorts.py +52 -0
  10. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/settings/settings_base.py +6 -0
  11. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/settings/settings_dev.py +3 -1
  12. lx_annotate-1.3.4/lx_annotate/views/study_cohorts.py +173 -0
  13. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/manage.py +0 -19
  14. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/pyproject.toml +2 -2
  15. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/.vite/manifest.json +28 -4
  16. lx_annotate-1.3.4/staticfiles/AiDatasetBucketsPage.css +1 -0
  17. lx_annotate-1.3.4/staticfiles/AiDatasetBucketsPage.js +1 -0
  18. lx_annotate-1.3.4/staticfiles/AiDatasetSettingsPage.css +1 -0
  19. lx_annotate-1.3.4/staticfiles/AiDatasetSettingsPage.js +1 -0
  20. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnonymizationOverview.css +1 -1
  21. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnonymizationOverview.js +1 -1
  22. lx_annotate-1.3.4/staticfiles/AnonymizationValidationComponent.css +1 -0
  23. lx_annotate-1.3.4/staticfiles/AnonymizationValidationComponent.js +1 -0
  24. lx_annotate-1.3.4/staticfiles/DatasetStudyCohorts.vue_vue_type_script_setup_true_lang.js +1 -0
  25. lx_annotate-1.3.4/staticfiles/StudyCohortPage.css +1 -0
  26. lx_annotate-1.3.4/staticfiles/StudyCohortPage.js +1 -0
  27. lx_annotate-1.3.4/staticfiles/VideoExamination.css +1 -0
  28. lx_annotate-1.3.4/staticfiles/VideoExamination.js +1 -0
  29. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/main.js +2 -2
  30. lx_annotate-1.3.4/staticfiles/studyCohortApi.js +1 -0
  31. lx_annotate-1.3.4/staticfiles/studyCohortExportStore.js +1 -0
  32. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/uv.lock +11 -12
  33. lx_annotate-1.3.2/lx_annotate/migrations/max_migration.txt +0 -1
  34. lx_annotate-1.3.2/staticfiles/AiDatasetBucketsPage.css +0 -1
  35. lx_annotate-1.3.2/staticfiles/AiDatasetBucketsPage.js +0 -1
  36. lx_annotate-1.3.2/staticfiles/AiDatasetSettingsPage.css +0 -1
  37. lx_annotate-1.3.2/staticfiles/AiDatasetSettingsPage.js +0 -1
  38. lx_annotate-1.3.2/staticfiles/AnonymizationValidationComponent.css +0 -1
  39. lx_annotate-1.3.2/staticfiles/AnonymizationValidationComponent.js +0 -1
  40. lx_annotate-1.3.2/staticfiles/StudyCohortPage.css +0 -1
  41. lx_annotate-1.3.2/staticfiles/StudyCohortPage.js +0 -1
  42. lx_annotate-1.3.2/staticfiles/VideoExamination.css +0 -1
  43. lx_annotate-1.3.2/staticfiles/VideoExamination.js +0 -1
  44. lx_annotate-1.3.2/staticfiles/studyCohortExportStore.js +0 -1
  45. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/.gitignore +0 -0
  46. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/LICENSE +0 -0
  47. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/README.md +0 -0
  48. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/hatch_build.py +0 -0
  49. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/__init__.py +0 -0
  50. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/admin.py +0 -0
  51. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/apps.py +0 -0
  52. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/asgi.py +0 -0
  53. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/celery.py +0 -0
  54. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/checks.py +0 -0
  55. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/cli.py +0 -0
  56. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/dtypes_api_urls.py +0 -0
  57. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/file_watcher.py +0 -0
  58. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/__init__.py +0 -0
  59. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_audit.py +0 -0
  60. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_cleanup.py +0 -0
  61. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_contracts.py +0 -0
  62. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_health.py +0 -0
  63. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_jobs.py +0 -0
  64. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_payloads.py +0 -0
  65. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_reconciliation.py +0 -0
  66. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_state.py +0 -0
  67. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/hub_export_worker.py +0 -0
  68. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/node_provisioning.py +0 -0
  69. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_balance_worker.py +0 -0
  70. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_ingest.py +0 -0
  71. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_orchestration.py +0 -0
  72. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_provider.py +0 -0
  73. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_publication.py +0 -0
  74. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_reconciliation.py +0 -0
  75. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_recovery.py +0 -0
  76. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_rekey.py +0 -0
  77. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_report_provider.py +0 -0
  78. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_resolver.py +0 -0
  79. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/storage_telemetry.py +0 -0
  80. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/hub/transfer_transport.py +0 -0
  81. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/__init__.py +0 -0
  82. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/__init__.py +0 -0
  83. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/check_hub_export_health.py +0 -0
  84. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/check_migration_compatibility.py +0 -0
  85. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/dispatch_hub_export_recovery.py +0 -0
  86. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/export_openapi.py +0 -0
  87. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/export_route_manifest.py +0 -0
  88. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/monitoring_status.py +0 -0
  89. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/provision_hub_nodes.py +0 -0
  90. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/reap_verified_hub_exports.py +0 -0
  91. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/recover_runtime_data.py +0 -0
  92. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/repair_legacy_migration_history.py +0 -0
  93. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/repair_managed_payloads.py +0 -0
  94. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/run_filewatcher.py +0 -0
  95. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/runtime_acceptance.py +0 -0
  96. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/start_filewatcher.py +0 -0
  97. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/management/commands/verify_encrypted_storage.py +0 -0
  98. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/middleware/__init__.py +0 -0
  99. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/middleware/lookup_tracker.py +0 -0
  100. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migration_history_safety.py +0 -0
  101. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/0001_outboundhubtransferjob.py +0 -0
  102. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/0002_outboundhubtransferjob_local_cleanup_fields.py +0 -0
  103. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/0003_outboundhubtransferjob_failure_class.py +0 -0
  104. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/0004_storagenodeactionreceipt.py +0 -0
  105. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/0005_storageoperatordispatchreceipt.py +0 -0
  106. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/0006_storageartifactpublication.py +0 -0
  107. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/0007_outbound_hub_receipt_cleanup.py +0 -0
  108. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/0008_aidatasetsplitplan.py +0 -0
  109. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/0009_videotranscodejob.py +0 -0
  110. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/migrations/__init__.py +0 -0
  111. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/monitoring/__init__.py +0 -0
  112. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/monitoring/configuration.py +0 -0
  113. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/monitoring/contracts.py +0 -0
  114. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/monitoring/database.py +0 -0
  115. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/monitoring/runtime.py +0 -0
  116. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/monitoring/service.py +0 -0
  117. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/operational_support.py +0 -0
  118. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/permissions.py +0 -0
  119. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/runtime_commands/__init__.py +0 -0
  120. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/schemas/__init__.py +0 -0
  121. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/schemas/ai_dataset_splits.py +0 -0
  122. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/serializers.py +0 -0
  123. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/services/__init__.py +0 -0
  124. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/services/access_management.py +0 -0
  125. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/services/ai_dataset_splits.py +0 -0
  126. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/services/report_llm.py +0 -0
  127. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/services/runtime_recovery.py +0 -0
  128. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/services/video_transcode_jobs.py +0 -0
  129. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/settings/__init__.py +0 -0
  130. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/settings/config.py +0 -0
  131. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/settings/oidc.py +0 -0
  132. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/settings/secret_key.py +0 -0
  133. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/settings/settings_prod.py +0 -0
  134. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/settings/settings_test.py +0 -0
  135. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/signals.py +0 -0
  136. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/storage/__init__.py +0 -0
  137. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/storage/encrypted.py +0 -0
  138. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/storage/encryption.py +0 -0
  139. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/tasks.py +0 -0
  140. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/templates/base.html +0 -0
  141. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/urls.py +0 -0
  142. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/__init__.py +0 -0
  143. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/administration.py +0 -0
  144. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/ai_dataset_splits.py +0 -0
  145. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/anonymization_overview.py +0 -0
  146. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/anonymization_storage.py +0 -0
  147. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/application_settings.py +0 -0
  148. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/frame_annotation.py +0 -0
  149. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/hub_export.py +0 -0
  150. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/monitoring.py +0 -0
  151. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/quarantine.py +0 -0
  152. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/report_llm.py +0 -0
  153. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/study_export.py +0 -0
  154. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/video_state_repair.py +0 -0
  155. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/views/video_transcode_jobs.py +0 -0
  156. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate/wsgi.py +0 -0
  157. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/lx_annotate_assets/__init__.py +0 -0
  158. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AboutUs.js +0 -0
  159. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AdministrationPage.css +0 -0
  160. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AdministrationPage.js +0 -0
  161. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnnotationDashboard.css +0 -0
  162. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnnotationDashboard.js +0 -0
  163. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnnotationDashboard2.js +0 -0
  164. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnonymizationCorrectionComponent.css +0 -0
  165. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnonymizationCorrectionComponent.js +0 -0
  166. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnonymizationEvaluation.css +0 -0
  167. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnonymizationEvaluation.js +0 -0
  168. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnonymizationMetrics.css +0 -0
  169. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/AnonymizationMetrics.js +0 -0
  170. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ApplicationSettingsPage.css +0 -0
  171. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ApplicationSettingsPage.js +0 -0
  172. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/CaseResolutionPage.js +0 -0
  173. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/CaseSetupPage.css +0 -0
  174. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/CaseSetupPage.js +0 -0
  175. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ColoReg.png +0 -0
  176. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Comfortaa-Bold.ttf +0 -0
  177. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Comfortaa-Regular.ttf +0 -0
  178. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Dashboard.js +0 -0
  179. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Documentation.css +0 -0
  180. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Documentation.js +0 -0
  181. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Export.css +0 -0
  182. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Export.js +0 -0
  183. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/FinalizedResultPage.js +0 -0
  184. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/FindingsCapturePage.css +0 -0
  185. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/FindingsCapturePage.js +0 -0
  186. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/FrameAnnotation.css +0 -0
  187. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/FrameAnnotation.js +0 -0
  188. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/FrameSelectorPage.css +0 -0
  189. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/FrameSelectorPage.js +0 -0
  190. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/HubExport.css +0 -0
  191. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/HubExport.js +0 -0
  192. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ModelTrainingPage.css +0 -0
  193. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ModelTrainingPage.js +0 -0
  194. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/MonitoringPage.css +0 -0
  195. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/MonitoringPage.js +0 -0
  196. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/PageOverview.css +0 -0
  197. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/PageOverview.js +0 -0
  198. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/PatientDocumentsPage.css +0 -0
  199. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/PatientDocumentsPage.js +0 -0
  200. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/PatientMedicationPage.css +0 -0
  201. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/PatientMedicationPage.js +0 -0
  202. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/PatientOverview.css +0 -0
  203. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/PatientOverview.js +0 -0
  204. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Profile.js +0 -0
  205. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ReportEditorPage.css +0 -0
  206. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ReportEditorPage.js +0 -0
  207. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ReportExportPage.css +0 -0
  208. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ReportExportPage.js +0 -0
  209. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ReportTemplateBuilderPage.css +0 -0
  210. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ReportTemplateBuilderPage.js +0 -0
  211. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ReportingShell.css +0 -0
  212. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ReportingShell.js +0 -0
  213. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/ReportingWorklistPage.js +0 -0
  214. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Timeline.css +0 -0
  215. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/Timeline.js +0 -0
  216. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/administrationApi.js +0 -0
  217. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/aiDatasetApi.js +0 -0
  218. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/annotationPrincipal.js +0 -0
  219. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/anonymizationValidationPresentation.js +0 -0
  220. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/applicationSettingsApi.js +0 -0
  221. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/casesApi.js +0 -0
  222. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/dateHelpers.js +0 -0
  223. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/examinationStore.js +0 -0
  224. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/frameStreams.js +0 -0
  225. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/img/favicon.png +0 -0
  226. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/knowledgeBaseGraphApi.js +0 -0
  227. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/main.css +0 -0
  228. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/mediaTypeStore.js +0 -0
  229. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/mediaUrls.js +0 -0
  230. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/nucleo-icons.eot +0 -0
  231. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/nucleo-icons.svg +0 -0
  232. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/nucleo-icons.ttf +0 -0
  233. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/nucleo-icons.woff +0 -0
  234. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/nucleo-icons.woff2 +0 -0
  235. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/patientExaminationStore.js +0 -0
  236. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/patientService.js +0 -0
  237. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/patientStore.js +0 -0
  238. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/pdf.js +0 -0
  239. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/pdf.worker.min.js +0 -0
  240. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/pdf.worker.min.mjs +0 -0
  241. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/reportExportApi.js +0 -0
  242. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/reportTemplateLifecycleContext.js +0 -0
  243. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/reportingError.js +0 -0
  244. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/reportingExaminationResolution.js +0 -0
  245. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/reportingIndicationContract.js +0 -0
  246. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/reportingPresentation.js +0 -0
  247. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/reportingTimelineApi.js +0 -0
  248. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/rng.js +0 -0
  249. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/studyApi.js +0 -0
  250. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/terminologyStore.js +0 -0
  251. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/timeHelpers.js +0 -0
  252. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/useAuthenticatedVideoStream.js +0 -0
  253. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/useDebug.js +0 -0
  254. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/useFindingSelectors.js +0 -0
  255. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/useReportTemplates.css +0 -0
  256. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/useReportTemplates.js +0 -0
  257. {lx_annotate-1.3.2 → lx_annotate-1.3.4}/staticfiles/useReportingKnowledgeBase.js +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: lx-annotate
3
- Version: 1.3.2
3
+ Version: 1.3.4
4
4
  Summary: This webapp provides a frontend interface for pseudonymizing and annotating data and applying AI predictions.
5
5
  Author-email: Max Hild <hild_m@ukw.de>, "Thomas J. Lux" <lux_t1@ukw.de>
6
6
  Maintainer: Hamza Zahid
@@ -29,7 +29,7 @@ Requires-Dist: django-webpack-loader>=0.7.0
29
29
  Requires-Dist: django==6.0.3
30
30
  Requires-Dist: djangorestframework>=3.12.4
31
31
  Requires-Dist: drf-spectacular>=0.28.0
32
- Requires-Dist: endoreg-db==1.3.4
32
+ Requires-Dist: endoreg-db==1.3.7
33
33
  Requires-Dist: gunicorn>=23.0.0
34
34
  Requires-Dist: lx-dtypes>=0.3.4
35
35
  Requires-Dist: mozilla-django-oidc>=4.0.1
@@ -35,11 +35,33 @@ from lx_annotate.views.hub_export import (
35
35
  from lx_annotate.views.monitoring import monitoring_snapshot
36
36
  from lx_annotate.views.quarantine import quarantine_overview
37
37
  from lx_annotate.views.report_llm import report_llm_generate, report_llm_status
38
+ from lx_annotate.views.study_cohorts import (
39
+ dataset_study_cohorts,
40
+ study_cohort_detail,
41
+ study_cohort_preview,
42
+ study_cohorts,
43
+ )
38
44
  from lx_annotate.views.study_export import study_export_options, study_export_xlsx
39
45
  from lx_annotate.views.video_state_repair import VideoStateRepairView
40
46
  from lx_annotate.views.video_transcode_jobs import VideoTranscodeJobsView
41
47
 
42
48
  urlpatterns = [
49
+ path("media/studies/cohorts/", study_cohorts, name="study-cohorts"),
50
+ path(
51
+ "media/studies/cohorts/preview/",
52
+ study_cohort_preview,
53
+ name="saved-study-cohort-preview",
54
+ ),
55
+ path(
56
+ "media/studies/cohorts/<int:cohort_id>/",
57
+ study_cohort_detail,
58
+ name="study-cohort-detail",
59
+ ),
60
+ path(
61
+ "settings/application/ai_datasets/<int:dataset_id>/study_cohorts/",
62
+ dataset_study_cohorts,
63
+ name="dataset-study-cohorts",
64
+ ),
43
65
  path(
44
66
  "media/videos/transcode-jobs/",
45
67
  VideoTranscodeJobsView.as_view(),
@@ -19,7 +19,7 @@ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
19
19
  from cryptography.hazmat.primitives.ciphers.aead import AESGCM
20
20
  from cryptography.hazmat.primitives.kdf.hkdf import HKDF
21
21
  from django.conf import settings
22
- from endoreg_db.utils.filesystem.file_operations import (
22
+ from endoreg_db.utils.file_operations import (
23
23
  atomic_create_file,
24
24
  safe_unlink_file,
25
25
  )
@@ -117,8 +117,7 @@ def resolve_hub_export_envelope_config() -> HubExportEnvelopeConfig:
117
117
  staging.relative_to(protected_root)
118
118
  except ValueError as exc:
119
119
  raise ValueError(
120
- "Hub envelope staging directory must be inside "
121
- "LX_RUNTIME_ROOT.",
120
+ "Hub envelope staging directory must be inside LX_RUNTIME_ROOT.",
122
121
  ) from exc
123
122
  if staging.exists() and (staging.is_symlink() or not staging.is_dir()):
124
123
  raise ValueError("Hub envelope staging path must be a non-symlink directory.")
@@ -23,7 +23,7 @@ from cryptography.hazmat.primitives.asymmetric.x25519 import (
23
23
  from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
24
24
  from cryptography.hazmat.primitives.ciphers.aead import AESGCM
25
25
  from cryptography.hazmat.primitives.kdf.hkdf import HKDF
26
- from endoreg_db.utils.filesystem.file_operations import (
26
+ from endoreg_db.utils.file_operations import (
27
27
  atomic_create_file,
28
28
  atomic_write_file,
29
29
  safe_unlink_file,
@@ -0,0 +1,155 @@
1
+ """Reserve host resources for API work without granting Django systemd access."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import fcntl
6
+ import logging
7
+ import socket
8
+ import threading
9
+ import time
10
+ from collections.abc import AsyncIterator, Callable, Iterator
11
+ from pathlib import Path
12
+ from typing import BinaryIO, cast
13
+
14
+ from django.conf import settings
15
+ from django.http import (
16
+ HttpRequest,
17
+ HttpResponseBase,
18
+ JsonResponse,
19
+ StreamingHttpResponse,
20
+ )
21
+
22
+ logger = logging.getLogger(__name__)
23
+ API_PREFIXES = ("/api/", "/endoreg-api/", "/dtypes-api/")
24
+ ADMISSION_TIMEOUT_SECONDS = 5.0
25
+
26
+
27
+ def parse_request_throttle_directory(value: str) -> Path | None:
28
+ value = value.strip()
29
+ if not value:
30
+ return None
31
+ path = Path(value)
32
+ if not path.is_absolute() or ".." in path.parts or "\x00" in value:
33
+ raise ValueError(
34
+ "Request throttle directory must be an absolute normalized path"
35
+ )
36
+ if len(bytes(path / "control.sock")) > 107:
37
+ raise ValueError(
38
+ "Request throttle directory exceeds the Unix socket path limit"
39
+ )
40
+ return path
41
+
42
+
43
+ class ThrottleUnavailable(RuntimeError):
44
+ """The configured host controller did not acknowledge foreground priority."""
45
+
46
+
47
+ class RequestActivity:
48
+ def __init__(self, directory: Path) -> None:
49
+ self.directory = directory
50
+ self._file: BinaryIO | None = None
51
+ self._close_lock = threading.Lock()
52
+
53
+ def acquire(self) -> None:
54
+ deadline = time.monotonic() + ADMISSION_TIMEOUT_SECONDS
55
+ try:
56
+ self._file = (self.directory / "activity.lock").open("rb")
57
+ while True:
58
+ try:
59
+ fcntl.flock(self._file.fileno(), fcntl.LOCK_SH | fcntl.LOCK_NB)
60
+ break
61
+ except BlockingIOError:
62
+ if time.monotonic() >= deadline:
63
+ raise TimeoutError("Request activity lock admission timed out")
64
+ time.sleep(0.005)
65
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as connection:
66
+ remaining = deadline - time.monotonic()
67
+ if remaining <= 0:
68
+ raise TimeoutError("Request throttle admission timed out")
69
+ connection.settimeout(remaining)
70
+ connection.connect(str(self.directory / "control.sock"))
71
+ connection.sendall(b"+")
72
+ if connection.recv(1) != b"+":
73
+ raise OSError("Request throttle acknowledgement missing")
74
+ except OSError as exc:
75
+ self.close()
76
+ raise ThrottleUnavailable(
77
+ "Request resource controller unavailable"
78
+ ) from exc
79
+ except BaseException:
80
+ self.close()
81
+ raise
82
+
83
+ def close(self) -> None:
84
+ with self._close_lock:
85
+ if self._file is not None:
86
+ self._file.close()
87
+ self._file = None
88
+
89
+
90
+ def _stream(content: Iterator[bytes], activity: RequestActivity) -> Iterator[bytes]:
91
+ try:
92
+ yield from content
93
+ finally:
94
+ activity.close()
95
+
96
+
97
+ async def _async_stream(
98
+ content: AsyncIterator[bytes], activity: RequestActivity
99
+ ) -> AsyncIterator[bytes]:
100
+ try:
101
+ async for chunk in content:
102
+ yield chunk
103
+ finally:
104
+ activity.close()
105
+
106
+
107
+ class FrontendRequestThrottleMiddleware:
108
+ """Synchronous admission also runs in Django's ASGI middleware adapter."""
109
+
110
+ def __init__(self, get_response: Callable[[HttpRequest], HttpResponseBase]) -> None:
111
+ self.get_response = get_response
112
+ self.directory = cast(
113
+ Path | None, settings.LX_ANNOTATE_REQUEST_THROTTLE_DIRECTORY
114
+ )
115
+
116
+ def __call__(self, request: HttpRequest) -> HttpResponseBase:
117
+ if self.directory is None or not request.path_info.startswith(API_PREFIXES):
118
+ return self.get_response(request)
119
+ activity = RequestActivity(self.directory)
120
+ try:
121
+ activity.acquire()
122
+ except ThrottleUnavailable:
123
+ logger.error("request_throttle.admission_failed")
124
+ response = JsonResponse(
125
+ {"error": "request_resources_unavailable"}, status=503
126
+ )
127
+ response["Retry-After"] = "1"
128
+ return response
129
+ try:
130
+ response = self.get_response(request)
131
+ if isinstance(response, StreamingHttpResponse):
132
+ content = response.streaming_content
133
+ if response.is_async:
134
+ response.streaming_content = _async_stream(
135
+ cast(AsyncIterator[bytes], content), activity
136
+ )
137
+ else:
138
+ response.streaming_content = _stream(
139
+ cast(Iterator[bytes], content), activity
140
+ )
141
+ # Keep the reservation through response delivery and request-finished
142
+ # handlers, including a disconnect before stream consumption.
143
+ original_close = response.close
144
+
145
+ def close_response() -> None:
146
+ try:
147
+ original_close()
148
+ finally:
149
+ activity.close()
150
+
151
+ response.close = close_response
152
+ return response
153
+ except BaseException:
154
+ activity.close()
155
+ raise
@@ -0,0 +1,50 @@
1
+ from __future__ import annotations
2
+
3
+ import django.db.models.deletion
4
+ from django.conf import settings
5
+ from django.db import migrations, models
6
+
7
+
8
+ class Migration(migrations.Migration):
9
+ dependencies = [
10
+ ("lx_annotate", "0009_videotranscodejob"),
11
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
12
+ ]
13
+
14
+ operations = [
15
+ migrations.CreateModel(
16
+ name="StudyCohort",
17
+ fields=[
18
+ (
19
+ "id",
20
+ models.BigAutoField(
21
+ auto_created=True,
22
+ primary_key=True,
23
+ serialize=False,
24
+ verbose_name="ID",
25
+ ),
26
+ ),
27
+ ("name", models.CharField(max_length=255)),
28
+ ("hypothesis", models.TextField()),
29
+ ("filters", models.JSONField(default=dict)),
30
+ ("created_at", models.DateTimeField(auto_now_add=True)),
31
+ ("updated_at", models.DateTimeField(auto_now=True)),
32
+ (
33
+ "created_by",
34
+ models.ForeignKey(
35
+ on_delete=django.db.models.deletion.PROTECT,
36
+ to=settings.AUTH_USER_MODEL,
37
+ ),
38
+ ),
39
+ (
40
+ "datasets",
41
+ models.ManyToManyField(
42
+ blank=True,
43
+ related_name="study_cohorts",
44
+ to="endoreg_db.aidataset",
45
+ ),
46
+ ),
47
+ ],
48
+ options={"ordering": ["name", "pk"]},
49
+ ),
50
+ ]
@@ -0,0 +1 @@
1
+ 0010_studycohort
@@ -10,6 +10,47 @@ from django.db import models
10
10
  User = get_user_model()
11
11
 
12
12
 
13
+ class StudyCohort(models.Model):
14
+ """User-owned cohort definition with shared dataset references, not copied annotations."""
15
+
16
+ name = models.CharField(max_length=255)
17
+ hypothesis = models.TextField()
18
+ filters = models.JSONField(default=dict)
19
+ datasets = models.ManyToManyField(
20
+ "endoreg_db.AIDataSet", related_name="study_cohorts", blank=True
21
+ )
22
+ created_by = models.ForeignKey(User, on_delete=models.PROTECT)
23
+ created_at = models.DateTimeField(auto_now_add=True)
24
+ updated_at = models.DateTimeField(auto_now=True)
25
+
26
+ def clean(self):
27
+ from pydantic import ValidationError as SchemaError
28
+
29
+ from lx_annotate.schemas.study_cohorts import CohortDefinition
30
+
31
+ super().clean()
32
+ try:
33
+ definition = CohortDefinition.model_validate(
34
+ {
35
+ "name": self.name,
36
+ "hypothesis": self.hypothesis,
37
+ "filters": self.filters,
38
+ }
39
+ )
40
+ except SchemaError as error:
41
+ raise ValidationError("Invalid study cohort definition.") from error
42
+ self.name = definition.name
43
+ self.hypothesis = definition.hypothesis
44
+ self.filters = definition.filters.model_dump(mode="json")
45
+
46
+ def save(self, *args, **kwargs):
47
+ self.full_clean()
48
+ return super().save(*args, **kwargs)
49
+
50
+ class Meta:
51
+ ordering = ["name", "pk"]
52
+
53
+
13
54
  class AIDatasetSplitPlan(models.Model):
14
55
  """Immutable, validated annotation membership snapshot."""
15
56
 
@@ -0,0 +1,52 @@
1
+ """Validated saved cohort definitions; membership is recomputed on explicit preview."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Annotated, Self
6
+
7
+ from endoreg_db.services.study_cohort import parse_study_cohort_filters
8
+ from pydantic import BaseModel, ConfigDict, Field, model_validator
9
+
10
+ PositiveId = Annotated[int, Field(strict=True, gt=0)]
11
+
12
+
13
+ class CohortFilters(BaseModel):
14
+ model_config = ConfigDict(extra="forbid", strict=True)
15
+
16
+ date_from: str | None = None
17
+ date_to: str | None = None
18
+ center_key: str | None = None
19
+ examination_name: str | None = None
20
+ document_type: str | None = None
21
+ finding: str | None = None
22
+ annotation_label: str | None = None
23
+ has_report: bool | None = None
24
+ has_video: bool | None = None
25
+ limit: int = Field(default=100, ge=1, le=500)
26
+
27
+ @model_validator(mode="after")
28
+ def valid_filters(self) -> Self:
29
+ parse_study_cohort_filters(self.model_dump())
30
+ return self
31
+
32
+
33
+ class CohortDefinition(BaseModel):
34
+ model_config = ConfigDict(extra="forbid", strict=True, str_strip_whitespace=True)
35
+
36
+ name: str = Field(min_length=1, max_length=255)
37
+ hypothesis: str = Field(min_length=1, max_length=10000)
38
+ filters: CohortFilters = Field(default_factory=CohortFilters)
39
+ dataset_ids: list[PositiveId] = Field(default_factory=list, max_length=500)
40
+
41
+ @model_validator(mode="after")
42
+ def unique_datasets(self) -> Self:
43
+ if len(self.dataset_ids) != len(set(self.dataset_ids)):
44
+ raise ValueError("Dataset IDs must be unique.")
45
+ return self
46
+
47
+
48
+ class CohortDatasetLink(BaseModel):
49
+ model_config = ConfigDict(extra="forbid", strict=True)
50
+
51
+ cohort_id: PositiveId
52
+ linked: bool
@@ -20,6 +20,7 @@ from endoreg_db.config.identity_hashing import load_identity_salt
20
20
  from endoreg_db.utils.paths import get_runtime_paths
21
21
  from kombu import Exchange, Queue
22
22
 
23
+ from lx_annotate.middleware.request_throttle import parse_request_throttle_directory
23
24
  from lx_annotate.settings.config import load_config, load_runtime_environment
24
25
 
25
26
  logger = getLogger(__name__)
@@ -682,6 +683,7 @@ MIDDLEWARE = [
682
683
  "corsheaders.middleware.CorsMiddleware",
683
684
  "django.middleware.security.SecurityMiddleware",
684
685
  "whitenoise.middleware.WhiteNoiseMiddleware",
686
+ "lx_annotate.middleware.request_throttle.FrontendRequestThrottleMiddleware",
685
687
  "django.contrib.sessions.middleware.SessionMiddleware",
686
688
  "django.middleware.common.CommonMiddleware",
687
689
  "django.middleware.csrf.CsrfViewMiddleware",
@@ -695,6 +697,10 @@ MIDDLEWARE = [
695
697
  ROOT_URLCONF = "lx_annotate.urls"
696
698
  WSGI_APPLICATION = "lx_annotate.wsgi.application"
697
699
 
700
+ LX_ANNOTATE_REQUEST_THROTTLE_DIRECTORY = parse_request_throttle_directory(
701
+ os.getenv("LX_ANNOTATE_REQUEST_THROTTLE_DIRECTORY", "")
702
+ )
703
+
698
704
  # -----------------------------------------------------------------------------
699
705
  # 3. TEMPLATES & FRONTEND
700
706
  # -----------------------------------------------------------------------------
@@ -13,7 +13,6 @@ from lx_annotate.settings.oidc import oidc_scopes_with_center_groups
13
13
 
14
14
  from .settings_base import (
15
15
  BASE_DIR,
16
- CELERY_BROKER_URL as CELERY_BROKER_URL,
17
16
  DATABASES,
18
17
  INSTALLED_APPS,
19
18
  LOGGING,
@@ -31,6 +30,9 @@ from .settings_base import (
31
30
  STORAGES,
32
31
  TEMPLATES,
33
32
  )
33
+ from .settings_base import (
34
+ CELERY_BROKER_URL as CELERY_BROKER_URL,
35
+ )
34
36
  from .settings_base import (
35
37
  DJANGO_SALT as DJANGO_SALT,
36
38
  )
@@ -0,0 +1,173 @@
1
+ """Saved cohorts and bidirectional dataset links with explicit, scoped previews."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from django.db import transaction
6
+ from django.db.models import F, Q
7
+ from django.shortcuts import get_object_or_404
8
+ from endoreg_db.models import AIDataSet, PatientExamination, VideoFile
9
+ from endoreg_db.services.center_access import resolve_allowed_center_ids
10
+ from endoreg_db.services.study_cohort import (
11
+ build_study_cohort_payload,
12
+ parse_study_cohort_filters,
13
+ )
14
+ from pydantic import ValidationError
15
+ from rest_framework.decorators import api_view, permission_classes
16
+ from rest_framework.permissions import IsAuthenticated
17
+ from rest_framework.request import Request
18
+ from rest_framework.response import Response
19
+
20
+ from lx_annotate.models import StudyCohort
21
+ from lx_annotate.schemas.study_cohorts import (
22
+ CohortDatasetLink,
23
+ CohortDefinition,
24
+ )
25
+ from lx_annotate.views.ai_dataset_splits import require_dataset_access
26
+ from lx_annotate.views.study_export import StudyExportPatientReadPermission
27
+
28
+
29
+ def cohort_response(cohort: StudyCohort) -> dict[str, object]:
30
+ return {
31
+ "id": cohort.pk,
32
+ "name": cohort.name,
33
+ "hypothesis": cohort.hypothesis,
34
+ "filters": cohort.filters,
35
+ "dataset_ids": list(
36
+ cohort.datasets.order_by("pk").values_list("pk", flat=True)
37
+ ),
38
+ "updated_at": cohort.updated_at.isoformat(),
39
+ }
40
+
41
+
42
+ def validated_datasets(ids: list[int], user: object) -> list[AIDataSet]:
43
+ datasets = list(AIDataSet.objects.filter(pk__in=ids).order_by("pk"))
44
+ if len(datasets) != len(ids):
45
+ raise ValueError(
46
+ "One or more datasets no longer exist. Reload the dataset list."
47
+ )
48
+ for dataset in datasets:
49
+ require_dataset_access(user, dataset)
50
+ return datasets
51
+
52
+
53
+ def save_definition(request: Request, cohort: StudyCohort | None = None) -> Response:
54
+ try:
55
+ definition = CohortDefinition.model_validate(request.data)
56
+ with transaction.atomic():
57
+ datasets = validated_datasets(definition.dataset_ids, request.user)
58
+ if cohort is None:
59
+ cohort = StudyCohort(created_by=request.user)
60
+ else:
61
+ cohort = StudyCohort.objects.select_for_update().get(pk=cohort.pk)
62
+ cohort.name = definition.name
63
+ cohort.hypothesis = definition.hypothesis
64
+ cohort.filters = definition.filters.model_dump(mode="json")
65
+ cohort.save()
66
+ cohort.datasets.set(datasets)
67
+ except (ValidationError, ValueError) as error:
68
+ return Response({"detail": str(error)}, status=400)
69
+ return Response(
70
+ cohort_response(cohort), status=200 if request.method == "PUT" else 201
71
+ )
72
+
73
+
74
+ @api_view(["GET", "POST"])
75
+ @permission_classes([IsAuthenticated, StudyExportPatientReadPermission])
76
+ def study_cohorts(request: Request) -> Response:
77
+ if request.method == "POST":
78
+ return save_definition(request)
79
+ cohorts = StudyCohort.objects.filter(created_by=request.user).prefetch_related(
80
+ "datasets"
81
+ )
82
+ return Response([cohort_response(cohort) for cohort in cohorts])
83
+
84
+
85
+ @api_view(["PUT"])
86
+ @permission_classes([IsAuthenticated, StudyExportPatientReadPermission])
87
+ def study_cohort_detail(request: Request, cohort_id: int) -> Response:
88
+ cohort = get_object_or_404(StudyCohort, pk=cohort_id, created_by=request.user)
89
+ return save_definition(request, cohort)
90
+
91
+
92
+ @api_view(["GET", "POST"])
93
+ @permission_classes([IsAuthenticated, StudyExportPatientReadPermission])
94
+ def dataset_study_cohorts(request: Request, dataset_id: int) -> Response:
95
+ dataset = get_object_or_404(AIDataSet, pk=dataset_id)
96
+ require_dataset_access(request.user, dataset)
97
+ if request.method == "POST":
98
+ try:
99
+ link = CohortDatasetLink.model_validate(request.data)
100
+ except ValidationError as error:
101
+ return Response({"detail": str(error)}, status=400)
102
+ with transaction.atomic():
103
+ cohort = get_object_or_404(
104
+ StudyCohort.objects.select_for_update(),
105
+ pk=link.cohort_id,
106
+ created_by=request.user,
107
+ )
108
+ if link.linked:
109
+ cohort.datasets.add(dataset)
110
+ else:
111
+ cohort.datasets.remove(dataset)
112
+ cohort.save()
113
+ return Response(cohort_response(cohort))
114
+ cohorts = StudyCohort.objects.filter(created_by=request.user, datasets=dataset)
115
+ return Response([cohort_response(cohort) for cohort in cohorts])
116
+
117
+
118
+ @api_view(["POST"])
119
+ @permission_classes([IsAuthenticated, StudyExportPatientReadPermission])
120
+ def study_cohort_preview(request: Request) -> Response:
121
+ try:
122
+ definition = CohortDefinition.model_validate(request.data)
123
+ datasets = validated_datasets(definition.dataset_ids, request.user)
124
+ except (ValidationError, ValueError) as error:
125
+ return Response({"detail": str(error)}, status=400)
126
+ cases = PatientExamination.objects.all()
127
+ allowed = resolve_allowed_center_ids(request.user)
128
+ if allowed is not None:
129
+ cases = cases.filter(patient__center_id__in=allowed)
130
+ missing_examination_count = 0
131
+ conflicting_patient_count = 0
132
+ dataset_video_count = 0
133
+ if datasets:
134
+ video_ids = set()
135
+ for dataset in datasets:
136
+ video_ids.update(
137
+ dataset.image_annotations.values_list("frame__video_id", flat=True)
138
+ )
139
+ video_ids.update(
140
+ dataset.video_annotations.values_list("video_file_id", flat=True)
141
+ )
142
+ videos = VideoFile.objects.filter(pk__in=video_ids)
143
+ dataset_video_count = videos.count()
144
+ missing_examination_count = videos.filter(examination__isnull=True).count()
145
+ conflicting = videos.filter(
146
+ patient__isnull=False, examination__isnull=False
147
+ ).exclude(patient_id=F("examination__patient_id"))
148
+ conflicting_patient_count = conflicting.count()
149
+ videos = videos.exclude(pk__in=conflicting.values("pk"))
150
+ cases = cases.filter(pk__in=videos.values("examination_id"))
151
+ candidate_count = cases.count()
152
+ pseudonymous = cases.filter(patient__is_real_person=False).exclude(
153
+ Q(patient__patient_hash__isnull=True) | Q(patient__patient_hash="")
154
+ )
155
+ payload = build_study_cohort_payload(
156
+ parse_study_cohort_filters(definition.filters.model_dump()),
157
+ request=request,
158
+ case_scope=pseudonymous,
159
+ )
160
+ return Response(
161
+ {
162
+ **payload,
163
+ "eligibility": {
164
+ "dataset_count": len(datasets),
165
+ "dataset_video_count": dataset_video_count,
166
+ "missing_examination_video_count": missing_examination_count,
167
+ "conflicting_patient_video_count": conflicting_patient_count,
168
+ "candidate_examination_count": candidate_count,
169
+ "pseudonymous_examination_count": pseudonymous.count(),
170
+ "displayed_patient_count": len(payload["cases"]),
171
+ },
172
+ }
173
+ )
@@ -49,31 +49,12 @@ def _select_settings_module(argv: list[str]) -> str:
49
49
  return PROD_SETTINGS_MODULE
50
50
 
51
51
 
52
- def _ensure_required_runtime_packages() -> None:
53
- if importlib.util.find_spec("endoreg_db") is None:
54
- raise ImportError(
55
- "Required package 'endoreg_db' is not installed in the active Python "
56
- "environment. Install the packaged dependency instead of relying on a "
57
- "repo-local checkout.",
58
- )
59
-
60
52
 
61
53
  os.environ["DJANGO_SETTINGS_MODULE"] = _select_settings_module(sys.argv)
62
54
 
63
55
 
64
56
  def main():
65
57
  """Run administrative tasks."""
66
- try:
67
- _ensure_required_runtime_packages()
68
- from django.core.management import execute_from_command_line
69
-
70
- except ImportError as exc:
71
- raise ImportError(
72
- "Failed to start management command because a required runtime "
73
- "dependency is missing. Ensure Django and endoreg_db are installed "
74
- "in the active environment rather than imported from a repo-local checkout.",
75
- ) from exc
76
- execute_from_command_line(sys.argv)
77
58
 
78
59
 
79
60
  if __name__ == "__main__":
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
5
5
  [project]
6
6
  name = "lx-annotate"
7
7
 
8
- version = "1.3.2"
8
+ version = "1.3.4"
9
9
  description = "This webapp provides a frontend interface for pseudonymizing and annotating data and applying AI predictions."
10
10
  authors = [
11
11
  { name = "Max Hild", email = "hild_m@ukw.de"},
@@ -52,7 +52,7 @@ dependencies = [
52
52
  "daphne>=4.2.1",
53
53
  "psycopg[binary,pool]>=3.2.12",
54
54
  "mozilla-django-oidc>=4.0.1",
55
- "endoreg-db==1.3.4",
55
+ "endoreg-db==1.3.7",
56
56
  "pydantic-settings>=2.12.0",
57
57
  "pydantic>=2.12.5",
58
58
  "sops>=1.18",