Skip to main content

Sans-IO host library for the pyControl behavioural-experiment framework.

Project description

pycontrol-core

pycontrol-core is the host engine for pyControl. It handles board communication, the wire protocol, workspace configuration, data logging, task and experiment extensions, firmware sync, and the pycontrol command-line tool.

The package is designed so GUI and script frontends share the same tested core:

Pyboard <-> Transport <-> protocol codec <-> BoardSession <-> event bus <-> subscribers

The on-disk data format and board wire protocol are kept compatible with existing pyControl sessions. See wire-protocol.md and data-format.md for the frozen specs.

Install From PyPI Alpha

For the 3.0.0a1 alpha, pin the prerelease:

uv add "pycontrol-core==3.0.0a1"
# or
pip install --pre "pycontrol-core==3.0.0a1"

To install the GUI workflow, add pycontrol-gui instead; it depends on pycontrol-core. See getting-started.md.

Install For Development

From this package:

pip install -e ".[test,lint]"

With uv:

uv sync --extra test --extra lint

Run checks:

uv run pytest
uv run ruff check src tests
uv run mypy

Create A Workspace

Most lab-authored files live in a workspace, not inside this package.

pycontrol workspace init my-workspace
cd my-workspace
pycontrol setups add BoxA --port /dev/cu.usbmodemXXXX

The workspace contains:

Path Purpose
tasks/ Task files uploaded to the board.
hardware_definitions/ Rig wiring files uploaded as hardware_definition.py.
devices/ Workspace device classes uploaded when referenced.
plugins/task_extensions/ Host-side task automation.
plugins/experiment_extensions/ Whole-experiment automation.
plugins/task_plotters/ Optional GUI plotters.
plugins/task_controls/ Optional GUI control panels.
experiments/*.json Multi-subject experiment definitions.
settings.json / setups.json Workspace settings and setup registry.
data/ Default output folder for TSV and analog .npy files.

For a full walkthrough, use getting-started.md.

Run A Task

pycontrol run --setup BoxA --task blinker --hwdef example \
  --subject mouse42 --duration 10

--setup looks up the serial port and setup variables from setups.json. --task and --hwdef are resolved against the workspace by stem or by path. Tasks that import hardware_definition need --hwdef.

The run command connects to the board, checks firmware status, uploads the hardware definition and task, starts the framework, and writes data under the workspace data directory.

Run An Experiment

pycontrol experiment blink_demo --duration 10

Experiment identity comes from the JSON file path under experiments/. For example, experiments/training/day1.json is experiment training/day1.

Experiment JSON supports a first-class optional hardware_definition field. When present, it overrides each setup's default hardware definition for that experiment; when omitted, the setup default is used.

Firmware And Board Checks

BoardSession.connect() performs a read-only firmware status check. It never syncs files automatically.

pycontrol firmware status --setup BoxA
pycontrol firmware sync --setup BoxA
pycontrol board info --setup BoxA --json

Setups can pin an expected MCU so the host refuses the wrong board:

pycontrol setups add BoxH7 --port /dev/cu.usbmodemYYYY --mcu stm32h743
pycontrol setups detect BoxH7

See troubleshooting.md for operator triage.

Public Imports

pycontrol.__init__ exports only __version__. Import from explicit modules:

from pycontrol.session import BoardSession
from pycontrol.recording import TsvLogger
from pycontrol.extension import TaskExtension
from pycontrol.workspace import Workspace

See public-api.md for the supported import surface.

Documentation

New to the project? Start with the repo-level guides:

Orientation and operation:

Contracts and internals:

Extending pyControl:

Project process:

Contributing

See the repository-level CONTRIBUTING.md for editable installs, tests, contracts, firmware notes, and trusted plugin guidance.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycontrol_core-3.0.0a1.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycontrol_core-3.0.0a1-py3-none-any.whl (223.2 kB view details)

Uploaded Python 3

File details

Details for the file pycontrol_core-3.0.0a1.tar.gz.

File metadata

  • Download URL: pycontrol_core-3.0.0a1.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pycontrol_core-3.0.0a1.tar.gz
Algorithm Hash digest
SHA256 66c5d380a24f1014806bb01364da9543dd8bdaae3c470b1ef202be7e983e73b2
MD5 836a9eb2010b97f58a3c97002977f7f5
BLAKE2b-256 909e294b8f7ddcf801aa815b8e9be3946deac583294e5275c61f3206a7933201

See more details on using hashes here.

File details

Details for the file pycontrol_core-3.0.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for pycontrol_core-3.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e86556ff74591f1b34371c3ae6d01593646e34997fb1d526cfa796153478dd6
MD5 be2e58df21b08e9be4ba39f3907f4a30
BLAKE2b-256 6dfedbad2376e84cabb211a5a4e4196d390a5da6cb4d5c3e1e4a8e29d0663e77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page