Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyhans committed Feb 11, 2025
1 parent df64f2a commit 0309df1
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 44 deletions.
6 changes: 3 additions & 3 deletions hawc/apps/assessment/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,11 +1009,11 @@ class TrainedModelVersionForm(forms.ModelForm):

class Meta:
model = TrainedModelVersion
fields = ["model", "notes", "vectorizer", "new_vectorizer"]
fields = ["model", "description", "vectorizer", "new_vectorizer"]

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["notes"].widget.attrs["rows"] = 1
self.fields["description"].widget.attrs["rows"] = 1

@property
def helper(self):
Expand All @@ -1022,7 +1022,7 @@ def helper(self):
helper.layout = cfl.Layout(
cfl.Row(
cfl.Column("model"),
cfl.Column("notes"),
cfl.Column("description"),
cfl.Column("vectorizer"),
cfl.Column("new_vectorizer"),
)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block content %}

<form method="post" enctype="multipart/form-data">
<form method="post" enctype="multipart/form-data" class="mt-2">
{% csrf_token %}

<div class="card mb-3">
Expand Down
41 changes: 28 additions & 13 deletions hawc/apps/assessment/templates/assessment/trained_model_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,46 @@
{% block content %}


<div class="d-flex align-items-start">
<div class="d-flex align-items-start mt-2">
<h2 class="mt-0 mb-2">{{object.name}}</h2>
<!-- <a class="ml-auto btn btn-primary mt-1" href="{% url 'assessment:trained_model_create' %}">Create a model</a> -->
<span class="unpublishedBadge align-self-start flex-shrink-0 badge badge-pill ml-auto mt-1 border {{ object.published|yesno:'border-success text-success,border-secondary text-muted' }}" style="font-size: 0.75rem; vertical-align: top;" title="{{object.published|yesno:'Published,Unpublished'}}"><i class="fa fa-{{ object.published|yesno:'eye,eye-slash' }}" aria-hidden="true"></i> <i>{{object.published|yesno:'Published,Unpublished'}}</i></span>
{% actions %}
<a class="dropdown-item" href="{{object.get_update_url}}">Upload new model version</a>
<a class="dropdown-item" href="{{object.get_update_url}}">Edit model details or upload new version</a>
{% endactions %}
</div>
{{object.description}}
<h4>Versions</h4>
<div class="list-group mb-4">
{% for object in object.versions.all %}
<div class="list-group-item text-dark d-flex">
<i>Version {{object.version}}</i>: {{object.notes}} &nbsp;<b>Vectorizer</b>: {{object.vectorizer}}
<div>{{object.description}}</div>
{% for object in object.versions.all %}
<div class="my-3 pb-3">
<h4 class="m-0">{{object}}</h4>
<div class="d-flex mt-2">
{% if object.description %}
<div class="box-shadow-minor rounded p-3 mr-3" style="min-height: 3rem;">
<div class="font-weight-bold" style="font-size: 1.1rem;">Description:</div>
<div title="{{object.description}}">{{object.description|truncatechars:75}}</div>
</div>
{% endif %}
<div class="box-shadow-minor rounded p-3 mr-3" style="min-height: 3rem;">
<div class="font-weight-bold" style="font-size: 1.1rem;">Vectorizer: {{object.vectorizer}}</div>
<div class="text-muted text-overflow" title="{{object.vectorizer.description}}"><i>{{object.vectorizer.description|truncatechars:75}}</i></div>
</div>
<div class="box-shadow-minor rounded p-3 flex-shrink-0" style="min-height: 3rem;">
<div class="font-weight-bold" style="font-size: 1.1rem;">Created</div>
<div>{{object.created|date:"DATE_FORMAT"}}</div>
</div>
</div>

