Skip to content

Commit 4570973

Browse files
committed
feat!: Support for verawood
1 parent 3373eb5 commit 4570973

14 files changed

Lines changed: 265 additions & 452 deletions

File tree

pyproject.toml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "tutor-contrib-codejail"
3-
version = "21.0.1"
3+
version = "22.0.0"
44
description = "Codejail plugin for Tutor"
55
readme = "README.md"
66
license-files = ["LICENSE"]
@@ -9,7 +9,7 @@ authors = [
99
]
1010
requires-python = ">=3.10"
1111
dependencies = [
12-
"tutor~=21.0"
12+
"tutor~=22.0"
1313
]
1414
classifiers = [
1515
"Development Status :: 3 - Alpha",
@@ -34,6 +34,17 @@ codejail = "tutorcodejail.plugin"
3434
module-root = "."
3535
module-name = "tutorcodejail"
3636

37+
[tool.uv.sources]
38+
tutor = {
39+
git = "https://github.com/overhangio/tutor",
40+
rev = "59264ca9f9c6a8e67622ae72080684ffc6ec7e2a", # Verawood
41+
}
42+
tutor-mfe = {
43+
git = "https://github.com/overhangio/tutor-mfe",
44+
rev = "72370dd4ace29e1a7a646da57eabc8e098ecee67", # Verawood
45+
}
46+
47+
3748
[build-system]
3849
requires = ["uv_build>=0.9.5,<0.12.0"]
3950
build-backend = "uv_build"
@@ -44,6 +55,7 @@ dev = [
4455
"ruff",
4556
"scriv>=1.8.0",
4657
"ty>=0.0.34",
58+
"tutor-mfe",
4759
]
4860

4961
[tool.ruff]

tutorcodejail/patches/cms-env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ENABLE_CODEJAIL_REST_SERVICE: true
2-
CODE_JAIL_REST_SERVICE_HOST: "http://{{ CODEJAIL_HOST }}:8550"
2+
CODE_JAIL_REST_SERVICE_HOST: "http://codejail:8000"
33
CODE_JAIL_REST_SERVICE_CONNECT_TIMEOUT: 0.5
44
CODE_JAIL_REST_SERVICE_READ_TIMEOUT: 3.5

tutorcodejail/patches/k8s-deployments

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
---
2-
{% if CODEJAIL_USE_SERVICE_V2 %}
32
apiVersion: apps/v1
43
kind: Deployment
54
metadata:
6-
name: codejailservice
5+
name: codejail
76
labels:
8-
app.kubernetes.io/name: codejailservice
7+
app.kubernetes.io/name: codejail
98
spec:
109
selector:
1110
matchLabels:
12-
app.kubernetes.io/name: codejailservice
11+
app.kubernetes.io/name: codejail
1312
template:
1413
metadata:
1514
labels:
16-
app.kubernetes.io/name: codejailservice
15+
app.kubernetes.io/name: codejail
1716
spec:
1817
securityContext:
1918
appArmorProfile:
2019
type: Localhost
2120
localhostProfile: openedx_codejail_service
2221
containers:
23-
- name: codejailservice
24-
image: {{ CODEJAIL_DOCKER_IMAGE_V2 }}
22+
- name: codejail
23+
image: {{ CODEJAIL_DOCKER_IMAGE }}
2524
ports:
2625
- containerPort: 8550
2726
env:
@@ -35,45 +34,6 @@ spec:
3534
- name: settings-codejail
3635
configMap:
3736
name: settings-codejail
38-
{% else %}
39-
apiVersion: apps/v1
40-
kind: Deployment
41-
metadata:
42-
name: codejailservice
43-
labels:
44-
app.kubernetes.io/name: codejailservice
45-
spec:
46-
selector:
47-
matchLabels:
48-
app.kubernetes.io/name: codejailservice
49-
template:
50-
metadata:
51-
labels:
52-
app.kubernetes.io/name: codejailservice
53-
spec:
54-
{% if CODEJAIL_ENFORCE_APPARMOR %}
55-
securityContext:
56-
appArmorProfile:
57-
type: Localhost
58-
localhostProfile: docker-edx-sandbox
59-
{% endif %}
60-
containers:
61-
- name: codejailservice
62-
image: {{ CODEJAIL_DOCKER_IMAGE }}
63-
ports:
64-
- containerPort: 8550
65-
env:
66-
- name: FLASK_APP_SETTINGS
67-
value: codejailservice.tutor.ProductionConfig
68-
volumeMounts:
69-
- mountPath: /openedx/codejailservice/codejailservice/tutor.py
70-
name: settings-codejail
71-
subPath: tutor.py
72-
volumes:
73-
- name: settings-codejail
74-
configMap:
75-
name: settings-codejail
76-
{% endif %}
7737
{% if CODEJAIL_ENABLE_K8S_DAEMONSET %}
7838
---
7939
apiVersion: apps/v1

tutorcodejail/patches/k8s-services

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
apiVersion: v1
33
kind: Service
44
metadata:
5-
name: codejailservice
5+
name: codejail
66
labels:
7-
app.kubernetes.io/name: codejailservice
7+
app.kubernetes.io/name: codejail
88
spec:
99
type: ClusterIP
1010
ports:
11-
- port: 8550
11+
- port: 8000
1212
protocol: TCP
13+
name: http
1314
selector:
14-
app.kubernetes.io/name: codejailservice
15+
app.kubernetes.io/name: codejail
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
- name: codejail-profile
22
files:
3-
- plugins/codejail/apps/profiles/docker-edx-sandbox.profile
43
- plugins/codejail/apps/profiles/openedx-codejail-service.profile
54
options:
65
labels:
76
app.kubernetes.io/name: codejail-aa-loader
8-
- name: settings-codejail
7+
- name: codejail-settings
98
files:
10-
{% if CODEJAIL_USE_SERVICE_V2 %}
11-
- plugins/codejail/apps/codejail-service-v2/tutor.py
12-
{% else %}
139
- plugins/codejail/apps/codejail/tutor.py
14-
{% endif %}
1510
options:
1611
labels:
17-
app.kubernetes.io/name: codejailservice
12+
app.kubernetes.io/name: codejail

tutorcodejail/patches/lms-env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
ENABLE_CODEJAIL_REST_SERVICE: true
2-
CODE_JAIL_REST_SERVICE_HOST: "http://{{ CODEJAIL_HOST }}:8550"
2+
CODE_JAIL_REST_SERVICE_HOST: "http://codejail:8000"
33
CODE_JAIL_REST_SERVICE_CONNECT_TIMEOUT: 0.5
44
CODE_JAIL_REST_SERVICE_READ_TIMEOUT: 3.5
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +0,0 @@
1-
codejailservice:
2-
command: flask run --host 0.0.0.0 --port 8550
3-
environment:
4-
FLASK_ENV: development
5-
FLASK_APP_SETTINGS: codejailservice.tutor.DevelopmentConfig
6-
ports:
7-
- "8550:8550"
8-
restart: unless-stopped

tutorcodejail/patches/local-docker-compose-services

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,16 @@
11
#############Codejail service
2-
{% if CODEJAIL_USE_SERVICE_V2 %}
3-
codejailservice:
4-
image: {{ CODEJAIL_DOCKER_IMAGE_V2 }}
5-
ports:
6-
- 8550:8550
2+
codejail:
3+
image: {{ CODEJAIL_DOCKER_IMAGE }}
74
environment:
85
DJANGO_SETTINGS_MODULE: codejail_service.settings.tutor
96
security_opt:
107
- apparmor:openedx_codejail_service
118
volumes:
12-
- ../plugins/codejail/apps/codejail-service-v2/tutor.py:/app/codejail_service/settings/tutor.py:ro
13-
restart: unless-stopped
14-
depends_on:
15-
codejail-apparmor-loader:
16-
condition: service_completed_successfully
17-
{% else %}
18-
codejailservice:
19-
image: {{ CODEJAIL_DOCKER_IMAGE }}
20-
environment:
21-
FLASK_APP_SETTINGS: codejailservice.tutor.ProductionConfig
22-
{% if CODEJAIL_ENFORCE_APPARMOR %}
23-
security_opt:
24-
- apparmor:docker-edx-sandbox
25-
{% endif %}
26-
volumes:
27-
- ../plugins/codejail/apps/codejail/tutor.py:/openedx/codejailservice/codejailservice/tutor.py:ro
9+
- ../plugins/codejail/apps/codejail/tutor.py:/app/codejail_service/settings/tutor.py:ro
2810
restart: unless-stopped
2911
depends_on:
3012
codejail-apparmor-loader:
3113
condition: service_completed_successfully
32-
{% endif %}
3314

3415
codejail-apparmor-loader:
3516
image: {{ CODEJAIL_APPARMOR_DOCKER_IMAGE }}

tutorcodejail/plugin.py

Lines changed: 34 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import importlib_resources
1010
from tutor import hooks
11-
from tutor.types import Config
1211

1312
from .__about__ import __version__
1413

@@ -21,18 +20,13 @@
2120
"defaults": {
2221
"APPARMOR_DOCKER_IMAGE": "docker.io/ednxops/codejail_apparmor_loader:apparmor-4",
2322
"DOCKER_IMAGE": f"docker.io/ednxops/codejailservice:{__version__}",
24-
"DOCKER_IMAGE_V2": "{{ CODEJAIL_DOCKER_IMAGE }}-v2",
2523
"ENABLE_K8S_DAEMONSET": False,
2624
"ENFORCE_APPARMOR": True,
2725
"EXTRA_PIP_REQUIREMENTS": [],
28-
"HOST": "codejailservice",
29-
"SANDBOX_PYTHON_VERSION": "3.11.14",
30-
"SERVICE_REPOSITORY": "https://github.com/edunext/codejailservice.git",
31-
"SERVICE_V2_REPOSITORY": "https://github.com/openedx/codejail-service.git",
32-
"SERVICE_V2_VERSION": "{{ OPENEDX_COMMON_VERSION }}",
26+
"SANDBOX_PYTHON_VERSION": "3.12",
27+
"SERVICE_REPOSITORY": "https://github.com/openedx/codejail-service.git",
3328
"SERVICE_VERSION": "{{ OPENEDX_COMMON_VERSION }}",
3429
"SKIP_INIT": False,
35-
"USE_SERVICE_V2": False,
3630
"VERSION": __version__,
3731
},
3832
"overrides": {},
@@ -71,60 +65,47 @@ def get_apparmor_abi():
7165
]
7266
)
7367

