plesty init#
Initialize a new Plesty project from the official template. The project is created in the
directory specified by the global --project-dir option (defaults to the current working
directory), making the standard workflow as simple as:
mkdir plesty-my-device && cd plesty-my-device
plesty init device
plesty init [PROJECT_TYPE] [OPTIONS]
PROJECT_TYPE is one of device or experiment (default: default, not yet available).
Naming conventions#
All Plesty projects follow a consistent naming scheme derived from the module name
(e.g. foo_bar):
Artifact |
Convention |
Example |
|---|---|---|
Project folder |
|
|
Source folder |
|
|
PyPI distribution |
|
|
Python import |
|
|
The plesty- prefix in the folder name is automatically stripped when inferring the module
name, so plesty-foo-bar → foo_bar without needing --name.
Options#
Option |
Default |
Description |
|---|---|---|
|
inferred |
Python module name — lowercase letters, digits, and |
|
|
Author name written into |
|
|
Author email written into |
|
|
Compliance standard for the generated CI pipeline: |
|
off |
Skip generating |
Directory rules#
If
--project-dirdoes not exist it is created automatically.If it already exists it must be empty (hidden entries such as
.gitare ignored).
What init does#
After copying the template, plesty init automatically:
Formats generated files — runs
ruff formatso the scaffold is alreadyplesty check-clean from the first commit.Creates the initial git commit — required by
versioningitto resolve a package version from git history.Installs the pre-push hook — writes
.git/hooks/pre-pushto runplesty checkautomatically before everygit push(standard read from[tool.plesty] standardinpyproject.toml, default:quantum).
Examples#
# Minimal: module name inferred from directory, quantum CI, default author
mkdir plesty-power-meter && cd plesty-power-meter
plesty init device
# Explicit name and author
plesty --project-dir ~/projects/plesty-power-meter init device \
--name power_meter \
--author "Jane Doe" \
--email jane@example.com
# Use nebula standard in CI (gates 1–6 only)
plesty --project-dir ~/projects/plesty-scan-exp init experiment \
--name scan_exp \
--standard nebula
# Skip CI file entirely
plesty --project-dir ~/projects/plesty-internal-tool init device \
--name internal_tool \
--no-ci
Generated project layout#
plesty-foo-bar/
├── plesty/
│ └── foo_bar/
│ ├── __init__.py
│ ├── __main__.py
│ ├── base_device.py # device only
│ └── device.py # device only
├── docs/
│ ├── index.md
│ └── toc.yaml
├── tests/
│ ├── __init__.py
│ └── test_foo_bar.py # smoke tests covering all public methods
├── CHANGELOG.md
├── .env.example # device only — connection credential template
├── .git/
│ └── hooks/
│ └── pre-push # runs plesty check (standard from pyproject.toml)
├── .gitlab-ci.yml # omitted when --no-ci
├── .gitignore # ignores .env (keeps .env.example tracked)
├── LICENSE # LGPL text, kept for forge (GitLab) detection
├── LICENSES/
│ └── LGPL-3.0-or-later.txt
├── REUSE.toml # declares copyright/license for every file
├── pyproject.toml
└── README.md
The pyproject.toml is pre-configured with:
The PyPI distribution name
plesty-foo-bar(kebab-case)packages = ["plesty"]so the module installs under theplestynamespace (import plesty.foo_bar)Dynamic versioning via
versioningitplesty-libas a runtime dependencypytest,pytest-cov,mypy, andplesty-sdkunder[dependency-groups] dev(included automatically byuv run— no--extra devneeded)Sphinx docs settings under
[tool.plesty.docs]
The generated .gitlab-ci.yml uses the unified plesty-standard-ci CI component from
plesty-ci and passes access_token: $CI_BOT_TOKEN. Configure a project access token with
read_repository + write_repository scopes and Maintainer role, then set it as a
masked CI/CD variable named CI_BOT_TOKEN.
Use plesty update to change author info, the PyPI name, or CI standard after initialisation.
Device connection credentials (device only)#
Device projects are scaffolded to read their connection credentials from the
environment rather than hard-coding them. The generated __main__.py loads three
variables via plesty.lib.utils.EnvSettings:
Variable |
Meaning |
Required |
|---|---|---|
|
Target device host / IP |
yes |
|
Target device port |
yes |
|
ZMQ port the device server binds (default |
no |
Resolution precedence per value is CLI argument > environment variable > default.
The required DEVICE_HOST/DEVICE_PORT are validated with parser.error(...), so a
missing credential produces a clean usage message instead of a traceback.
EnvSettings.load() reads ./.env and then the process environment (the process
environment wins) and, by default, also registers the parsed .env values into
os.environ. Rename these variables per device as needed — the names are just the
scaffold defaults, not a fixed contract.
Workflow:
cp .env.example .env # then fill in DEVICE_HOST / DEVICE_PORT
python -m plesty.foo_bar # credentials read from .env
python -m plesty.foo_bar --host 10.0.0.5 --tcp-port 6000 # CLI overrides env
.env.example is committed as a template; the real .env is gitignored. The generated
tests/test_foo_bar.py includes a skipif real-device test that consumes the same
variables, so one .env drives both the server and the tests. It is skipped unless
DEVICE_HOST is set.