Skip to main content

Python SPEC modules and tools

Project description

Test status badge

Test

PySpec

PySpec is a Python implementation of the SPEC server and client protocol, providing tools for remote control, data acquisition, and automation in scientific instrumentation environments. It enables Python-based clients to interact with a SPEC server, control motors, read/write variables, and execute commands or functions remotely.

Features

  • Async client-server architecture for high-performance remote control
  • Remote property and function access (read/write variables, call functions)
  • Motor control and status monitoring
  • Output streaming from server to client
  • Associative array and data array support
  • Test mode for safe experimentation

Installation

PySpec requires Python 3.9+ and depends on cython, h5py, numpy, and pyee.

pip install .
# or for development
pip install -e .[dev]

Quick Start

Connecting as a Client

import asyncio
from pyspec.client import Client

async def main():
    async with Client("127.0.0.1", 6510) as client:
        # Get a reference to "var/foo" on the server.
        foo = client.var("foo", int)
        await foo.set(42)
        value = await foo.get()
        print("foo:", value) # foo: 42

        result = await client.call("add", 2, 3)
        print("add(2, 3):", result)


        # Wait for properties to be set to specific values
        await foo.wait_for(15, timeout=10)


asyncio.run(main())

Motor Control Example

async with Client("127.0.0.1", 6510) as client:
    motor = client.motor("theta")

    # Read and write motor properties and parameters
    await motor.sign.get()
    await motor.offset.get()
    await motor.position.get()
    ...

    # Move motors on the server
    async with motor:
        await motor.move(10.0)
        pos = await motor.position.get()
        print("Motor position:", pos) # "Motor position: 10.0"

Output Streaming Example

async with Client("127.0.0.1", 6510) as client:
    async with client.output("tty").capture() as lines:
        await client.exec('print("Hello, world!")')
    print(lines[-1])  # Should print 'Hello, world!\n'

Starting a Server

from pyspec.server import Server, Property, remote_function
import asyncio

class MyServer(Server):
    foo = Property[int]("foo", 0)

    @remote_function
    def add(self, a: str, b: str):
        return float(a) + float(b)

async def main():
    async with MyServer(host="127.0.0.1", port=6510, test_mode=True) as server:
        await server.serve_forever()

asyncio.run(main())

Hardware servers currently support properties and remote function calls. Connect with a PySpec or spec client to interface with a PySpec server.

Currently unsupported server features:

  1. Associative Arrays
  2. Motor Protocols (through ../start_one or ../start_all )

Testing

Run the test suite with:

pytest

Documentation

See the docs/ directory for full API documentation and usage details.

License

See LICENSE or the source headers for license details. Portions copyright Certified Scientific Software.

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

chess_pyspec-1.0.0.tar.gz (80.4 kB view details)

Uploaded Source

Built Distributions

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

