commands.exec
Execution application for running code in Datalayer code sandboxes.
exec_callback
@app.callback()
def exec_callback(ctx: typer.Context) -> None
Execute files or notebooks on code sandboxes.
CodeSandboxExecService Objects
class CodeSandboxExecService()
Service for executing files on Datalayer code sandboxes.
__init__
def __init__(token: Optional[str] = None) -> None
Initialize the exec service.
handle_sigint
def handle_sigint(*args: Any) -> None
Handle SIGINT signal during kernel execution.
init_kernel_manager
def init_kernel_manager(sandbox_name: str) -> None
Initialize the kernel manager and connect to a code sandbox.
execute_file
def execute_file(filepath: Path,
silent: bool = True,
timeout: Optional[float] = None,
raise_exceptions: bool = False) -> dict[str, Any]
Execute a file or notebook on the connected code sandbox.
Parameters
filepath : Path Path to the file to execute. silent : bool Whether to suppress cell output. timeout : Optional[float] Execution timeout for each cell. raise_exceptions : bool Whether to stop on exceptions.
cleanup
def cleanup() -> None
Clean up resources.
main
@app.command()
def main(
filename: Optional[str] = typer.Argument(
None,
help="Path to the file or notebook to execute",
),
sandbox: Optional[str] = typer.
Option(
None,
"--sandbox",
"-s",
help=
"Name of the code sandbox to execute on (uses first available if not specified)",
),
verbose: bool = typer.Option(False,
"--verbose",
"-v",
help="Show all cell outputs"),
timeout: Optional[float] = typer.Option(
None,
"--timeout",
"-t",
help="Execution timeout for each cell in seconds",
),
raise_exceptions: bool = typer.Option(
False, "--raise", help="Stop executing if an exception occurs"),
token: Optional[str] = typer.Option(
None,
"--api-key",
help="API key (Bearer token for API requests).",
),
example_notebook: bool = typer.
Option(
False,
"--example-notebook",
help="Create a temporary example notebook, execute it, then remove it.",
),
example_py: bool = typer.
Option(
False,
"--example-py",
help=
"Create a temporary example Python file, execute it, then remove it.",
),
output_name: Optional[str] = typer.
Option(
None,
"--output-name",
help=
"Output report filename/path. Defaults to <input-name>.out.json next to the input file.",
)) -> None
Execute a Python file or Jupyter notebook on a Datalayer code sandbox.