grader.utils package
Submodules
grader.utils.cli module
Module containing the CLI arguments parser.
grader.utils.config module
Module for loading the configuration file.
grader.utils.constants module
Module containing the constants
grader.utils.files module
Module containing the file-related functions.
- grader.utils.files.find_all_files_under_directory(directory: str, extension: str) list[str][source]
Find all files under a directory with a specific extension.
- Parameters:
directory – The directory to search in
extension – The extension of the files to search for
- Returns:
A list of all files under the directory with the specified extension
- Return type:
list[str]
- grader.utils.files.find_all_python_files(project_root_dir: str) list[str][source]
Find all python files in the project directory.
- Parameters:
project_root_dir – The path to the project directory
- Returns:
A list of all python files in the project directory
- grader.utils.files.find_all_source_files(project_root_dir: str) list[str][source]
Find all source files in the project directory.
- Parameters:
project_root_dir – The path to the project directory
- Returns:
A list of all source files in the project directory
- grader.utils.files.find_all_test_files(tests_directory: str | None = None) list[str][source]
Find all test files in the project directory.
- Parameters:
tests_directory – The tests directory, defaults to None
- Returns:
A list of all test files in the project directory. If no tests directory is found, return an empty list
grader.utils.logger module
Module containing the logger setup function and the custom VERBOSE level.
- grader.utils.logger.setup_logger(student_id: str | None = None, verbosity: int = 0, suppress_info: bool = False) Logger[source]
Setup the logger with the given verbosity level and student id
- Parameters:
student_id – The id of the student. Defaults to None.
verbosity – . Defaults to 0.
suppress_info – Suppress info and warning messages. Defaults to False.
- Returns:
The configured logger object.
- Return type:
logging.Logger
grader.utils.process module
Module containing a wrapper for launching shell commands
- grader.utils.process.extend_env_variable(variable: str, value: str) dict[str, str][source]
Extend an environment variable with a new value.
- Parameters:
variable – The name of the environment variable to extend
value – The value to append to the environment variable
- Returns:
A dictionary with the updated environment variable
- grader.utils.process.run(command: list[str], current_directory: str | None = None, env_vars: dict[str, str] | None = None) CompletedProcess[str][source]
Execute a command in the terminal. Wraps the subprocess.run function, with the check=False, capture_output=True and text=True flags.
If the command passes, log the stdout. If the command fails, log the returncode, stdout and stderr.
- Parameters:
command – The command to execute
current_directory – The directory to execute the command in
env_vars – A dictionary of environment variables to set for the subprocess
- Returns:
The output of the command (returncode, stdout, stderr)
grader.utils.virtual_environment module
Module containing the virtual environment class.
- class grader.utils.virtual_environment.VirtualEnvironment(project_path: str, keep_venv: bool = False)[source]
Bases:
objectClass that handles the creation and deletion of a virtual environment. Acts as a context manager. Everything executed within it, can assume that the venv is setup.
- is_initialized = False