plesty.server.model.home

The bench’s plesty-server home directory: venvs, logs and process state.

Everything plesty-server writes lives under one directory so a bench can be wiped or moved as a whole. Resolution order for its location: an explicit --home, home: in fleet.yaml, PLESTY_SERVER_HOME, then the packaged default (~/.plesty/server — beside ~/.plesty/ui where plesty-lib keeps its window layouts).

Attributes

HOME_ENV

Classes

Home

Layout of the plesty-server home directory.

Functions

default_home(→ pathlib.Path)

The home directory the environment or the packaged config designates.

Module Contents

plesty.server.model.home.HOME_ENV = 'PLESTY_SERVER_HOME'
plesty.server.model.home.default_home() → pathlib.Path

The home directory the environment or the packaged config designates.

Returns:

$PLESTY_SERVER_HOME when set, else running.home from config.yaml with ~ expanded.

Return type:

pathlib.Path

class plesty.server.model.home.Home

Layout of the plesty-server home directory.

Variables:

root – The directory everything lives under.

root: pathlib.Path
classmethod resolve(root: str | os.PathLike[str] | None = None) → Home

Build a home from an explicit path or the environment default.

Parameters:

root (str | os.PathLike[str] | None) – Directory to use; None selects default_home().

Return type:

Home

property venvs: pathlib.Path

One virtual environment per installed device, keyed by device name.

Return type:

pathlib.Path

property logs: pathlib.Path

One append-only log per device server.

Return type:

pathlib.Path

property state: pathlib.Path

One JSON record per running server (pid, port, start time).

Return type:

pathlib.Path

property run: pathlib.Path

Working directories the servers run in; plesty-lib writes logs/ there.

Return type:

pathlib.Path

property repos: pathlib.Path

Git checkouts of device modules installed from a repository.

Return type:

pathlib.Path

property jobs: pathlib.Path

One JSON record per long-running job (install, update, field test, command).

Return type:

pathlib.Path

property fleets: pathlib.Path

Where the bench keeps its fleets, one file each (<home>/fleets/<name>.yaml).

Return type:

pathlib.Path

property default_fleet: pathlib.Path

The fleet a new bench starts with, empty (<home>/fleets/default.yaml).

Return type:

pathlib.Path

fleet_file(name: str) → pathlib.Path

The file of the fleet called name.

Parameters:

name (str)

Return type:

pathlib.Path

property data: pathlib.Path

Where the devices write while the bench has no Plesty share (#43).

Return type:

pathlib.Path

property demo: pathlib.Path

Where the welcome’s demo keeps its runs, and its spectrometer replays them (#43).

Return type:

pathlib.Path

property tools: pathlib.Path

Tools the bench installed for itself (the portable git on Windows).

Return type:

pathlib.Path

property packages: pathlib.Path

one environment per (package, version), side by side.

Type:

Installed device modules

Return type:

pathlib.Path

package_dir(package: str, version: str) → pathlib.Path

Environment of package at version.

Parameters:
  • package (str)

  • version (str)

Return type:

pathlib.Path

package_record(package: str, version: str) → pathlib.Path

Record file of package at version (beside its environment).

Parameters:
  • package (str)

  • version (str)

Return type:

pathlib.Path

property last_fleet: pathlib.Path

Pointer file naming the fleet the console used last (<home>/last-fleet).

Return type:

pathlib.Path

package_info(package: str) → pathlib.Path

The package-level record of package: repository, project page, latest release.

Parameters:

package (str)

Return type:

pathlib.Path

checkout(package: str, ref: str | None) → pathlib.Path

Checkout directory of package at ref (git sources only).

Refs may contain / (feat/x); the directory name flattens them.

Parameters:
  • package (str)

  • ref (str | None)

Return type:

pathlib.Path

job_file(job_id: str) → pathlib.Path

Record file of job job_id.

Parameters:

job_id (str)

Return type:

pathlib.Path

job_log(job_id: str) → pathlib.Path

Log file of job job_id.

Parameters:

job_id (str)

Return type:

pathlib.Path

venv(name: str) → pathlib.Path

Venv directory of the device name.

Parameters:

name (str)

Return type:

pathlib.Path

log(name: str) → pathlib.Path

The current log file of the device name.

Each server start, and each Clear log, opens a new file named with its time (new_log()); logs/<name>.current names the one in use. Without a pointer — a log written before there were any — it is the single logs/<name>.log every start used to append to.

Parameters:

name (str)

Return type:

pathlib.Path

new_log(name: str) → pathlib.Path

Start a new log file for name, make it the current one, and return it.

Named <name>-<YYYYMMDD-HHMMSS>.log. Older files stay: a clear never truncates a file a running server writes, which is what left an 11.7 MB log no reader could get through (#23).

Parameters:

name (str)

Return type:

pathlib.Path

state_file(name: str) → pathlib.Path

Process-state file of the device name.

Parameters:

name (str)

Return type:

pathlib.Path

run_dir(name: str) → pathlib.Path

Working directory of the device name’s server process.

Parameters:

name (str)

Return type:

pathlib.Path

property runs: pathlib.Path

Where experiment runs land, one directory per declared experiment.

A measurement’s data is not a device’s working directory and does not belong under run/: it outlives the process that wrote it, it is what the operator came for, and a purge that clears working directories must not reach it.

Return type:

pathlib.Path

run_root(name: str) → pathlib.Path

Root the runs of experiment name go under.

One root per declared experiment, so plesty.lib.experiment.Run and latest_run read it exactly as they read a checkout’s runs/.

Parameters:

name (str)

Return type:

pathlib.Path

ensure() → Home

Create the directory tree; returns self for chaining.

Return type:

Home