lamindb.setup.core

Core setup library.

class lamindb.setup.core.SetupSettings

Setup settings.

property auto_connect: bool

Auto-connect to current instance upon import lamindb.

This setting is always True and will be removed in a future version.

property branch: Branch

Default branch.

property cache_dir: UPath

Cache root, a local directory to cache cloud files.

property dev_dir: Path | None

Get or set the local development directory for the current instance.

If setting it to None, the working development directory is unset.

property instance: InstanceSettings

Settings of current LaminDB instance.

property is_connected: bool

Determine whether the current instance is fully connected and ready to use.

If True, the current instance is connected, meaning that the db and other settings are properly configured for use.

property paths: type[SetupPaths]

Convert cloud paths to lamindb local paths.

Use settings.paths.cloud_to_local_no_update or settings.paths.cloud_to_local.

property private_django_api: bool

Turn internal Django API private to clean up the API (default False).

This patches your local pip-installed django installation. You can undo the patch by setting this back to False.

property settings_dir: Path

The directory that holds locally persisted settings.

property space: Space

Default space.

property storage: StorageSettings

Settings of default storage.

property user: UserSettings

Settings of current user.

class lamindb.setup.core.UserSettings(handle='anonymous', email=None, api_key=None, password=None, access_token=None, uid='null', _uuid=None, name=None)

User data. All synched from cloud.

access_token: str | None = None

User access token.

api_key: str | None = None

API key.

email: str | None = None

User email.

handle: str = 'anonymous'

Unique handle.

property id

Integer id valid in current instance.

name: str | None = None

Full name.

password: str | None = None

legacy API key or legacy password.

uid: str = 'null'

Universal user ID.

class lamindb.setup.core.InstanceSettings(id, owner, name, storage=None, keep_artifacts_local=False, db=None, modules=None, git_repo=None, is_on_hub=None, api_url=None, schema_id=None, fine_grained_access=False, db_permissions=None, _locker_user=None)

Instance settings.

property api_url: str | None

URL for REST API.

Use this URL for API calls related to this instance.

property available_spaces: dict | None

Available spaces with roles for instances fine-grained permissions.

Returns a dictionary with roles as keys and lists of available spaces as values if this instance has fine-grained permissions and the current user is a collaborator, None otherwise.

property db: str

Database connection string (URI).

property dialect: Literal['sqlite', 'postgresql']

SQL dialect.

property git_repo: str | None

Sync transforms with scripts in git repository.

Provide the full git repo URL.

property is_on_hub: bool

Is this instance on the hub?

Can only reliably establish if user has access to the instance. Will return False in case the instance isn’t found.

property is_remote: bool

Boolean indicating if an instance has no local component.

property keep_artifacts_local: bool

Default to keeping artifacts local.

Guide: Keep artifacts local in a cloud instance

property local_storage: StorageSettings

An alternative default local storage location in the current environment.

Serves as the default storage location if keep_artifacts_local is enabled.

Guide: Keep artifacts local in a cloud instance

property modules: set[str]

The set of modules that defines the database schema.

The core schema contained in lamindb is not included in this set.

property name: str

Instance name.

property owner: str

Instance owner. A user or organization account handle.

property slug: str

Unique semantic identifier of form "{account_handle}/{instance_name}".

property storage: StorageSettings

Default storage of instance.

For a cloud instance, this is cloud storage. For a local instance, this is a local directory.

property ui_url: str | None

URL for UI.

Use this URL for accessing the UI related to this instance.

property uid: str

The user-facing instance id.

class lamindb.setup.core.StorageSettings(root, region=None, uid=None, uuid=None, instance_id=None, access_token=None)

Settings for a storage location (local or cloud).

Do not instantiate this class yourself, use ln.Storage instead.

Attributes

property cache_dir: UPath

Cache root, a local directory to cache cloud files.

property host: str | None

Host identifier for local storage locations.

Is None for locations with type != "local".

A globally unique user-defined host identifier (cluster, server, laptop, etc.).

property instance_uid: str | None

The uid of the managing LaminDB instance.

If None, the storage location is not managed by any LaminDB instance.

property is_on_hub: bool

Is this instance on the hub.

Only works if user has access to the instance.

property record: Any

Storage record in the current instance.

property region: str | None

Storage region.

property root: UPath

Root storage location.

property root_as_str: str

Formatted root string.

property type: Literal['local', 's3', 'gs', 'hf', 'http', 'https']

AWS S3 vs. Google Cloud vs. local.

Returns the protocol as a stringe, e.g., “local”, “s3”, “gs”, “http”, “https”.

property type_is_cloud: bool

True if storage_root is in cloud, False otherwise.

property uid: str

Storage uid.

Methods

cloud_to_local(filepath, cache_key=None, **kwargs)

Local (or local cache) filepath from filepath.

Return type:

UPath

cloud_to_local_no_update(filepath, cache_key=None)
Return type:

UPath

key_to_filepath(filekey)

Cloud or local filepath from filekey.

Return type:

UPath

local_filepath(filekey)

Local (cache) filepath from filekey.

Return type:

UPath