Skip to content

Environment schema#

Environment#

CompilationConfig #

Bases: BaseModel

Parameters:

Name Type Description Default
commands List[str] | None

Commands to compile the program.

[]
sandbox EnvironmentSandbox | None

Sandbox configuration to use when compiling for this language.

None
Source code in rbx/box/environment.py
class CompilationConfig(BaseModel):
    commands: Optional[List[str]] = Field(
        default=[],
        description="""Commands to compile the program.""",
    )

    sandbox: Optional[EnvironmentSandbox] = Field(
        default=None,
        description="""Sandbox configuration to use when compiling for this language.""",
    )

Environment #

Bases: BaseModel

Parameters:

Name Type Description Default
defaultFileMapping FileMapping | None

Default mapping for files within the sandbox. Fields in the mapping can be individually overridden in the language configuration.

None
defaultCompilation CompilationConfig | None

Default compilation configuration to use when compiling programs. Fields in the compilation config can be individually overridden in the language configuration.

None
defaultExecution ExecutionConfig | None

Default execution configuration to use when running programs. Fields in the execution config can be individually overridden in the language configuration.

None
languages List[EnvironmentLanguage]

Configuration for each language supported in this environment.

[]
sandbox str

Identifier of the sandbox used by this environment (e.g. "stupid")

'stupid'
timing TimingConfig

Timing configuration for the environment.

<dynamic>
extensions Extensions | None

Extensions to be added to the environment.

None
Source code in rbx/box/environment.py
class Environment(BaseModel):
    model_config = ConfigDict(extra='forbid')

    defaultFileMapping: Optional[FileMapping] = Field(
        default=None,
        description="""Default mapping for files within the sandbox. Fields in the mapping can be
individually overridden in the language configuration.""",
    )

    defaultCompilation: Optional[CompilationConfig] = Field(
        default=None,
        description="""Default compilation configuration to use when compiling programs. Fields in
the compilation config can be individually overridden in the language configuration.""",
    )

    defaultExecution: Optional[ExecutionConfig] = Field(
        default=None,
        description="""Default execution configuration to use when running programs. Fields in the
execution config can be individually overridden in the language configuration.""",
    )

    languages: List[EnvironmentLanguage] = Field(
        default=[],
        description="""Configuration for each language supported in this environment.""",
    )

    sandbox: str = Field(
        default='stupid',
        description="""Identifier of the sandbox used by this environment (e.g. "stupid")""",
    )

    timing: TimingConfig = Field(
        default_factory=TimingConfig,
        description="""Timing configuration for the environment.""",
    )

    extensions: Optional[Extensions] = Field(
        default=None,
        description="""Extensions to be added to the environment.""",
    )

EnvironmentLanguage #

Bases: BaseModel

Parameters:

Name Type Description Default
name str

Identifier of this language within this environment.

required
readableName str | None

Readable name for this language.

None
extension str

File extension supported by this language. If there's only one language that supports a certain file extension in the environment, the tool will automatically identify the language based on such extension.

required
compilation CompilationConfig | None

Compilation config to use when compiling programs for this language.

None
execution ExecutionConfig

Execution config to use when running programs for this language.

required
fileMapping FileMapping | None

Mapping for files within the sandbox. If not specified, the default mapping for the environment will be used.

None
extensions LanguageExtensions | None

Extensions to apply for this language.

None
Source code in rbx/box/environment.py
class EnvironmentLanguage(BaseModel):
    model_config = ConfigDict(extra='forbid')

    name: str = Field(
        description="""Identifier of this language within this environment."""
    )

    readableName: Optional[str] = Field(
        default=None,
        description="""Readable name for this language.""",
    )

    extension: str = Field(
        description="""File extension supported by this language. If there's only one language
that supports a certain file extension in the environment, the tool
will automatically identify the language based on such extension."""
    )

    compilation: Optional[CompilationConfig] = Field(
        default=None,
        description="""Compilation config to use when compiling programs for this language.""",
    )

    execution: ExecutionConfig = Field(
        description="""Execution config to use when running programs for this language."""
    )

    fileMapping: Optional[FileMapping] = Field(
        default=None,
        description="""Mapping for files within the sandbox. If not specified, the default mapping
for the environment will be used.""",
    )

    extensions: Optional[LanguageExtensions] = Field(
        default=None,
        description="""Extensions to apply for this language.""",
    )

    def get_extension(self, name: str, _: Type[T]) -> Optional[T]:
        if self.extensions is None:
            return None
        if not hasattr(self.extensions, name):
            return None
        return getattr(self.extensions, name)

    def get_extension_or_default(self, name: str, cls: Type[T]) -> T:
        return self.get_extension(name, cls) or cls()

EnvironmentSandbox #

Bases: BaseModel

Parameters:

Name Type Description Default
maxProcesses int | None

Max. number of process to allow to run concurrently for the program.

1
timeLimit int | None

Time limit in milliseconds to allow the program to run.

None
wallTimeLimit int | None

Wall time limit in milliseconds to allow the program to run.

None
memoryLimit int | None

Memory limit in MiB.

None
fileSizeLimit int | None

File size limit in KiB

None
stackLimit int | None

Stack limit in MiB.

None
preserveEnv bool | None

Whether to preserve env. variables coming from the host.

False
mirrorDirs List[str] | None

Directories in the host that should be read-only exposed to the sandbox.

