Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ jobs:
with:
enable-cache: true
python-version: "${{ matrix.python-version }}"
# Pin uv to the version used by tox-uv in the lockfile to avoid
# lockfile serialization mismatches between uv versions.
version: "0.11.29"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't get the tests to run until I did this.


- name: Install CI dependencies
run: uv sync --group ci
Expand Down
10 changes: 7 additions & 3 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ def dummy_callback(_request, *_args, **_kwargs):
LMS_ROOT_URL = "http://localhost:8000"

# Code jail REST service
ENABLE_CODEJAIL_REST_SERVICE = False
ENABLE_CODEJAIL_REST_SERVICE = True

# Set the python package.module.function that is reponsible of
# calling the remote service in charge of jailed code execution
CODE_JAIL_REST_SERVICE_REMOTE_EXEC = "xblocks_contrib.problem.capa.safe_exec.remote_exec.send_safe_exec_request_v0"
# calling the remote service in charge of jailed code execution.
# For tests, we use a mock service that runs CodeJail's unsafe executor with out
# sandboxing.
CODE_JAIL_REST_SERVICE_REMOTE_EXEC = (
"xblocks_contrib.problem.capa.safe_exec.tests.test_utils.send_safe_exec_request_locally"
)

# Set the codejail remote service host
CODE_JAIL_REST_SERVICE_HOST = "http://127.0.0.1:8550"
Expand Down
22 changes: 0 additions & 22 deletions xblocks_contrib/problem/capa/safe_exec/remote_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,12 @@
# .. toggle_creation_date: 2021-08-19
ENABLE_CODEJAIL_REST_SERVICE = SettingToggle("ENABLE_CODEJAIL_REST_SERVICE", default=False, module_name=__name__)

# .. toggle_name: ENABLE_CODEJAIL_DARKLAUNCH
# .. toggle_implementation: SettingToggle
# .. toggle_default: False
# .. toggle_description: Turn on to send requests to both the codejail service and the installed codejail library for
# testing and evaluation purposes. The results from the installed codejail library will be the ones used.
# .. toggle_warning: This toggle will only behave as expected when ENABLE_CODEJAIL_REST_SERVICE is not enabled and when
# CODE_JAIL_REST_SERVICE_REMOTE_EXEC, CODE_JAIL_REST_SERVICE_HOST, CODE_JAIL_REST_SERVICE_READ_TIMEOUT,
# and CODE_JAIL_REST_SERVICE_CONNECT_TIMEOUT are configured.
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2025-04-03
# .. toggle_target_removal_date: 2025-05-01
ENABLE_CODEJAIL_DARKLAUNCH = SettingToggle("ENABLE_CODEJAIL_DARKLAUNCH", default=False, module_name=__name__)


def is_codejail_rest_service_enabled():
"""Return whether the codejail REST service is enabled."""
return ENABLE_CODEJAIL_REST_SERVICE.is_enabled()


def is_codejail_in_darklaunch():
"""
Returns whether codejail dark launch is enabled.

Codejail dark launch can only be enabled if ENABLE_CODEJAIL_REST_SERVICE is not enabled.
"""
return not is_codejail_rest_service_enabled() and ENABLE_CODEJAIL_DARKLAUNCH.is_enabled()


def get_remote_exec(*args, **kwargs):
"""Get remote exec function based on setting and executes it."""
remote_exec_function_name = settings.CODE_JAIL_REST_SERVICE_REMOTE_EXEC
Expand Down
Loading