Skip to content

Commit

Permalink
Merge pull request #143 from bptlab/improvement/136-extraction-pipeline
Browse files Browse the repository at this point in the history
Improvement/136 extraction pipeline
  • Loading branch information
nils-schmitt authored May 24, 2024
2 parents 085a70a + 56b2e0c commit 6fae209
Show file tree
Hide file tree
Showing 33 changed files with 1,629 additions and 1,780 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ plotly~=5.22.0
pandas~=2.1.3
numpy~=1.26.2
jinja2~=3.1.4
regex~=2024.5.15
55 changes: 46 additions & 9 deletions tracex_project/extraction/admin.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,59 @@
"""Admin file for extraction app."""
from typing import Union

from django.contrib import admin

from extraction.models import Event, PatientJourney, Prompt, Trace, Cohort, Metric


class CohortInline(admin.StackedInline):
"""Inline for the Cohort model, used to display the related Cohort object in the Trace admin page."""
"""
Django admin interface for the Cohort model.
This inline admin interface is used to manage Cohort instances directly from the Trace admin page.
No extra blank forms are displayed for adding new Cohort instances, and deletion of Cohort instances
from the Trace admin page is not allowed.
Attributes:
model: Specifies the model that this inline admin interface is for.
extra: Defines how many extra blank forms are displayed on the admin page when a new Trace is created.
can_delete: Determines whether the deletion of instances of the model is allowed from the admin interface.
"""

model = Cohort
extra = 0
can_delete = False


class TraceInline(admin.TabularInline):
"""Inline for the Trace model, used to display the related Trace objects in the PatientJourney admin page."""
"""
Django admin interface for the Trace model.
This inline admin interface is used to manage Trace instances directly from the PatientJourney admin page.
No extra blank forms are displayed for adding new Trace instances.
Attributes:
model: Specifies the model that this inline admin interface is for.
extra: Defines how many extra blank forms are displayed on the admin page when a new PatientJourney is created.
"""

model = Trace
extra = 0 # Controls the number of empty forms displayed for adding related objects


class EventInline(admin.TabularInline):
"""Inline for the Event model, used to display the related Event objects in the Trace admin page."""
"""
Django admin interface for the Event model.
This inline admin interface is used to manage Event instances directly from the Trace admin page.
No extra blank forms are displayed for adding new Event instances. Certain fields related to metrics
are read-only.
Attributes:
model: Specifies the model that this inline admin interface is for.
extra: Defines how many extra blank forms are displayed on the admin page when a new Trace is created.
readonly_fields: Specifies which fields on the admin interface are read-only.
"""

model = Event
extra = 0
Expand All @@ -29,36 +63,39 @@ class EventInline(admin.TabularInline):
"metrics_correctness_confidence",
)

def metrics_activity_relevance(self, obj):
@staticmethod
def metrics_activity_relevance(obj: Event) -> Union[str, int]:
"""Returns the activity relevance metric for the event."""
return obj.metrics.activity_relevance if hasattr(obj, "metrics") else "-"

def metrics_timestamp_correctness(self, obj):
@staticmethod
def metrics_timestamp_correctness(obj: Event) -> Union[str, int]:
"""Returns the timestamp correctness metric for the event."""
return obj.metrics.timestamp_correctness if hasattr(obj, "metrics") else "-"

def metrics_correctness_confidence(self, obj):
@staticmethod
def metrics_correctness_confidence(obj: Event) -> Union[str, int]:
"""Returns the correctness confidence metric for the event."""
return obj.metrics.correctness_confidence if hasattr(obj, "metrics") else "-"


@admin.register(PatientJourney)
class PatientJourneyAdmin(admin.ModelAdmin):
"""Admin page for the PatientJourney model."""
"""Django admin interface for managing PatientJourney instances and related Trace instances."""

inlines = [TraceInline]


@admin.register(Trace)
class TraceAdmin(admin.ModelAdmin):
"""Admin page for the Trace model."""
"""Django admin interface for managing Trace instances and related Cohort and Event instances."""

inlines = [CohortInline, EventInline]


@admin.register(Event)
class EventAdmin(admin.ModelAdmin):
"""Admin page for the Event model."""
"""Django admin interface for managing Event instances."""


admin.site.register(Metric)
Expand Down
11 changes: 10 additions & 1 deletion tracex_project/extraction/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@


class ExtractionConfig(AppConfig):
"""App configuration class for django UI."""
"""
Configuration class for the 'extraction' Django application.
This class allows customization of application configuration. It sets the default type of auto-created
primary key fields to be 64-bit integers and specifies the name of the application.
Attributes:
default_auto_field: The type of auto-created primary key fields for models in this application.
name: The name of the application that is being configured.
"""

default_auto_field = "django.db.models.BigAutoField"
name = "extraction"

This file was deleted.

Loading

0 comments on commit 6fae209

Please sign in to comment.