From 00f496b446eb26fa1f22d2b275d392e57bf95abd Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Tue, 26 Nov 2024 18:25:14 +0100 Subject: [PATCH] Interactive task via IO change (#396) * Interactive task changes after ONTAK * Add migration * Update test packages * Fix tests * Bump required sioworkers version * Remove tmp hack --- oioioi/interactive/controllers.py | 4 ++- .../migrations/0002_interactivetaskinfo.py | 23 ++++++++++++++++++ oioioi/interactive/models.py | 7 ++++++ oioioi/programs/handlers.py | 2 ++ oioioi/sinolpack/controllers.py | 16 ++++++++++++ .../files/test_sigpipe_interactor.tgz | Bin 546 -> 743 bytes .../files/test_simple_interactive.tgz | Bin 949 -> 1178 bytes oioioi/sinolpack/package.py | 16 +++++++++--- oioioi/sinolpack/tests.py | 3 +-- requirements.txt | 2 +- 10 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 oioioi/interactive/migrations/0002_interactivetaskinfo.py diff --git a/oioioi/interactive/controllers.py b/oioioi/interactive/controllers.py index cf01aa72c..8a34152e6 100644 --- a/oioioi/interactive/controllers.py +++ b/oioioi/interactive/controllers.py @@ -1,7 +1,7 @@ from django.utils.translation import gettext_lazy as _ from oioioi.filetracker.utils import django_to_filetracker_path -from oioioi.interactive.models import Interactor +from oioioi.interactive.models import Interactor, InteractiveTaskInfo from oioioi.programs.controllers import ProgrammingProblemController @@ -13,6 +13,8 @@ def fill_evaluation_environ(self, environ, submission, **kwargs): interactor = Interactor.objects.get(problem=self.problem) environ['interactor_file'] = django_to_filetracker_path(interactor.exe_file) + info = InteractiveTaskInfo.objects.get(problem=self.problem) + environ['num_processes'] = info.num_processes environ['task_type_suffix'] = '-interactive-exec' diff --git a/oioioi/interactive/migrations/0002_interactivetaskinfo.py b/oioioi/interactive/migrations/0002_interactivetaskinfo.py new file mode 100644 index 000000000..6a10e145e --- /dev/null +++ b/oioioi/interactive/migrations/0002_interactivetaskinfo.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.13 on 2024-07-10 11:33 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('problems', '0031_auto_20220328_1124'), + ('interactive', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='InteractiveTaskInfo', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('num_processes', models.IntegerField(default=1, verbose_name="number of user's processes to run")), + ('problem', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='problems.problem')), + ], + ), + ] diff --git a/oioioi/interactive/models.py b/oioioi/interactive/models.py index 80abaf568..c1ba1a066 100644 --- a/oioioi/interactive/models.py +++ b/oioioi/interactive/models.py @@ -17,3 +17,10 @@ class Interactor(models.Model): class Meta(object): verbose_name = _("interactive executable file") verbose_name_plural = _("interactive executable files"), + + +class InteractiveTaskInfo(models.Model): + problem = models.OneToOneField(Problem, on_delete=models.CASCADE) + num_processes = models.IntegerField( + verbose_name=_("number of user's processes to run"), default=1 + ) diff --git a/oioioi/programs/handlers.py b/oioioi/programs/handlers.py index 03bcee9d2..96470db78 100755 --- a/oioioi/programs/handlers.py +++ b/oioioi/programs/handlers.py @@ -295,6 +295,8 @@ def run_tests(env, kind=None, **kwargs): job['upload_out'] = True if env.get('interactor_file'): job['interactor_file'] = env['interactor_file'] + if env.get('num_processes'): + job['num_processes'] = env['num_processes'] job['untrusted_checker'] = env['untrusted_checker'] jobs[test_name] = job extra_args = env.get('sioworkers_extra_args', {}).get(kind, {}) diff --git a/oioioi/sinolpack/controllers.py b/oioioi/sinolpack/controllers.py index c054a3ccb..f7fbf59c7 100644 --- a/oioioi/sinolpack/controllers.py +++ b/oioioi/sinolpack/controllers.py @@ -1,5 +1,6 @@ from django.utils.translation import gettext_lazy as _ +from oioioi.interactive.controllers import InteractiveProblemController from oioioi.programs.controllers import ProgrammingProblemController from oioioi.sinolpack.admin import SinolpackProblemAdminMixin from oioioi.sinolpack.utils import add_extra_files @@ -18,3 +19,18 @@ def mixins_for_admin(self): return super(SinolProblemController, self).mixins_for_admin() + ( SinolpackProblemAdminMixin, ) + + +class SinolInteractiveProblemController(InteractiveProblemController): + description = _("Sinol package interactive problem") + + def fill_evaluation_environ(self, environ, submission, **kwargs): + super(SinolInteractiveProblemController, self).fill_evaluation_environ( + environ, submission, **kwargs + ) + add_extra_files(environ, self.problem) + + def mixins_for_admin(self): + return super(SinolInteractiveProblemController, self).mixins_for_admin() + ( + SinolpackProblemAdminMixin, + ) diff --git a/oioioi/sinolpack/files/test_sigpipe_interactor.tgz b/oioioi/sinolpack/files/test_sigpipe_interactor.tgz index 604746d308da1beb301eb81e10ac67cc62d3176c..c1234375de48042b2199335afa737dc7fcfc66af 100644 GIT binary patch literal 743 zcmVVJpQ| z|EJ|%+1<+D?ZvMpEcap z4_e^YGn{p7x&B6&lplf?<3bc1gfv{m%!oVg8IkduRAj;&0zsL)jAyxeTrtrDPnOwD zp>oEx<{FLOzn+l8t6=kA$a=Sc*VKPX2Dbi3G<5a93C#4zi{BHno*0|;4^aOBCHNJR z(AIxHB(DB90UEiAz0I)spO>cA4dC_lpAb55^}h*N{qgy2T<0I)FZ8Dar+*_@=#Pya zD~dW|Y}6k$U+n*bYX1*OQI#X@$v@blR{3Tz!#^PkjI05;}-K8+|L!Tyi7+Br#c6|AYOgMxM&4j&w^W0mT_r% z*x`I*pdWDANq|Fmo{mD|{Q)&@9 ZkAs7QgM)*EgM&kj_yrILlj#5`003Y?c;Em4 literal 546 zcmV+-0^R)|iwFRX&qQVb1MOJBj@uv*%{Bgt(e{#UDhDv&L$bN{P^l~R(nGrkmf!>_ z#*wirb*ugNg5xGxRce|8Uai7AWC$|??8h4hi$^&d1qMPWXAC;a_ZAVlw>|jD8nOQp%>=S+D6oFDWzysYoAJCwWy!|j&or}@sDx(=Q!9m0^#_t+9v28xPX5~ zGv@i{H1a zI{jI0!_48{2dDJ^@_$A={~RGY0u*LBFA@2lrBcX^3YP&c(tqyjKZY5J`X2&^{O=k# zmAhSlInL@oBS-$3=bvXNi~1h|+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