Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: return a missing number in a recipe dataset page as null (#12103)
Mohammad Hijjawi72a5990558bd
diff --git a/studio/backend/core/data_recipe/jsonable.py b/studio/backend/core/data_recipe/jsonable.pyindex 989d0ce1897..819a55f73c8 100644--- a/studio/backend/core/data_recipe/jsonable.py+++ b/studio/backend/core/data_recipe/jsonable.py@@ -5,6 +5,7 @@ from __future__ import annotationsimport base64import io+import mathfrom decimal import Decimalfrom pathlib import Pathfrom typing import Any@@ -109,7 +110,13 @@ def to_jsonable(value: Any) -> Any:if isinstance(value, np.ndarray):return value.tolist()if isinstance(value, np.generic):- return value.item()+ value = value.item()+ if not isinstance(value, float):+ return value++ # pandas' missing number is NaN; Starlette refuses NaN/inf, so one blank cell 500'd the page.+ if isinstance(value, float):+ return value if math.isfinite(value) else Noneif isinstance(value, dict):return {str(k): to_jsonable(v) for k, v in value.items()}diff --git a/studio/backend/tests/test_data_recipe_dataset_download.py b/studio/backend/tests/test_data_recipe_dataset_download.pyindex b3300e8d7a6..fa6924379c1 100644--- a/studio/backend/tests/test_data_recipe_dataset_download.py+++ b/studio/backend/tests/test_data_recipe_dataset_download.py@@ -621,6 +621,55 @@ def test_to_jsonable_maps_pandas_missing_sentinels_to_none():assert to_preview_jsonable(sentinel) is None+def test_to_jsonable_maps_non_finite_numbers_to_none():+ np = pytest.importorskip("numpy")+ from core.data_recipe.jsonable import to_jsonable, to_preview_jsonable++ for value in (float("nan"), float("inf"), -math.inf, np.float64("nan"), np.float32("nan")):+ assert to_jsonable(value) is None+ assert to_preview_jsonable(value) is None+ assert to_jsonable(np.float32(0.5)) == 0.5+ assert to_jsonable(1.5) == 1.5+++def test_job_dataset_route_returns_a_missing_number_as_null(monkeypatch):+ pd = pytest.importorskip("pandas")+ from fastapi import FastAPI+ from fastapi.testclient import TestClient++ from core.data_recipe.jsonable import to_preview_jsonable_row++ jobs_route = pytest.importorskip(+ "routes.data_recipe.jobs",+ reason = "studio backend routes unavailable",+ )++ frame = pd.DataFrame({"question": ["Q1", "Q2"], "score": [1.0, None]})+ rows = to_preview_jsonable_row(frame.to_dict(orient = "records"))++ class _FakeManager:+ def get_dataset(+ self,+ job_id: str,+ *,+ limit: int,+ offset: int = 0,+ ):+ return {"dataset": rows[offset : offset + limit], "total": len(rows)}++ monkeypatch.setattr(jobs_route, "get_job_manager", lambda: _FakeManager())+ app = FastAPI()+ app.include_router(jobs_route.router)++ response = TestClient(app, raise_server_exceptions = False).get("/jobs/job-1/dataset")++ assert response.status_code == 200+ assert response.json()["dataset"] == [+ {"question": "Q1", "score": 1.0},+ {"question": "Q2", "score": None},+ ]++def test_build_dataset_download_writes_a_missing_timestamp_as_null(tmp_path: Path, monkeypatch):pytest.importorskip("pyarrow")pd = pytest.importorskip("pandas")