Package containing various utility functions used for remote-exercise-framework submission procedure
Check requirements.txt
git clone [email protected]:remote-exercise-framework/ref-utils.git
cd ref-utils
pip install -f requirements.txt
Produce pip-installable file with
python3 setup.py bdist_wheel
@environment_test(task_name="default")- register a function as an environment check (must returnbool)@submission_test(task_name="default")- register a function as a submission test (must returnboolorTestResult)@extended_submission_test(task_name="default")- register an extended submission testTestResult(success: bool, score: Optional[float])- return type for scored submission testsrun_tests()- execute all registered tests (deprecated; called automatically bytask.py)test_result_will_be_submitted()- check whether the current run is a final submission or just a checkget_instance_info()- retrieve instance metadata (InstanceInfodataclass)get_user_environment()- retrieve environment variables set by the user
drop_privilegesanddrop_privileges_to(uid, gid)decorators allow executing a function in unprivileged context
Return False instead of raising AssertionError on failure
assert_is_file- check whether given path points to a fileassert_is_exec- check whether given path points to an executable fileassert_is_dir- check whether given path points to a directory
Colored output
print_ok- prints text greenprint_warn- prints text yellowprint_err- prints text red
Run (shell) command after dropping privileges. Wraps subprocess.run
run- subprocess.runrun_shell- subprocess.run withshell=Truerun_capture_output- subprocess.run capturing stdout/stderrrun_with_payload- run a binary with specific stdin payload
Various checks to run on instances
run_pylint- pylint linter (disable withNO_LINT="1")run_mypy- mypy type checker (disable withNO_LINT="1")contains_flag- execute given python script and check whether output contains a given flag value