Skip to content

Commit

Permalink
πŸ’š Avoid returning draft notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
falexwolf committed Sep 29, 2024
1 parent 671954b commit 716d63c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lamin_cli/_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ def load(entity: str, uid: str = None, key: str = None, with_env: bool = False):
transform = (
ln.Transform.get(uid)
if uid is not None
else ln.Transform.get(key=key, is_latest=True)
# if below, we take is_latest=True as the criterion, we might get draft notebooks
# hence, we use source_code__isnull=False and order by created_at instead
else ln.Transform.filter(key=key, source_code__isnull=False)
.order_by("-created_at")
.first()
)
target_filename = transform.key
if Path(target_filename).exists():
Expand All @@ -64,7 +68,7 @@ def load(entity: str, uid: str = None, key: str = None, with_env: bool = False):
else:
Path(target_filename).write_text(transform.source_code)
else:
raise ValueError("No source code available for this transform.")
raise SystemExit("No source code available for this transform.")
logger.important(f"{transform.type} is here: {target_filename}")
if with_env:
if (
Expand Down

0 comments on commit 716d63c

Please sign in to comment.