chess_pyspec-1.0.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (111.2 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

chess_pyspec-1.0.0-pp311-pypy311_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (114.2 kB view details)

Uploaded PyPymanylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

chess_pyspec-1.0.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (111.2 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

chess_pyspec-1.0.0-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (114.2 kB view details)

Uploaded PyPymanylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

chess_pyspec-1.0.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (111.2 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

chess_pyspec-1.0.0-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (114.2 kB view details)

Uploaded PyPymanylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

chess_pyspec-1.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (258.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

chess_pyspec-1.0.0-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (247.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

chess_pyspec-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (256.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

chess_pyspec-1.0.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (247.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

chess_pyspec-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (258.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

chess_pyspec-1.0.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (246.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

chess_pyspec-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (258.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

chess_pyspec-1.0.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (246.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

chess_pyspec-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (257.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

chess_pyspec-1.0.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (246.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.12+ i686manylinux: glibc 2.17+ i686

File details

Details for the file chess_pyspec-1.0.0.tar.gz.

File metadata

  • Download URL: chess_pyspec-1.0.0.tar.gz
  • Upload date:
  • Size: 80.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.21

File hashes

Hashes for chess_pyspec-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f7b4e9c84aa2c72ccfa285af191cf8373f1d606bca9ec2096514ea31f84a6724
MD5 8d91ea8d16b9b09eec33d882d36494eb
BLAKE2b-256 76b3d7bfd3a59b470d623c24626c9a5028e6678a6c823c76dace242dd4837f6f

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6756013fca3636e491b1662324f6c7c553aa6f6de53cbbc5beedc2fc70c4ce6e
MD5 0f0f3e1914d1c56f57d676ea5d52ae6b
BLAKE2b-256 71991d1e89822f43178d56b667f953cbea6f00c1193473a17f1bdd6b6a7f3fea

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-pp311-pypy311_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-pp311-pypy311_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 e1bd45b99fedf5f0ae55d6c56998970c7422a0d4835bb54f4070a90d86dcb67e
MD5 f457f600197599d2591373acb848216f
BLAKE2b-256 a55abaa547f16706a0b0ec4279c32305d81799566cbe83156027190456f80465

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a3f20fd692fb5d16c7880c13090e175f2d061a5123b962f84c778907770d5e61
MD5 3f14ec3db54b8bcb2dde9ef098e28021
BLAKE2b-256 fdcf54686596641d05660593f48b9ea1931ca754bfdcc6a4ab44626b5a515565

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 45048bdb49e3b4ddde703a238e0107ccd52f596130eb3ce151ced3ab929f9f88
MD5 ac283022b0d43d5717f6810cdf4f1aea
BLAKE2b-256 27abe3564888b273af9d18cc35674f341117636318c5277c7ca83906f1ec184d

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b9b865da7c32f4103ae908254ff9aa1517ec01112382de7b66c638d99932a6d
MD5 1eba601e0de017a7845e2ea9394e8200
BLAKE2b-256 9c88f0bf7747be4f44a76291f5c33342682796169ddab060f4722058b48601ab

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 999b8bfe47c170283832a639e1e01288118008b9c3c950e6a3c4689f229bc217
MD5 0da858c75464b2645c0e1d09b0d3aeaf
BLAKE2b-256 4dad589c68e971c2271a9aded58fb7b6099034e14557cebe17f5f2fd55d2ab04

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7f24cc5ac5b964c6127c030f0c79042ed6bd7cfdcccc2e594caee7edf78f4b43
MD5 fc8b94a89f9915c79400b33a3196355e
BLAKE2b-256 c4ba1d59853d31d7e90a913a5ca981a1659c61e62f6289f0fbdd58d9e0d7ed92

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a10b78402d3ba8644d8c14158ca5cac1abe7fd6f4903edbcb7e0d2dab7d8f799
MD5 cc9c98ccb69ee883c56ad6d0f2403b9a
BLAKE2b-256 a6b2e00cd8ba29f9ea717856b16842719a563afc0588f184d0b66ae9eaca422f

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 edd7554ff7c8e2ab7644eda2ab5144ee8bb01dc3ac677fbd2691a2249fee21ac
MD5 ab2a225acf473863916cd3f586d94ebe
BLAKE2b-256 3b67066689b8d8cef4d95459366184e99abc90b297cb07e23a958a05bb9841b7

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 07728a20227a1bfe565c656b5c5ed4dbf7051108183b75d3ab44a759085bab29
MD5 c1714d3d8036ea3706cebe136ed53117
BLAKE2b-256 eabff57193695219b7e25d6575a586f766d909ae8c1d4e6bda1fe33abd74c4ac

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b0f987a99d8f3a476eab55ab313e89249ba4b4bdf737b85d9ab59e14313638c
MD5 3c37460c2e60a10f38863e4d4f985480
BLAKE2b-256 9882887d86753993e12f465aeda26029c2ac6f9447e5cf68c3c9e01ba5411b9e

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 afd4112f6e8b9b5733a1ad0383b57b6177f69f7587300076adb85f2fecb06e57
MD5 40387005b45d80f35560327ea827e736
BLAKE2b-256 bd3869e74bd08c68cbd3ca98f692df2bf792518c3449b5976d479f63ce2f05a9

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 70ba4ebbac40628ef2f0a42aea96d04bdf7d5398948b80c6614ea40b43bf34e1
MD5 9d7a0156af26798088f289858e2c5868
BLAKE2b-256 be10adaf7099d35d1dcc376add2fdd606b0eb683865a7f165a5ecefffcaf2569

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 c7af0031763ff0c082f8771ad4c2a4c6228833d0c86d3042afb6f482e071fc68
MD5 908c86f01b723ffaa81326ad7d9a6490
BLAKE2b-256 d2cc9929daa555a7ca72889b67368e4328cd9bba2d259981393a4a73a95311ff

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c521f4e076bc708ae6508b4676bd0d0a2e05b4b6fe14ff25a645a1120369d7f6
MD5 c5ba3c862d7e52f820f19a6d977b25e8
BLAKE2b-256 734f78c4428b01b8a57ef633a25fcd3244401f41b994b0457a67b7c434e2b66a

See more details on using hashes here.

File details

Details for the file chess_pyspec-1.0.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for chess_pyspec-1.0.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 7cd3f87d42fcf08144e00104a6d72e5f19886cbf68fb0f7197d0dd3c543e4a90
MD5 f366cb84fab4e47a7e933b1bbba7b2e5
BLAKE2b-256 63b1d06fea06949b28b96ec44af972353d7c93dfaa03aeda42ef3628c06b07c3

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