Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Better error message when attempting to save a file while not being connected to an instance #103

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading