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
2 changes: 1 addition & 1 deletion e2e/test_evaluator_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def test_fileset_fragment_and_glob_datasets(evaluator_sdk: NeMoPlatform) -> None

cases = {
"specific file": (f"{workspace}/{fileset_name}#part-a.json", [1.0, 0.0]),
"glob": (f"{workspace}/{fileset_name}#part-*.json", [1.0, 1.0, 0.0]),
"glob": (f"{workspace}/{fileset_name}#part-*.json", [1.0, 0.0, 1.0]),
}
for label, (reference, expected_scores) in cases.items():
job = evaluator_sdk.evaluator.submit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def discover_files(base_path: Path, pattern: str | None) -> list[Path]:
pattern: Optional explicit file name or glob pattern.

Returns:
List of discovered files.
List of discovered files, sorted by path.

Raises:
DatasetLoadError: If files cannot be found or selected paths are invalid.
Expand All @@ -172,7 +172,7 @@ def discover_files(base_path: Path, pattern: str | None) -> list[Path]:
raise DatasetLoadError(f"Dataset directory not found: {base_path}")

if pattern is None:
files = [f for f in base_path.rglob("*") if f.is_file()]
files = sorted(f for f in base_path.rglob("*") if f.is_file())
if not files:
raise DatasetLoadError(f"No files found in {base_path}")
return files
Expand All @@ -184,7 +184,7 @@ def discover_files(base_path: Path, pattern: str | None) -> list[Path]:
return [file_path]

if is_glob_pattern(pattern):
files = list(base_path.glob(pattern))
files = sorted(base_path.glob(pattern))
if not files:
raise DatasetLoadError(f"No files found matching pattern '{pattern}' in {base_path}")
return [f for f in files if f.is_file()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,26 @@ def test_glob_pattern_discovers_files(self, tmp_path: Path):

assert sorted(discover_files(tmp_path / "splits", "**/*.jsonl")) == sorted([train_path, validation_path])

def test_glob_pattern_returns_files_in_sorted_order(self, tmp_path: Path):
for name in ("part-c.json", "part-a.json", "part-b.json"):
(tmp_path / name).touch()

assert discover_files(tmp_path, "part-*.json") == [
tmp_path / "part-a.json",
tmp_path / "part-b.json",
tmp_path / "part-c.json",
]

def test_directory_without_a_pattern_returns_files_in_sorted_order(self, tmp_path: Path):
for name in ("c.jsonl", "a.jsonl", "b.jsonl"):
(tmp_path / name).touch()

assert discover_files(tmp_path, None) == [
tmp_path / "a.jsonl",
tmp_path / "b.jsonl",
tmp_path / "c.jsonl",
]


class TestIsCompletionsEndpoint:
@pytest.mark.parametrize(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading