58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
|
|
from django.contrib import admin
|
||
|
|
from django.contrib.admin import ModelAdmin, TabularInline
|
||
|
|
from apps.mlstore.models import AgentModel, AgentRun, Agent, AgentEvent
|
||
|
|
|
||
|
|
|
||
|
|
class AgentInline(TabularInline):
|
||
|
|
model = Agent
|
||
|
|
extra = 0
|
||
|
|
raw_id_fields = ('model',)
|
||
|
|
|
||
|
|
|
||
|
|
class AgentRunInline(TabularInline):
|
||
|
|
model = AgentRun
|
||
|
|
extra = 0
|
||
|
|
raw_id_fields = ('agent', 'user')
|
||
|
|
|
||
|
|
|
||
|
|
class AgentEventInline(TabularInline):
|
||
|
|
model = AgentEvent
|
||
|
|
extra = 0
|
||
|
|
raw_id_fields = ('execution',)
|
||
|
|
|
||
|
|
|
||
|
|
@admin.register(AgentModel)
|
||
|
|
class AgentModelAdmin(ModelAdmin):
|
||
|
|
list_display = ('id', 'uuid', 'name', 'version')
|
||
|
|
search_fields = ('name', 'version')
|
||
|
|
inlines = (AgentInline,)
|
||
|
|
readonly_fields = ('uuid',)
|
||
|
|
|
||
|
|
|
||
|
|
@admin.register(Agent)
|
||
|
|
class AgentAdmin(ModelAdmin):
|
||
|
|
list_display = ('id', 'uuid', 'model', 'status', 'started_at', 'completed_at')
|
||
|
|
search_fields = ('model__name', 'uuid')
|
||
|
|
list_filter = ('status',)
|
||
|
|
inlines = (AgentRunInline,)
|
||
|
|
raw_id_fields = ('model',)
|
||
|
|
readonly_fields = ('uuid', 'started_at', 'completed_at')
|
||
|
|
|
||
|
|
|
||
|
|
@admin.register(AgentRun)
|
||
|
|
class AgentRunAdmin(ModelAdmin):
|
||
|
|
list_display = ('id', 'uuid', 'agent', 'user', 'status', 'started_at', 'completed_at')
|
||
|
|
search_fields = ('uuid', 'agent__model__name', 'user__email_address')
|
||
|
|
list_filter = ('status',)
|
||
|
|
inlines = (AgentEventInline,)
|
||
|
|
raw_id_fields = ('agent', 'user')
|
||
|
|
readonly_fields = ('uuid', 'started_at', 'completed_at')
|
||
|
|
|
||
|
|
|
||
|
|
@admin.register(AgentEvent)
|
||
|
|
class AgentEventAdmin(ModelAdmin):
|
||
|
|
list_display = ('id', 'event_type', 'execution', 'timestamp')
|
||
|
|
search_fields = ('event_type', 'execution__uuid', 'execution__agent__model__name')
|
||
|
|
list_filter = ('event_type',)
|
||
|
|
raw_id_fields = ('execution',)
|