68+
hooks.Filters.IMAGES_BUILD.add_item(
69+
(
70+
"codejail",
71+
("plugins", "codejail", "build", "codejail"),
72+
"{{ CODEJAIL_DOCKER_IMAGE }}",
73+
(),
74+
),
75+
)
76+
hooks.Filters.IMAGES_PULL.add_item(
77+
(
78+
"codejail",
79+
"{{ CODEJAIL_DOCKER_IMAGE }}",
80+
)
81+
)
82+
hooks.Filters.IMAGES_PUSH.add_item(
83+
(
84+
"codejail",
85+
"{{ CODEJAIL_DOCKER_IMAGE }}",
86+
)
87+
)
7488

75-
@hooks.Filters.IMAGES_BUILD.add()
76-
def _build_codejail_images(
77-
images: list[tuple[str, str | tuple[str, ...], str, tuple[str, ...]]],
78-
tutor_config: Config,
79-
):
80-
"""Choose the appropiate build context when using CODEJAIL_USE_SERVICE_V2."""
81-
# TODO: Remove after the Verawood update
82-
if tutor_config.get("CODEJAIL_USE_SERVICE_V2"):
83-
codejail_img = (
84-
"codejail",
85-
"plugins/codejail/build/codejail-service",
86-
"{{ CODEJAIL_DOCKER_IMAGE_V2 }}",
87-
(),
88-
)
89-
else:
90-
codejail_img = (
91-
"codejail",
92-
"plugins/codejail/build/codejail",
93-
"{{ CODEJAIL_DOCKER_IMAGE }}",
94-
(),
95-
)
96-
apparmor_img = (
89+
hooks.Filters.IMAGES_BUILD.add_item(
90+
(
9791
"codejail_apparmor",
9892
("plugins", "codejail", "build", "codejail_apparmor"),
9993
"{{CODEJAIL_APPARMOR_DOCKER_IMAGE}}",
10094
(),
95+
),
96+
)
97+
hooks.Filters.IMAGES_PULL.add_item(
98+
(
99+
"codejail_apparmor",
100+
"{{CODEJAIL_APPARMOR_DOCKER_IMAGE}}",
101101
)
102-
103-
return images + [codejail_img, apparmor_img]
104-
105-
106-
@hooks.Filters.IMAGES_PUSH.add()
107-
def _push_codejail_images(
108-
images: list[tuple[str, str]],
109-
tutor_config: Config,
110-
):
111-
"""Choose the appropiate image tag when using CODEJAIL_USE_SERVICE_V2."""
112-
# TODO: Remove after the Verawood update
113-
if tutor_config.get("CODEJAIL_USE_SERVICE_V2"):
114-
codejail_img = (
115-
"codejail",
116-
"{{ CODEJAIL_DOCKER_IMAGE_V2 }}",
117-
)
118-
else:
119-
codejail_img = (
120-
"codejail",
121-
"{{ CODEJAIL_DOCKER_IMAGE }}",
122-
)
123-
apparmor_img = (
102+
)
103+
hooks.Filters.IMAGES_PUSH.add_item(
104+
(
124105
"codejail_apparmor",
125106
"{{CODEJAIL_APPARMOR_DOCKER_IMAGE}}",
126107
)
127-
return images + [codejail_img, apparmor_img]
108+
)
128109

129110

130111
# Boilerplate code

tutorcodejail/templates/codejail/apps/codejail-service-v2/tutor.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)