## lamindb_setup.core

Core library.

# Settings

class lamindb_setup.core.SetupSettings

 Setup settings.

| modules_warning: str | None = None |

 property modules: set[str]

 The set of configured schema modules for this environment.

 Instance modules take precedence if an instance is configured,
 including when it is resolved from a dev-dir marker or
 "LAMIN_CURRENT_INSTANCE". Otherwise, "LAMINDB_MODULES" overrides
 a global setting.

 property settings_dir: Path

 The directory that holds locally persisted 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 dev_dir: Path | None |

 Development directory containing the working directory.

 This is the nearest parent, including the working directory,
 with a ".lamin/current_instance" marker for the current
 instance. "$HOME" is never a development directory. Outside
 every such directory the value is "None".

 Setting a path writes that marker and leaves every other
 development directory in place. Setting "None" removes the
 marker of the directory that contains the working directory.

 property branch: lamindb.Branch

 Default branch.

 property space: lamindb.Space

 Default space, falling back to "all" when no space is
 configured.

 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 is_configured: bool

 Whether an instance is configured in this environment.

 "True" means the current instance is a real instance (not
 "none/none").

 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 user: UserSettings

 Settings of current user.

 property instance: InstanceSettings

 Settings of current LaminDB instance.

 property storage: StorageSettings

 Settings of default storage.

 property cache_dir: UPath

 Cache root, a local directory to cache cloud files.

 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".

 get_configured_space()

 Return the configured space, or "None" for the implicit "all"
 default.

 A directory-specific selection takes precedence over the
 instance-wide selection. An explicit selection of "all" also
 counts as configured.

 Return type:
| Space | None |

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.

 handle: "str" = 'anonymous'

 Unique handle.

| email: "str" | "None" = None |

 User email.

| api_key: "str" | "None" = None |

 API key.

| password: "str" | "None" = None |

 Legacy password.

| access_token: "str" | "None" = None |

 User access token.

 uid: "str" = 'null'

 Universal user ID.

| name: "str" | "None" = None |

 Full name.

 property id

 Integer id valid in current instance.

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, _is_clone=False)

 Instance settings.

 property owner: str

 Instance owner. A user or organization account handle.

 property name: str

 Instance name.

 property keep_artifacts_local: bool

 Default to keeping artifacts local.

 Guide: Keep artifacts local in a cloud instance

 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 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 slug: str

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

| property git_repo: str | None |

 Sync transforms with scripts in git repository.

 Provide the full git repo URL.

| property api_url: str | None |

 URL for REST API.

 Use this URL for API calls related to this instance.

| property ui_url: str | None |

 URL for UI.

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

 property is_read_only_connection: bool

 Whether the current connection to the database is read-only.

| 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 uid: str

 The user-facing instance id.

 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 db: str

 Database connection string (URI).

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

 SQL dialect.

 Equivalent to "vendor".

 "vendor" is the Django terminology for the type of database.
 "dialect" is the SQLAlchemy terminology.

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

 Database vendor.

 Equivalent to "dialect".

 "vendor" is the Django terminology for the type of database.
 "dialect" is the SQLAlchemy terminology.

 property is_remote: bool

 Boolean indicating if an instance has no local component.

 property is_on_hub: bool

 Is this instance registered on the hub?

 Most likely you're looking for "is_managed_by_hub". The instance
 being registered on LaminHub doesn't imply that LaminHub has
 access to the instance. If you want to know whether there is a
 LaminHub UI, use "is_managed_by_hub". If you merely want to know
 whether the instance is registered, independent of whether
 LaminHub has access to the instance, use "is_on_hub".

 The "is_on_hub" property makes a network request to the hub and
 can only establish if an instance is registered if the calling
 user has access to the instance. Will return "False" in case the
 user has no access.

 property is_managed_by_hub: bool

 Is this instance managed by the hub?

 Returns "True" if the instance is managed by LaminHub, i.e., the
 instance was connected to LaminHub to manage permissions and
 migrations and provide access to the instance through a UI and a
 REST API.

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.

 property uid: str

 Storage uid.

| 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 record: Storage

 Storage record in the current instance.

| property hub_record: dict | None |

 property root: UPath

 Root storage location.

 property root_as_str: str

 Formatted root string.

 property cache_dir: UPath

 Cache root, a local directory to cache cloud files.

 property type_is_cloud: bool

 "True" if "storage_root" is in cloud, "False" otherwise.

| 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 region: str | None |

 Storage region.

 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 is_on_hub: bool

 Is this instance on the hub.

 Only works if user has access to the instance.

 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"