Skip to main content

Python library for Alicat mass flow meters and controllers.

Project description

alicatlib

Python library for Alicat Scientific instruments over serial — the full {flow, pressure} × {meter, controller} × {gas, liquid} matrix, plus the CODA Coriolis line. Covered prefixes include M- / MC- gas mass flow, P- / PC- gas pressure, L- / LC- liquid flow, the K-family (K- / KM- / KC- / KF- / KG-) CODA Coriolis prefixes, and all documented specialty variants (MCDW-, PCD-, LCR-, BASIS-, SFF-, …). The Medium model is flexible enough to handle devices configured for gas, liquid, or both — users narrow to the specific unit configuration via assume_media= on open_device.

alicatlib is focused on correctness, typed APIs, and reliable multi-device acquisition.

Status: beta. Documentation and release prep in progress; see docs/design.md for the architecture and remaining future work.

Highlights

  • Typed end to end. Gas.N2, Unit.SCCM, Statistic.MASS_FLOW, frozen dataclass responses. py.typed shipped. mypy --strict passes.
  • Declarative commands. One Command object per Alicat command with encoding, decoding, firmware gating, device-kind gating, and medium gating (gas vs. liquid, for CODA and friends) as metadata — adding a new command is ~50 lines.
  • Typed errors. Distinct exception types for timeout, malformed response, unsupported firmware, and device error markers — all carrying structured ErrorContext for debuggability.
  • Safety. Destructive operations (factory reset, baud change, exhaust) require confirm=True. Setpoints are range-checked before any I/O.
  • Multi-device, correctly. AlicatManager runs many devices concurrently; same-port requests serialize via a shared lock, different ports run in parallel, resources unwind cleanly on partial-open failures.
  • Acquisition built in. record() drives one or more devices at an absolute-target cadence with no cumulative drift, and pipe() drains samples into any SampleSink. First-party sinks: InMemorySink, CsvSink, JsonlSink, SqliteSink (stdlib WAL), plus ParquetSink and PostgresSink behind extras.
  • Streaming mode. dev.stream(...) opens a bounded-memory StreamingSession that normalises the wire and fast-fails any concurrent request/response command on the same bus; NCS sets the device's continuous-stream rate on V10 firmware 10v05+.
  • Swappable transports. SerialTransport for hardware, FakeTransport for tests; TCP / Modbus can land behind the same interface later.
  • Sync or async. The core is async (built on anyio), and a sync facade (alicatlib.sync.Alicat) wraps it for scripts, notebooks, and REPLs.
  • Lean core. pip install alicatlib pulls in anyio and anyserial — and nothing else. Parquet, Postgres, and docs live behind extras.

Install

pip install alicatlib
# optional sinks
pip install 'alicatlib[parquet]'
pip install 'alicatlib[postgres]'

Requires Python 3.13+.

Quickstart (sync)

from alicatlib.sync import Alicat

with Alicat.open("/dev/ttyUSB0") as dev:
    frame = dev.poll()
    print(frame.get_float("Mass_Flow"))
    dev.setpoint(50.0, "SCCM")

Quickstart (async)

import anyio
from alicatlib import Gas, open_device

async def main():
    async with await open_device("/dev/ttyUSB0") as dev:
        frame = await dev.poll()
        print(frame.get_float("Mass_Flow"))
        await dev.gas(Gas.N2, save=True)

anyio.run(main)

Development

Uses uv for env and lock management, hatchling for the build backend, ruff for format and lint, and mypy --strict for types.

uv sync --all-extras --dev
uv run pytest
uv run ruff format --check .
uv run ruff check .
uv run mypy

See CONTRIBUTING.md for the full workflow, and docs/design.md for the architectural design.

License

MIT. See LICENSE.

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

alicatlib-0.3.0.tar.gz (480.5 kB view details)

Uploaded Source

Built Distribution

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

alicatlib-0.3.0-py3-none-any.whl (293.9 kB view details)

Uploaded Python 3

File details

Details for the file alicatlib-0.3.0.tar.gz.

File metadata

  • Download URL: alicatlib-0.3.0.tar.gz
  • Upload date:
  • Size: 480.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for alicatlib-0.3.0.tar.gz
Algorithm Hash digest
SHA256 83bd313d2ad60bf0c86da51897384d5ef50d83da8bb004471ef35ccd9111946c
MD5 b7ff7ab32832fd4720c6a3773b70a72a
BLAKE2b-256 da1ca04d8f008169817ec4452b74a6cccb6c01abde285d54f171c90170de0fc8

See more details on using hashes here.

Provenance

The following attestation bundles were made for alicatlib-0.3.0.tar.gz:

Publisher: release.yml on GraysonBellamy/alicatlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alicatlib-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: alicatlib-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 293.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for alicatlib-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cdcb8c5fdd0b9222f84abd0c87674e9b04b155cb8352ddf87e27cff5ca486b1b
MD5 7fa1a874f060c83905a39c93c8b337e2
BLAKE2b-256 3544159214cb9f7d9cf6701d6a76eaa25ddf48abe178c0373254df148e36645d

See more details on using hashes here.

Provenance

The following attestation bundles were made for alicatlib-0.3.0-py3-none-any.whl:

Publisher: release.yml on GraysonBellamy/alicatlib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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