{% if object.prediction_runs.exists %}
<div class="list-group mb-4 ml-4">
<div class="list-group my-3">
{% for object in object.prediction_runs.all %}
<a class="list-group-item list-group-item-action text-dark d-flex" href="{{object.get_absolute_url}}">
Model ran in {{object.workflow.assessment}} on {{object.workflow}}
</a>
{% endfor %}
</div>
{% endif %}
{% empty %}
{% alert type="info" %}No versions found.{% endalert %}
{% endfor %}
</div>
{% empty %}
{% alert type="info" %}No versions found.{% endalert %}
{% endfor %}

{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block content %}


<div class="d-flex align-items-start">
<div class="d-flex align-items-start mt-2">
<h2 class="mt-0 mb-2">Trained Models</h2>
<a class="ml-auto btn btn-primary mt-1" href="{% url 'assessment:trained_model_create' %}">Create a model</a>
</div>
Expand Down
6 changes: 3 additions & 3 deletions hawc/apps/assessment/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,17 @@
name="label-item",
),
path(
"trained-model/create/",
"trained-models/create/",
views.TrainedModelCreate.as_view(),
name="trained_model_create",
),
path(
"trained-model/update/<int:pk>",
"trained-models/update/<int:pk>",
views.TrainedModelUpdate.as_view(),
name="trained_model_update",
),
path(
"trained-model/<int:pk>/",
"trained-models/<int:pk>/",
views.TrainedModelDetail.as_view(),
name="trained_model_detail",
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1.4 on 2025-02-11 03:56
# Generated by Django 5.1.4 on 2025-02-11 04:35

import django.core.files.storage
import django.core.validators
Expand Down Expand Up @@ -30,11 +30,11 @@ class Migration(migrations.Migration):
help_text="Publish this model for all users to see and use across assessments.",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("created", models.DateTimeField(auto_now_add=True)),
("last_updated", models.DateTimeField(auto_now=True)),
],
options={
"ordering": ["-updated_at"],
"ordering": ["-created"],
},
),
migrations.CreateModel(
Expand All @@ -57,8 +57,7 @@ class Migration(migrations.Migration):
upload_to="trained-vectorizers/",
),
),
("created_at", models.DateTimeField(auto_now_add=True)),
("updated_at", models.DateTimeField(auto_now=True)),
("created", models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
Expand All @@ -85,8 +84,8 @@ class Migration(migrations.Migration):
upload_to="trained-models/",
),
),
("notes", models.TextField(blank=True)),
("created_at", models.DateTimeField(auto_now_add=True)),
("description", models.TextField(blank=True)),
("created", models.DateTimeField(auto_now_add=True)),
(
"trained_model",
models.ForeignKey(
Expand Down
13 changes: 6 additions & 7 deletions hawc/apps/lit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1469,8 +1469,7 @@ class TrainedVectorizer(models.Model):
vectorizer = models.FileField(
upload_to="trained-vectorizers/", storage=get_private_data_storage()
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created = models.DateTimeField(auto_now_add=True)

def __str__(self):
return self.name
Expand All @@ -1483,14 +1482,14 @@ class TrainedModel(models.Model):
default=False,
help_text="Publish this model for all users to see and use across assessments.",
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created = models.DateTimeField(auto_now_add=True)
last_updated = models.DateTimeField(auto_now=True)

def __str__(self):
return self.name

class Meta:
ordering = ["-updated_at"]
ordering = ["-created"]

def get_absolute_url(self):
return reverse("assessment:trained_model_detail", args=(self.id,))
Expand All @@ -1513,8 +1512,8 @@ class TrainedModelVersion(models.Model):
on_delete=models.PROTECT,
related_name="trained_models",
)
notes = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
description = models.TextField(blank=True)
created = models.DateTimeField(auto_now_add=True)

def __str__(self):
return f"{self.trained_model.name} v{self.version}"
Expand Down
2 changes: 1 addition & 1 deletion hawc/apps/lit/templates/lit/model_prediction_run.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block content %}

<h3>{{object.model_version}} ran on <i>{{object.workflow}}</i></h3>
<h3 class="mt-2">{{object.model_version}} ran on <i>{{object.workflow}}</i></h3>

<p>{{object.notes}}</p>

Expand Down

0 comments on commit 0309df1

Please sign in to comment.