Skip to content

Commit c19a741

Browse files
authored
Better errors (#35)
* Workflow parsing validation * Fix tests * Run formatters * Better error handling * Run formatters * Docstring for documentation * Run formatters * Fix test * Bump version * Cleanup
1 parent 80c5e11 commit c19a741

40 files changed

+777
-181
lines changed

example_workflows/encdec_workflows.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
"resource_groups": [
4242
{
4343
"cpu_usage_limit": 100.0,
44-
"instruction_limit": 1000000000.0,
44+
"instruction_limit": 1000000000,
4545
"memory_limit": 2147483648,
4646
"oom_terminate_all_tasks": false,
4747
"pid_limit": 2,
4848
"swap_limit": 0,
49-
"time_limit": 1000000000.0
49+
"time_limit": 1000000000
5050
}
5151
],
5252
"processes": [
@@ -152,12 +152,12 @@
152152
"resource_groups": [
153153
{
154154
"cpu_usage_limit": 100.0,
155-
"instruction_limit": 1000000000.0,
155+
"instruction_limit": 1000000000,
156156
"memory_limit": 2147483648,
157157
"oom_terminate_all_tasks": false,
158158
"pid_limit": 2,
159159
"swap_limit": 0,
160-
"time_limit": 1000000000.0
160+
"time_limit": 1000000000
161161
}
162162
],
163163
"processes": [

example_workflows/interactive_io_workflows.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
"resource_groups": [
4848
{
4949
"cpu_usage_limit": 100.0,
50-
"instruction_limit": 1000000000.0,
50+
"instruction_limit": 1000000000,
5151
"memory_limit": 2147483648,
5252
"oom_terminate_all_tasks": false,
5353
"pid_limit": 2,
5454
"swap_limit": 0,
55-
"time_limit": 1000000000.0
55+
"time_limit": 1000000000
5656
}
5757
],
5858
"processes": [
@@ -143,12 +143,12 @@
143143
"resource_groups": [
144144
{
145145
"cpu_usage_limit": 100.0,
146-
"instruction_limit": 1000000000.0,
146+
"instruction_limit": 1000000000,
147147
"memory_limit": 2147483648,
148148
"oom_terminate_all_tasks": false,
149149
"pid_limit": 2,
150150
"swap_limit": 0,
151-
"time_limit": 1000000000.0
151+
"time_limit": 1000000000
152152
}
153153
],
154154
"processes": [

example_workflows/inwer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
"resource_groups": [
3939
{
4040
"cpu_usage_limit": 100.0,
41-
"instruction_limit": 1000000000.0,
41+
"instruction_limit": 1000000000,
4242
"memory_limit": 2147483648,
4343
"oom_terminate_all_tasks": false,
4444
"pid_limit": 2,
4545
"swap_limit": 0,
46-
"time_limit": 1000000000.0
46+
"time_limit": 1000000000
4747
}
4848
],
4949
"processes": [
@@ -102,12 +102,12 @@
102102
"resource_groups": [
103103
{
104104
"cpu_usage_limit": 100.0,
105-
"instruction_limit": 1000000000.0,
105+
"instruction_limit": 1000000000,
106106
"memory_limit": 2147483648,
107107
"oom_terminate_all_tasks": false,
108108
"pid_limit": 2,
109109
"swap_limit": 0,
110-
"time_limit": 1000000000.0
110+
"time_limit": 1000000000
111111
}
112112
],
113113
"processes": [
@@ -162,12 +162,12 @@
162162
"resource_groups": [
163163
{
164164
"cpu_usage_limit": 100.0,
165-
"instruction_limit": 1000000000.0,
165+
"instruction_limit": 1000000000,
166166
"memory_limit": 2147483648,
167167
"oom_terminate_all_tasks": false,
168168
"pid_limit": 2,
169169
"swap_limit": 0,
170-
"time_limit": 1000000000.0
170+
"time_limit": 1000000000
171171
}
172172
],
173173
"processes": [

example_workflows/outgen.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
"resource_groups": [
4242
{
4343
"cpu_usage_limit": 100.0,
44-
"instruction_limit": 1000000000.0,
44+
"instruction_limit": 1000000000,
4545
"memory_limit": 2147483648,
4646
"oom_terminate_all_tasks": false,
4747
"pid_limit": 2,
4848
"swap_limit": 0,
49-
"time_limit": 1000000000.0
49+
"time_limit": 1000000000
5050
}
5151
],
5252
"processes": [
@@ -105,12 +105,12 @@
105105
"resource_groups": [
106106
{
107107
"cpu_usage_limit": 100.0,
108-
"instruction_limit": 1000000000.0,
108+
"instruction_limit": 1000000000,
109109
"memory_limit": 2147483648,
110110
"oom_terminate_all_tasks": false,
111111
"pid_limit": 2,
112112
"swap_limit": 0,
113-
"time_limit": 1000000000.0
113+
"time_limit": 1000000000
114114
}
115115
],
116116
"processes": [
@@ -168,12 +168,12 @@
168168
"resource_groups": [
169169
{
170170
"cpu_usage_limit": 100.0,
171-
"instruction_limit": 1000000000.0,
171+
"instruction_limit": 1000000000,
172172
"memory_limit": 2147483648,
173173
"oom_terminate_all_tasks": false,
174174
"pid_limit": 2,
175175
"swap_limit": 0,
176-
"time_limit": 1000000000.0
176+
"time_limit": 1000000000
177177
}
178178
],
179179
"processes": [

example_workflows/run.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
"resource_groups": [
4242
{
4343
"cpu_usage_limit": 100.0,
44-
"instruction_limit": 1000000000.0,
44+
"instruction_limit": 1000000000,
4545
"memory_limit": 2147483648,
4646
"oom_terminate_all_tasks": false,
4747
"pid_limit": 2,
4848
"swap_limit": 0,
49-
"time_limit": 1000000000.0
49+
"time_limit": 1000000000
5050
}
5151
],
5252
"processes": [
@@ -105,12 +105,12 @@
105105
"resource_groups": [
106106
{
107107
"cpu_usage_limit": 100.0,
108-
"instruction_limit": 1000000000.0,
108+
"instruction_limit": 1000000000,
109109
"memory_limit": 2147483648,
110110
"oom_terminate_all_tasks": false,
111111
"pid_limit": 2,
112112
"swap_limit": 0,
113-
"time_limit": 1000000000.0
113+
"time_limit": 1000000000
114114
}
115115
],
116116
"processes": [
@@ -195,12 +195,12 @@
195195
"resource_groups": [
196196
{
197197
"cpu_usage_limit": 100.0,
198-
"instruction_limit": 1000000000.0,
198+
"instruction_limit": 1000000000,
199199
"memory_limit": 2147483648,
200200
"oom_terminate_all_tasks": false,
201201
"pid_limit": 2,
202202
"swap_limit": 0,
203-
"time_limit": 1000000000.0
203+
"time_limit": 1000000000
204204
}
205205
],
206206
"processes": [
@@ -285,12 +285,12 @@
285285
"resource_groups": [
286286
{
287287
"cpu_usage_limit": 100.0,
288-
"instruction_limit": 1000000000.0,
288+
"instruction_limit": 1000000000,
289289
"memory_limit": 2147483648,
290290
"oom_terminate_all_tasks": false,
291291
"pid_limit": 2,
292292
"swap_limit": 0,
293-
"time_limit": 1000000000.0
293+
"time_limit": 1000000000
294294
}
295295
],
296296
"processes": [
@@ -375,12 +375,12 @@
375375
"resource_groups": [
376376
{
377377
"cpu_usage_limit": 100.0,
378-
"instruction_limit": 1000000000.0,
378+
"instruction_limit": 1000000000,
379379
"memory_limit": 2147483648,
380380
"oom_terminate_all_tasks": false,
381381
"pid_limit": 2,
382382
"swap_limit": 0,
383-
"time_limit": 1000000000.0
383+
"time_limit": 1000000000
384384
}
385385
],
386386
"processes": [

example_workflows/string_regs.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
"resource_groups": [
4545
{
4646
"cpu_usage_limit": 100.0,
47-
"instruction_limit": 1000000000.0,
47+
"instruction_limit": 1000000000,
4848
"memory_limit": 2147483648,
4949
"oom_terminate_all_tasks": false,
5050
"pid_limit": 2,
5151
"swap_limit": 0,
52-
"time_limit": 1000000000.0
52+
"time_limit": 1000000000
5353
}
5454
],
5555
"processes": [
@@ -107,8 +107,8 @@
107107
"pipes": 0,
108108
"resource_groups": [
109109
{
110-
"cpu_usage_limit": 100,
111-
"instruction_limit": 30000000000000.0,
110+
"cpu_usage_limit": 100.0,
111+
"instruction_limit": 30000000000000,
112112
"memory_limit": 104857600,
113113
"oom_terminate_all_tasks": false,
114114
"pid_limit": 2,
@@ -198,12 +198,12 @@
198198
"resource_groups": [
199199
{
200200
"cpu_usage_limit": 100.0,
201-
"instruction_limit": 1000000000.0,
201+
"instruction_limit": 1000000000,
202202
"memory_limit": 2147483648,
203203
"oom_terminate_all_tasks": false,
204204
"pid_limit": 2,
205205
"swap_limit": 0,
206-
"time_limit": 1000000000.0
206+
"time_limit": 1000000000
207207
}
208208
],
209209
"processes": [
@@ -287,8 +287,8 @@
287287
"pipes": 0,
288288
"resource_groups": [
289289
{
290-
"cpu_usage_limit": 100,
291-
"instruction_limit": 30000000000000.0,
290+
"cpu_usage_limit": 100.0,
291+
"instruction_limit": 30000000000000,
292292
"memory_limit": 104857600,
293293
"oom_terminate_all_tasks": false,
294294
"pid_limit": 2,
@@ -378,12 +378,12 @@
378378
"resource_groups": [
379379
{
380380
"cpu_usage_limit": 100.0,
381-
"instruction_limit": 1000000000.0,
381+
"instruction_limit": 1000000000,
382382
"memory_limit": 2147483648,
383383
"oom_terminate_all_tasks": false,
384384
"pid_limit": 2,
385385
"swap_limit": 0,
386-
"time_limit": 1000000000.0
386+
"time_limit": 1000000000
387387
}
388388
],
389389
"processes": [
@@ -467,8 +467,8 @@
467467
"pipes": 0,
468468
"resource_groups": [
469469
{
470-
"cpu_usage_limit": 100,
471-
"instruction_limit": 30000000000000.0,
470+
"cpu_usage_limit": 100.0,
471+
"instruction_limit": 30000000000000,
472472
"memory_limit": 104857600,
473473
"oom_terminate_all_tasks": false,
474474
"pid_limit": 2,
@@ -558,12 +558,12 @@
558558
"resource_groups": [
559559
{
560560
"cpu_usage_limit": 100.0,
561-
"instruction_limit": 1000000000.0,
561+
"instruction_limit": 1000000000,
562562
"memory_limit": 2147483648,
563563
"oom_terminate_all_tasks": false,
564564
"pid_limit": 2,
565565
"swap_limit": 0,
566-
"time_limit": 1000000000.0
566+
"time_limit": 1000000000
567567
}
568568
],
569569
"processes": [

example_workflows/test_run.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
"resource_groups": [
4040
{
4141
"cpu_usage_limit": 100.0,
42-
"instruction_limit": 1000000000.0,
42+
"instruction_limit": 1000000000,
4343
"memory_limit": 2147483648,
4444
"oom_terminate_all_tasks": false,
4545
"pid_limit": 2,
4646
"swap_limit": 0,
47-
"time_limit": 1000000000.0
47+
"time_limit": 1000000000
4848
}
4949
],
5050
"processes": [
@@ -103,12 +103,12 @@
103103
"resource_groups": [
104104
{
105105
"cpu_usage_limit": 100.0,
106-
"instruction_limit": 1000000000.0,
106+
"instruction_limit": 1000000000,
107107
"memory_limit": 2147483648,
108108
"oom_terminate_all_tasks": false,
109109
"pid_limit": 2,
110110
"swap_limit": 0,
111-
"time_limit": 1000000000.0
111+
"time_limit": 1000000000
112112
}
113113
],
114114
"processes": [

example_workflows/user_out.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
"resource_groups": [
4040
{
4141
"cpu_usage_limit": 100.0,
42-
"instruction_limit": 1000000000.0,
42+
"instruction_limit": 1000000000,
4343
"memory_limit": 2147483648,
4444
"oom_terminate_all_tasks": false,
4545
"pid_limit": 2,
4646
"swap_limit": 0,
47-
"time_limit": 1000000000.0
47+
"time_limit": 1000000000
4848
}
4949
],
5050
"processes": [
@@ -103,12 +103,12 @@
103103
"resource_groups": [
104104
{
105105
"cpu_usage_limit": 100.0,
106-
"instruction_limit": 1000000000.0,
106+
"instruction_limit": 1000000000,
107107
"memory_limit": 2147483648,
108108
"oom_terminate_all_tasks": false,
109109
"pid_limit": 2,
110110
"swap_limit": 0,
111-
"time_limit": 1000000000.0
111+
"time_limit": 1000000000
112112
}
113113
],
114114
"processes": [

src/sio3pack/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
__version__ = "1.0.0.dev3"
1+
__version__ = "1.0.0.dev4"
22

3+
from sio3pack.exceptions import ImproperlyConfigured
34
from sio3pack.files import LocalFile
4-
from sio3pack.packages.exceptions import *
55
from sio3pack.packages.package import Package
66

77
__all__ = ["from_file", "from_db"]
@@ -39,4 +39,8 @@ def from_db(problem_id: int, configuration: SIO3PackConfig = None) -> Package:
3939
configuration.django_settings = settings
4040
return Package.from_db(problem_id, configuration)
4141
except ImportError:
42-
raise ImproperlyConfigured("sio3pack is not installed with Django support.")
42+
raise ImproperlyConfigured(
43+
"sio3pack is not installed with Django support.",
44+
"from_db function was used, but sio3pack isn't installed with Django support. "
45+
"Read the documentation to learn more.",
46+
)

0 commit comments

Comments
 (0)