From cc810544cda5a5189c3ea74ae52010cb1e2a790b Mon Sep 17 00:00:00 2001 From: hdoupe Date: Sat, 28 Sep 2019 09:45:16 -0400 Subject: [PATCH] Bump allowed traceback length and truncate if its over --- .../migrations/0015_auto_20190928_0840.py | 25 +++++++++++++++++++ webapp/apps/comp/models.py | 6 ++--- webapp/apps/comp/views/core.py | 2 ++ 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100755 webapp/apps/comp/migrations/0015_auto_20190928_0840.py diff --git a/webapp/apps/comp/migrations/0015_auto_20190928_0840.py b/webapp/apps/comp/migrations/0015_auto_20190928_0840.py new file mode 100755 index 00000000..76d62bfb --- /dev/null +++ b/webapp/apps/comp/migrations/0015_auto_20190928_0840.py @@ -0,0 +1,25 @@ +# Generated by Django 2.2.5 on 2019-09-28 13:40 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [("comp", "0014_auto_20190805_1601")] + + operations = [ + migrations.AlterField( + model_name="inputs", + name="traceback", + field=models.CharField( + blank=True, default=None, max_length=8000, null=True + ), + ), + migrations.AlterField( + model_name="simulation", + name="traceback", + field=models.CharField( + blank=True, default=None, max_length=8000, null=True + ), + ), + ] diff --git a/webapp/apps/comp/models.py b/webapp/apps/comp/models.py index 217f6efb..b7750bbb 100755 --- a/webapp/apps/comp/models.py +++ b/webapp/apps/comp/models.py @@ -38,7 +38,7 @@ def from_hashid(self, hashid): def get_object_from_hashid_or_404(self, hashid): """ - Get inputs object from a hash of its pk and + Get inputs object from a hash of its pk and raise 404 exception if it does not exist. """ try: @@ -78,7 +78,7 @@ class Inputs(models.Model): owner = models.ForeignKey( "users.Profile", on_delete=models.CASCADE, null=True, related_name="inputs" ) - traceback = models.CharField(null=True, blank=True, default=None, max_length=4000) + traceback = models.CharField(null=True, blank=True, default=None, max_length=8000) job_id = models.UUIDField(blank=True, default=None, null=True) status = models.CharField( choices=( @@ -168,7 +168,7 @@ class Simulation(models.Model): meta_data = JSONField(default=None, blank=True, null=True) outputs = JSONField(default=None, blank=True, null=True) aggr_outputs = JSONField(default=None, blank=True, null=True) - traceback = models.CharField(null=True, blank=True, default=None, max_length=4000) + traceback = models.CharField(null=True, blank=True, default=None, max_length=8000) owner = models.ForeignKey( "users.Profile", on_delete=models.CASCADE, null=True, related_name="sims" ) diff --git a/webapp/apps/comp/views/core.py b/webapp/apps/comp/views/core.py index d80a7c08..95646f06 100755 --- a/webapp/apps/comp/views/core.py +++ b/webapp/apps/comp/views/core.py @@ -127,4 +127,6 @@ def record_outputs(self, sim, data): else: sim.status = "FAIL" sim.traceback = data["traceback"] + if isinstance(sim.traceback, str) and len(sim.traceback) > 8000: + sim.traceback = sim.traceback[:8000] sim.save()