Plexora

ResourceLocator

Where one resource is, in the one vocabulary every caller shares.

Generated from Plexora 0.0.55View source
from plexora.api import ResourceLocator
ResourceLocator(
    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

kindstrrequired

Which 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 None

The filesystem path, for a local resource. None for a node-backed one.

nodestr | Nonedefault None

Which entry of nodes.json serves this, for a node-backed resource.

resource_idstr | Nonedefault None

What that node calls it. Node-scoped, never globally unique -- two nodes may both serve a resource called "cells".

Properties

is_local

is_local: bool

Whether this resource is read from this process's own filesystem.

Methods

to_dict

to_dict() -> dict

The JSON-safe form stored in a project's config.

dict

kind 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] | Nonerequired

The stored entry, in the shape to_dict writes. None is treated as empty.

kindstrrequired

Which resource this is ("image", "segmentation" or "table").

ResourceLocator

The locator described by raw.

Examples

from plexora.api import ResourceLocator

locator = ResourceLocator(kind="table", path="cells.csv")
locator.is_local  # True

On this page