ResourceLocator
Where one resource is, in the one vocabulary every caller shares.
from plexora.api import ResourceLocatorResourceLocator(
kind: str,
provider: str = 'local',
path: str | None = None,
node: str | None = None,
resource_id: str | None = None,
)path is the honest answer only for a local resource. For a node-backed
one it is None: a plugin holding a path to a file on another machine
would open it, find nothing, and report a missing project. Code that used
to reach for .path should ask a plexora.api.ImageHandle,
plexora.api.SegHandle or plexora.api.TableHandle to do the work
instead.
Fields
kindstrrequiredWhich resource this locates: "image", "segmentation" or "table".
providerstrdefault 'local'Where the bytes are read from: "local" (this filesystem) or "node"
(another Plexora process, reached over the node API).
pathstr | Nonedefault NoneThe filesystem path, for a local resource. None for a node-backed one.
nodestr | Nonedefault NoneWhich entry of nodes.json serves this, for a node-backed resource.
resource_idstr | Nonedefault NoneWhat that node calls it. Node-scoped, never globally unique -- two nodes may both serve a resource called "cells".
Properties
is_local
is_local: boolWhether this resource is read from this process's own filesystem.
Methods
to_dict
to_dict() -> dictThe JSON-safe form stored in a project's config.
dictkind and provider always; path, node and
resource_id only when set.
from_dict
@classmethod
from_dict(raw: Mapping[str, Any] | None, kind: str) -> 'ResourceLocator'Rebuild a locator from a project's stored config entry.
rawMapping[str, Any] | NonerequiredThe stored entry, in the shape
to_dict writes. None is treated as empty.
kindstrrequiredWhich resource this is ("image", "segmentation"
or "table").
ResourceLocatorThe locator described by raw.
Examples
from plexora.api import ResourceLocator
locator = ResourceLocator(kind="table", path="cells.csv")
locator.is_local # True