Skip to content

Commit d48ea50

Browse files
authored
Merge pull request #1993 from transformerlab/fix/caching-issue-lab-finish
Fix caching issue when saving score during lab finish
2 parents 70ed442 + 197153b commit d48ea50

4 files changed

Lines changed: 25 additions & 21 deletions

File tree

api/localprovider_pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies = [
3232
"soundfile==0.13.1",
3333
"tensorboardX==2.6.2.2",
3434
"timm==1.0.15",
35-
"transformerlab==0.1.31",
35+
"transformerlab==0.1.32",
3636
"transformerlab-inference==0.2.52",
3737
"transformers==4.57.1",
3838
"wandb==0.23.1",

api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
"python-dotenv==1.1.0",
2626
"python-multipart==0.0.20",
2727
"sqlalchemy[asyncio]==2.0.40",
28-
"transformerlab==0.1.31",
28+
"transformerlab==0.1.32",
2929
"transformerlab-inference==0.2.52",
3030
"uvicorn==0.35.0",
3131
"watchfiles==1.0.5",

lab-sdk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "transformerlab"
7-
version = "0.1.31"
7+
version = "0.1.32"
88
description = "Python SDK for Transformer Lab"
99
readme = "README.md"
1010
requires-python = ">=3.10"

lab-sdk/src/lab/lab_facade.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -630,15 +630,28 @@ def finish(
630630
except Exception:
631631
pass
632632
_run_async(self._job.update_progress(100)) # type: ignore[union-attr]
633-
_run_async(
634-
self._job.update_job_data_fields( # type: ignore[union-attr]
635-
{
636-
"completion_status": "success",
637-
"completion_details": message,
638-
"end_time": time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()),
639-
}
640-
)
641-
)
633+
634+
# Resolve score before the first write so it's included atomically with the
635+
# other completion fields. This prevents a window where completion_status is
636+
# "success" but score is still null (observable by caches or concurrent readers).
637+
resolved_score: Dict[str, Any] = {}
638+
if isinstance(score, dict):
639+
resolved_score.update(score)
640+
resolved_score.setdefault("discard", False)
641+
642+
completion_fields: Dict[str, Any] = {
643+
"completion_status": "success",
644+
"completion_details": message,
645+
"end_time": time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()),
646+
"score": resolved_score,
647+
}
648+
if additional_output_path is not None and additional_output_path.strip() != "":
649+
completion_fields["additional_output_path"] = additional_output_path
650+
if plot_data_path is not None and plot_data_path.strip() != "":
651+
completion_fields["plot_data_path"] = plot_data_path
652+
653+
_run_async(self._job.update_job_data_fields(completion_fields)) # type: ignore[union-attr]
654+
642655
# Best-effort Trackio integration: finish our own run if we created one,
643656
# then capture the active Trackio DB (managed or user-created) into job artifacts.
644657
try:
@@ -662,15 +675,6 @@ def finish(
662675
except Exception:
663676
# Never let optional Trackio integration break finish()
664677
logger.debug("Trackio integration failed during finish()", exc_info=True)
665-
resolved_score: Dict[str, Any] = {}
666-
if isinstance(score, dict):
667-
resolved_score.update(score)
668-
resolved_score.setdefault("discard", False)
669-
_run_async(self._job.update_job_data_field("score", resolved_score)) # type: ignore[union-attr]
670-
if additional_output_path is not None and additional_output_path.strip() != "":
671-
_run_async(self._job.update_job_data_field("additional_output_path", additional_output_path)) # type: ignore[union-attr]
672-
if plot_data_path is not None and plot_data_path.strip() != "":
673-
_run_async(self._job.update_job_data_field("plot_data_path", plot_data_path)) # type: ignore[union-attr]
674678

675679
# Important: update cached_jobs only when all completion fields are already written.
676680
_run_async(self._job.update_status(JobStatus.COMPLETE)) # type: ignore[union-attr]

0 commit comments

Comments
 (0)