Skip to content

Commit

Permalink
✨ Better error message when attempting to save a file while not being…
Browse files Browse the repository at this point in the history
… connected to an instance (#103)

Signed-off-by: zethson <[email protected]>
  • Loading branch information
Zethson authored Jan 9, 2025
1 parent d68f210 commit 880e62b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ test-search2
test-search3
test-search4
test-search5
test.ipynb

# General
.DS_Store

Expand Down
11 changes: 11 additions & 0 deletions lamin_cli/_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Union
from lamin_utils import logger
import re
from click import ClickException


def parse_uid_from_code(content: str, suffix: str) -> str | None:
Expand Down Expand Up @@ -40,6 +41,11 @@ def parse_uid_from_code(content: str, suffix: str) -> str | None:
return uid


class ClickInstanceNotSetupError(ClickException):
def show(self, file=None):
pass


def save_from_filepath_cli(
filepath: Union[str, Path],
key: str | None,
Expand All @@ -56,6 +62,11 @@ def save_from_filepath_cli(
auto_connect_state = ln_setup.settings.auto_connect
ln_setup.settings.auto_connect = True

if not ln_setup._check_instance_setup():
from lamindb_setup._check_setup import InstanceNotSetupError

raise ClickInstanceNotSetupError(InstanceNotSetupError.default_message)

import lamindb as ln
from lamindb._finish import save_context_core

Expand Down

0 comments on commit 880e62b

Please sign in to comment.