Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
16 changes: 6 additions & 10 deletions test/api/test_dataset_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
@pytest.fixture()
def tmp_dataset_dir(tmp_path: Path) -> Path:
# Create a temporary dataset directory with various files
(tmp_path / "a.jsonl").write_text("{\"text\": \"a\"}\n")
(tmp_path / "a.jsonl").write_text('{"text": "a"}\n')
(tmp_path / "b.txt").write_text("hello\n")
(tmp_path / "index.json").write_text("{\"index\": true}\n")
(tmp_path / "index.json").write_text('{"index": true}\n')
(tmp_path / ".DS_Store").write_text("ignored")
(tmp_path / "subdir").mkdir()
(tmp_path / "subdir" / "nested.jsonl").write_text("{\"text\": \"nested\"}\n")
(tmp_path / "subdir" / "nested.jsonl").write_text('{"text": "nested"}\n')
return tmp_path


Expand Down Expand Up @@ -48,7 +48,7 @@ def test_load_local_dataset_uses_explicit_data_files(tmp_path: Path, monkeypatch

# Explicit files provided (note: function should not re-filter these)
(tmp_path / "keep.me").write_text("1\n")
(tmp_path / "index.json").write_text("{\"index\": true}\n")
(tmp_path / "index.json").write_text('{"index": true}\n')

captured = {}

Expand All @@ -60,9 +60,7 @@ def fake_load_dataset(path=None, data_files=None, streaming=False):

monkeypatch.setattr(dataset_service, "load_dataset", fake_load_dataset)

result = dataset_service.load_local_dataset(
str(tmp_path), data_files=["keep.me", "index.json"], streaming=True
)
result = dataset_service.load_local_dataset(str(tmp_path), data_files=["keep.me", "index.json"], streaming=True)

assert result == {"ok": True}
assert captured["path"] == str(tmp_path)
Expand All @@ -78,7 +76,7 @@ def test_load_local_dataset_fallback_when_no_valid_files(tmp_path: Path, monkeyp
from transformerlab.services import dataset_service

# Only metadata/hidden files present
(tmp_path / "index.json").write_text("{\"index\": true}\n")
(tmp_path / "index.json").write_text('{"index": true}\n')
(tmp_path / ".hidden").write_text("ignored\n")

captured = {}
Expand All @@ -98,5 +96,3 @@ def fake_load_dataset(path=None, data_files=None, streaming=False):
# When no valid files, function should call underlying loader without data_files
assert captured["data_files"] in (None, [])
assert captured["streaming"] is False


3 changes: 3 additions & 0 deletions transformerlab/models/ollamamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@


async def list_models():
if "OLLAMA_MODELS" not in os.environ:
return []

try:
ollama_model_library = ollama_models_library_dir()
except Exception as e:
Expand Down
6 changes: 1 addition & 5 deletions transformerlab/routers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,6 @@ async def get_task_file_content(task_dir: str, file_path: str):
return {"status": "error", "message": "An error occurred while getting task file content"}




@router.post("/install_from_gallery", summary="Install a task from transformerlab/galleries to local tasks-gallery")
async def install_task_from_gallery(
id: str = Form(...),
Expand Down Expand Up @@ -928,9 +926,7 @@ async def import_task_from_local_gallery(
remote_info = resp.json()
# Extract uploaded_dir path from response
uploaded_dir = (
remote_info.get("uploaded_files", {})
.get("dir_files", {})
.get("uploaded_dir")
remote_info.get("uploaded_files", {}).get("dir_files", {}).get("uploaded_dir")
)
if uploaded_dir:
try:
Expand Down
Loading