From 12d6acde21c16694145b472a856a9773fc254b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Robidas?= Date: Fri, 19 Jan 2024 07:55:29 -0500 Subject: [PATCH] Raised the max runtime to 24 hours --- calcus/settings.py | 2 +- frontend/management/commands/add_resources.py | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 frontend/management/commands/add_resources.py diff --git a/calcus/settings.py b/calcus/settings.py index 678444b0..3a8fbd0f 100755 --- a/calcus/settings.py +++ b/calcus/settings.py @@ -321,7 +321,7 @@ }, "subscriber": { "nproc": 8, - "time": 6 * 60, + "time": 24 * 60, }, } diff --git a/frontend/management/commands/add_resources.py b/frontend/management/commands/add_resources.py new file mode 100755 index 00000000..cd8a5d05 --- /dev/null +++ b/frontend/management/commands/add_resources.py @@ -0,0 +1,29 @@ +import os +from django.core.management.base import BaseCommand + +from frontend.models import * +from frontend.environment_variables import * +from frontend.tasks import run_calc +from frontend.helpers import get_random_string + + +class Command(BaseCommand): + help = "Runs a calculation" + + def add_arguments(self, parser): + parser.add_argument("email", type=str) + parser.add_argument("time", type=int) + + def handle(self, *args, **options): + email = options["email"] + time = options["time"] + try: + u = User.objects.get(email=email) + except User.DoesNotExist: + raise Exception(f"Could not find user with email {email}") + random_code = get_random_string(64) + + res = ResourceAllocation.objects.create( + code=random_code, note=ResourceAllocation.MANUAL, allocation_seconds=time + ) + res.redeem(u)