workspace
The workspace of a service account: listing its filespaces and linking them.
client.workspace is the Workspace of the service account the client logged in as. Workspace.list_filespaces() lists the filespaces of the workspace, and Workspace.link_filespace() links one and returns its Filespace.
lucidlink.Workspace
Workspace()The workspace of the service account a Client logged in as.
Get it from client.workspace. Several filespaces can be linked at the same time; each link_filespace() returns its own Filespace, usable until it is unlinked.
Once the owning Client is closed, list_filespaces() and link_filespace() raise ClientClosedError.
Workspace example
workspace = client.workspaceprint(workspace.id, workspace.name)for info in workspace.list_filespaces():print(info.id, info.name)
id: str
The workspace ID.
linked_filespaces: list[Filespace]
The filespaces linked through this workspace and not yet unlinked.
name: str
The workspace name.
link_filespace(filespace_id: str, *, cache: CacheConfig | None = None) -> Filespace
Link a filespace of the workspace and return its Filespace.
Linking one filespace leaves the others linked. Each linked filespace has its own data cache on disk and its own metadata cache; both grow on demand up to the maximum sizes in cache.
Linking a filespace that is already linked returns its Filespace when each size set in cache equals the maximum given when it was linked or its current maximum; a size left as None matches any. To change the maximum sizes, unlink the filespace and link it again with the new ones. A size left as None keeps a maximum given when the filespace was linked before, so CacheConfig() does not bring back the defaults; see CacheConfig.
Parameters
Parameter | Description |
|---|---|
| The ID of the filespace, as list_filespaces() returns it. |
| The maximum cache sizes of the filespace; see CacheConfig for the size a field left as None gets. None is the same as CacheConfig(). |
filespace_id
Description
The ID of the filespace, as list_filespaces() returns it.
cache
Description
The maximum cache sizes of the filespace; see CacheConfig for the size a field left as None gets. None is the same as CacheConfig().
Returns
The linked filespace. Use it as a context manager, or call Filespace.unlink() when done.
Raises
Exception | Condition |
|---|---|
If the workspace has no filespace with that ID. | |
If the filespace is already linked and a size set in cache differs from both the maximum given when it was linked and its current maximum. | |
If filespace_id is empty or contains a NUL character, or a cache size is negative, larger than 2**63 - 1 or not accepted for that cache (the data cache size must be a multiple of 1 MiB). | |
| If a cache size is not an integer. |
If the filespace is still being created. | |
If the service account has no access to the filespace. | |
If the service account token expired or was revoked. | |
If this version of the SDK cannot link the filespace: the SDK is too old, or the filespace format is not supported. | |
If LucidLink services report too many requests. |
Condition
If the filespace is already linked and a size set in cache differs from both the maximum given when it was linked and its current maximum.
Condition
If filespace_id is empty or contains a NUL character, or a cache size is negative, larger than 2**63 - 1 or not accepted for that cache (the data cache size must be a multiple of 1 MiB).
TypeError
Condition
If a cache size is not an integer.
Condition
If this version of the SDK cannot link the filespace: the SDK is too old, or the filespace format is not supported.
Workspace.link_filespace example
from lucidlink import CacheConfig, FsUtils# Unlinked when the block exits, after a best-effort final syncwith workspace.link_filespace("fs-uuid-12345") as filespace:FsUtils(filespace.file_system).write_bytes("/file.txt", b"data")filespace.sync() # when the changes must be saved# With a data cache of up to 2 GiBfilespace = workspace.link_filespace("fs-uuid-12345", cache=CacheConfig(data_size=2 * 1024**3))filespace.unlink()
list_filespaces() -> list[FilespaceInfo]
List the filespaces of the workspace.
Returns
The ID, name and creation time of each filespace.
Raises
Exception | Condition |
|---|---|
If the service account token expired or was revoked. | |
If the service account may not list the filespaces of the workspace. | |
If LucidLink services report too many requests. |
Workspace.list_filespaces example
for info in workspace.list_filespaces():print(info.name, info.created_at)
stop() -> None
Unlink every filespace linked through this workspace.
Each filespace is unlinked as by Filespace.unlink(). Every filespace is unlinked even when one fails, and the failures are raised together afterwards. Filespaces can be linked again afterwards.
Raises
Exception | Condition |
|---|---|
If unlinking one or more filespaces failed, for example their final sync or the close of an open file. Each failure is a member; a FilespaceError member carries the filespace_id of its filespace. |
Condition
If unlinking one or more filespaces failed, for example their final sync or the close of an open file. Each failure is a member; a FilespaceError member carries the filespace_id of its filespace.