Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate old sandbox spec format when reading logs #1448

Merged
merged 4 commits into from
Mar 7, 2025
Merged
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
11 changes: 8 additions & 3 deletions src/inspect_ai/_view/www/dist/assets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63351,9 +63351,14 @@ ${events}
config2["model_base_url"] = evaluation.model_base_url;
}
if (evaluation == null ? void 0 : evaluation.sandbox) {
config2["sandbox"] = evaluation.sandbox[0];
if (evaluation.sandbox[1]) {
config2["sandbox_config"] = evaluation.sandbox[1];
if (Array.isArray(evaluation == null ? void 0 : evaluation.sandbox)) {
config2["sandbox"] = evaluation.sandbox[0];
if (evaluation.sandbox[1]) {
config2["sandbox_config"] = evaluation.sandbox[1];
}
} else {
config2["sandbox"] = evaluation == null ? void 0 : evaluation.sandbox.type;
config2["sandbox_config"] = evaluation == null ? void 0 : evaluation.sandbox.config;
}
}
const taskColumns = [];
Expand Down
11 changes: 8 additions & 3 deletions src/inspect_ai/_view/www/src/plan/PlanDetailView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ export const PlanDetailView: FC<PlanDetailViewProps> = ({
}

if (evaluation?.sandbox) {
config["sandbox"] = evaluation.sandbox[0];
if (evaluation.sandbox[1]) {
config["sandbox_config"] = evaluation.sandbox[1];
if (Array.isArray(evaluation?.sandbox)) {
config["sandbox"] = evaluation.sandbox[0];
if (evaluation.sandbox[1]) {
config["sandbox_config"] = evaluation.sandbox[1];
}
} else {
config["sandbox"] = evaluation?.sandbox.type;
config["sandbox_config"] = evaluation?.sandbox.config;
}
}

Expand Down
19 changes: 18 additions & 1 deletion src/inspect_ai/log/_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def migrate_deprecated(
# warning will handle this)
del values["transcript"]

return values
return migrate_sandbox_spec(values)

# allow field model_usage
model_config = ConfigDict(protected_namespaces=())
Expand Down Expand Up @@ -607,6 +607,23 @@ class EvalSpec(BaseModel):
# allow field model_args
model_config = ConfigDict(protected_namespaces=())

@model_validator(mode="before")
@classmethod
def read_sandbox_spec(
cls: Type["EvalSpec"], values: dict[str, Any]
) -> dict[str, Any]:
return migrate_sandbox_spec(values)


def migrate_sandbox_spec(values: dict[str, Any]) -> dict[str, Any]:
if "sandbox" in values:
sandbox = values.get("sandbox")
if isinstance(sandbox, list):
values["sandbox"] = SandboxEnvironmentSpec(
type=sandbox[0], config=sandbox[1]
)
return values


def eval_error(
exception: BaseException,
Expand Down