Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Bugfix: Native compaction now truncates an oversized tool output before summarizing instead of crashing or silently summarizing an error when it would exceed the model's context window. (#3600)
- Bugfix: React agent compaction now works after a checkpoint resume — the restored conversation is no longer treated as an always-preserved prefix, so compaction shrinks the context again.
- Bugfix: Nested `score_reducer` and `task_source` values in serialized task args now restore as instances rather than their registered factories. (#4374)
- Bugfix: Properly resolve relative sample file paths and file URIs on windows (#4502)
- Viewer: log listing responses include the log dir's canonical URI (`log_dir_uri`) so the viewer can reliably scope its local cache to the directory.
- Inspect View: Reuse one warm async S3 client and connection pool across requests — for both log reads and directory listings — instead of creating one per operation, eliminating the per-request credential/connection cold-start (e.g. `/log-headers` ~3s -> ~0.3s, `/logs` ~1.5s -> ~0.06s).
- Model Roles: `resolve_model_roles` now copies a `Model` passed by object (e.g. via `eval(model_roles=...)`) before stamping its role, so roles supplied through the Python API — not just `--model-role` — get a distinct instance and are not misattributed. (#4464)
Expand Down
5 changes: 2 additions & 3 deletions src/inspect_ai/dataset/_sources/csv.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import csv
import os
from io import TextIOWrapper
from pathlib import Path
from typing import Any

from inspect_ai._util.asyncfiles import is_s3_filename
from inspect_ai._util.file import file
from inspect_ai._util.file import absolute_file_path, file
from inspect_ai.dataset._sources.util import resolve_sample_files

from .._dataset import (
Expand Down Expand Up @@ -83,7 +82,7 @@ def csv_dataset(
dataset = MemoryDataset(
samples=data_to_samples(valid_data, data_to_sample, auto_id),
name=name,
location=os.path.abspath(csv_file),
location=absolute_file_path(csv_file),
)

# resolve relative file paths
Expand Down
5 changes: 2 additions & 3 deletions src/inspect_ai/dataset/_sources/json.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import json
import os
from io import TextIOWrapper
from pathlib import Path
from typing import Any

import jsonlines

from inspect_ai._util.asyncfiles import is_s3_filename
from inspect_ai._util.file import file
from inspect_ai._util.file import absolute_file_path, file

from .._dataset import (
Dataset,
Expand Down Expand Up @@ -87,7 +86,7 @@ def json_dataset(
dataset_reader(f, **reader_kwargs), data_to_sample, auto_id
),
name=name,
location=os.path.abspath(json_file),
location=absolute_file_path(json_file),
)

# resolve relative file paths
Expand Down
4 changes: 2 additions & 2 deletions src/inspect_ai/dataset/_sources/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ContentImage,
ContentVideo,
)
from inspect_ai._util.file import filesystem
from inspect_ai._util.file import dirname, filesystem
from inspect_ai.model._chat_message import ChatMessage, ChatMessageUser
from inspect_ai.util._sandbox.environment import SandboxEnvironmentSpec

Expand All @@ -22,7 +22,7 @@ def resolve_sample_files(dataset: Dataset) -> None:

# filesystem and parent for resolving paths
fs = filesystem(dataset.location)
parent_dir = fs.sep.join(dataset.location.split(fs.sep)[:-1])
parent_dir = dirname(dataset.location)

# resolve file locations
def resolve_file(file: str) -> str:
Expand Down
16 changes: 16 additions & 0 deletions tests/dataset/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from test_helpers.utils import skip_if_github_action

from inspect_ai._util.content import ContentImage
from inspect_ai._util.file import exists
from inspect_ai.dataset import (
Dataset,
FieldSpec,
Expand Down Expand Up @@ -174,6 +175,21 @@ def test_dataset_image_paths() -> None:
assert image.exists()


def test_dataset_image_paths_file_uri() -> None:
# dataset locations that are filesystem URIs should keep their scheme and
# still resolve relative sample files against the dataset's parent dir
dataset = json_dataset(Path(dataset_path("images.jsonl")).resolve().as_uri())
assert dataset.location is not None
assert dataset.location.startswith("file://")
sample = dataset[0]
assert not isinstance(sample.input, str)
assert isinstance(sample.input[0], ChatMessageUser)
content = sample.input[0].content[1]
assert isinstance(content, ContentImage)
assert content.image.startswith("file://")
assert exists(content.image)


def test_dataset_auto_id() -> None:
dataset = json_dataset(dataset_path("dataset.jsonl"))
assert all(sample.id is None for sample in dataset)
Expand Down
Loading