[]
Source code in rbx/box/environment.py
class EnvironmentSandbox(BaseModel):
    model_config = ConfigDict(extra='forbid')

    maxProcesses: Optional[int] = Field(
        default=1,
        description="""Max. number of process to allow to run concurrently for the program.""",
    )

    timeLimit: Optional[int] = Field(
        default=None,
        description="""Time limit in milliseconds to allow the program to run.""",
    )

    wallTimeLimit: Optional[int] = Field(
        default=None,
        description="""Wall time limit in milliseconds to allow the program to run.""",
    )

    memoryLimit: Optional[int] = Field(
        default=None,
        description="""Memory limit in MiB.""",
    )

    fileSizeLimit: Optional[int] = Field(
        default=None,
        description="""File size limit in KiB""",
    )

    stackLimit: Optional[int] = Field(
        default=None,
        description="""Stack limit in MiB.""",
    )

    preserveEnv: Optional[bool] = Field(
        default=False,
        description="""Whether to preserve env. variables coming from the host.""",
    )

    mirrorDirs: Optional[List[str]] = Field(
        default=[],
        description="""Directories in the host that should be read-only exposed to the sandbox.""",
    )

ExecutionConfig #

Bases: BaseModel

Parameters:

Name Type Description Default
command str | None

Command to run the program.

None
sandbox EnvironmentSandbox | None

Sandbox configuration to use when executing for this language.

None
problemLimits Limits

Original limits of the problem.

<dynamic>
Source code in rbx/box/environment.py
class ExecutionConfig(BaseModel):
    model_config = ConfigDict(extra='forbid')

    command: Optional[str] = Field(
        default=None,
        description="""Command to run the program.""",
    )

    sandbox: Optional[EnvironmentSandbox] = Field(
        default=None,
        description="""Sandbox configuration to use when executing for this language.""",
    )

    problemLimits: Limits = Field(
        default_factory=Limits,
        description="""Original limits of the problem.""",
    )

FileMapping #

Bases: BaseModel

Parameters:

Name Type Description Default
input str

Path where to copy the stdin file to before running the program, relative to the sandbox root.

'stdin'
output str

Path where to output the stdout file after running the program, relative to the sandbox root.

'stdout'
error str

Path where to output the stderr file after running the program, relative to the sandbox root.

'stderr'
capture str

Path where to output the capture file after running the program, relative to the sandbox root.

'capture'
compilable str

Path where to copy the compilable file to before compiling the program, relative to the sandbox root.

'compilable'
executable str

Path to where to output the executable file after compiling the program, relative to the sandbox root.

'executable'
Source code in rbx/box/environment.py
class FileMapping(BaseModel):
    model_config = ConfigDict(extra='forbid')

    input: str = Field(
        default='stdin',
        description="""Path where to copy the stdin file to before running the program,
relative to the sandbox root.""",
    )

    output: str = Field(
        default='stdout',
        description="""Path where to output the stdout file after running the program,
relative to the sandbox root.""",
    )

    error: str = Field(
        default='stderr',
        description="""Path where to output the stderr file after running the program,
relative to the sandbox root.""",
    )

    capture: str = Field(
        default='capture',
        description="""Path where to output the capture file after running the program,
relative to the sandbox root.""",
    )

    compilable: str = Field(
        default='compilable',
        description="""Path where to copy the compilable file to before compiling the program,
relative to the sandbox root.""",
    )

    executable: str = Field(
        default='executable',
        description="""Path to where to output the executable file after compiling the program,
relative to the sandbox root.""",
    )

TimingConfig #

Bases: BaseModel

Parameters:

Name Type Description Default
formula str

Formula to use to calculate the time limit for the environment.

'step_up(max(fastest * 3, slowest * 1.5), 100)'
Source code in rbx/box/environment.py
class TimingConfig(BaseModel):
    model_config = ConfigDict(extra='forbid')

    formula: str = Field(
        default='step_up(max(fastest * 3, slowest * 1.5), 100)',
        description="""Formula to use to calculate the time limit for the environment.""",
    )

Extensions#

Extensions #

Bases: BaseModel

Parameters:

Name Type Description Default
boca BocaExtension | None

Environment-level extensions for BOCA packaging.

None
Source code in rbx/box/extensions.py
class Extensions(BaseModel):
    boca: Optional[BocaExtension] = Field(
        default=None, description='Environment-level extensions for BOCA packaging.'
    )

LanguageExtensions #

Bases: BaseModel

Parameters:

Name Type Description Default
boca BocaLanguageExtension | None

Language-level extensions for BOCA packaging.

None
Source code in rbx/box/extensions.py
class LanguageExtensions(BaseModel):
    boca: Optional[BocaLanguageExtension] = Field(
        default=None, description='Language-level extensions for BOCA packaging.'
    )

BOCA#

BocaExtension #

Bases: BaseModel

Parameters:

Name Type Description Default
languages List[Literal[str, str, str, str, str, str, str]]
['c', 'cpp', 'cc', 'kt', 'java', 'py2', 'py3']
flags Dict[Literal[str, str, str, str, str, str, str], str]
{}
maximumTimeError float
0.2
preferContestLetter bool
False
Source code in rbx/box/packaging/boca/extension.py
class BocaExtension(BaseModel):
    languages: typing.List[BocaLanguage] = list(typing.get_args(BocaLanguage))
    flags: typing.Dict[BocaLanguage, str] = {}
    maximumTimeError: float = _MAX_REP_ERROR
    preferContestLetter: bool = False

    def flags_with_defaults(self) -> typing.Dict[BocaLanguage, str]:
        res: typing.Dict[BocaLanguage, str] = {
            'c': '-std=gnu11 -O2 -lm -static',
            'cpp': '-O2 -lm -static',
            'cc': '-std=c++20 -O2 -lm -static',
        }
        res.update(self.flags)
        return res

BocaLanguageExtension #

Bases: BaseModel

Parameters:

Name Type Description Default
bocaLanguage str | None
None
Source code in rbx/box/packaging/boca/extension.py
class BocaLanguageExtension(BaseModel):
    # BocaLanguage this rbx language matches with.
    bocaLanguage: typing.Optional[str] = None