memory limit
This commit is contained in:
parent
512bca4024
commit
1a6bf13b96
22
Main/migrations/0034_auto_20220509_1922.py
Normal file
22
Main/migrations/0034_auto_20220509_1922.py
Normal file
@ -0,0 +1,22 @@
|
||||
# Generated by Django 3.2.4 on 2022-05-09 16:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('Main', '0033_solution_docker_instances'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='solution',
|
||||
name='docker_instances',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='task',
|
||||
name='memory_limit',
|
||||
field=models.IntegerField(default=1024),
|
||||
),
|
||||
]
|
17
Main/migrations/0035_remove_task_memory_limit.py
Normal file
17
Main/migrations/0035_remove_task_memory_limit.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 3.2.4 on 2022-05-09 16:49
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('Main', '0034_auto_20220509_1922'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='task',
|
||||
name='memory_limit',
|
||||
),
|
||||
]
|
18
Main/migrations/0036_task_memory_limit.py
Normal file
18
Main/migrations/0036_task_memory_limit.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.4 on 2022-05-09 16:50
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('Main', '0035_remove_task_memory_limit'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='task',
|
||||
name='memory_limit',
|
||||
field=models.IntegerField(default=524288),
|
||||
),
|
||||
]
|
@ -21,7 +21,6 @@ class Solution(models.Model):
|
||||
test = models.IntegerField(default=None, null=True, blank=True)
|
||||
set = models.ForeignKey(Set, null=True, blank=True, on_delete=models.SET_NULL)
|
||||
extras = models.JSONField(default=dict)
|
||||
docker_instances = models.JSONField(null=True, blank=True, default=list)
|
||||
|
||||
_solutionfiles = None
|
||||
|
||||
|
@ -16,6 +16,7 @@ class Task(models.Model):
|
||||
output_format = models.TextField(default="")
|
||||
specifications = models.TextField(default="")
|
||||
time_limit = models.IntegerField(default=10000)
|
||||
memory_limit = models.IntegerField(default=524288)
|
||||
time_estimation = models.IntegerField(default=5)
|
||||
creator = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
|
||||
editors = ArrayField(models.TextField(), default=list)
|
||||
|
@ -37,7 +37,9 @@ class BaseTester:
|
||||
f"< {filename} {self.command} > output.txt",
|
||||
timeout=self.solution.task.time_limit / 1000,
|
||||
)
|
||||
if code != 0:
|
||||
if code == 1:
|
||||
raise TestException("ML")
|
||||
elif code != 0:
|
||||
raise TestException("RE")
|
||||
result = (
|
||||
open(join(self.path, "output.txt"), "r")
|
||||
@ -157,7 +159,7 @@ class BaseTester:
|
||||
fs.write(bts)
|
||||
print("Files copied")
|
||||
self._setup_networking()
|
||||
docker_command = f"docker run --network solution_network_{self.solution.id} --name solution_{self.solution.id} --volume={self.path}:/{self.working_directory} -t -d {self.solution.language.image}"
|
||||
docker_command = f"docker run --network solution_network_{self.solution.id} --name solution_{self.solution.id} --memory=\"{self.solution.task.memory_limit}k\" --volume={self.path}:/{self.working_directory} -t -d {self.solution.language.image}"
|
||||
print(docker_command)
|
||||
call(docker_command, shell=True)
|
||||
checker = self.solution.task.checkerfile
|
||||
|
@ -79,6 +79,14 @@
|
||||
<input type="text" name="time_limit" value="{{ task.time_limit }}" style="width: 100%;">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Ограничение по памяти (KB)
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="memory_limit" value="{{ task.memory_limit }}" style="width: 100%;">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
Оценка времени решения (мин)
|
||||
|
Loading…
Reference in New Issue
Block a user