Skip to main content

dsconfig-wrapper

pipeline status coverage report

This is a small Python library to complement MAX IV's excellent dsconfig library, which can make the database for the Tango controls system declarative by updating it from a JSON file.

Usually, it looks like this:

flowchart TD
    DatabaseDs[(Tango Database)]
    DatabaseDs -->|dsconfig.dump| JsonFile[JSON file]
    Human -->|vim/emacs| JsonFile
    JsonFile -->|json2tango| DatabaseDs

With this tool, it looks like this:

flowchart TD
    DatabaseDs[(Tango Database)]
    Human -->|vim/emacs| PythonFile[Python file]
    DsconfigWrapper[dsconfig-wrapper] -->|import| PythonFile
    PythonFile -->|dsconfig-wrapper| JsonFile
    JsonFile -->|json2tango| DatabaseDs

This way, we can have our configuration not in JSON, but in Python! And in Python, we can have, for instance, argparse, to create a little program that can generate a configuration with parameters. You can also use Python DRY elements in your configuration (say, you have the same motor, but with various different properties set).

Usage

Just do

pip install dsconfig-wrapper

and then use it to create a config JSON. Example:

test_servers = [
    Server(
        instance_name="my_instance_name",
        class_name="my_class_name",
        devices=[
            Device(
                identifier=Identifier(
                    domain="my_domain",
                    family="my_family",
                    member="my_member",
                    host="my_host:10000",
                ),
                properties={
                    "prop_str": "strvalue",
                    "prop_list_str": ["value1", "value2"],
                    "prop_list_int": [2000, 3000],
                    "prop_int": 2000,
                },
                polled_commands={"update": 1000},
                attribute_properties={
                    "State": AttributeProperties(archive_period_ms=1001),
                    "velocity_mm_per_s": AttributeProperties(
                        archive_abs_change=(-0.5, 0.5),
                        archive_period_ms=5000,
                        rel_change=(-0.05, 0.05),
                    ),
                },
            )
        ],
    )
]
test_config = Config(servers=test_servers)
print(config_to_json(test_config))

Here, we create a config for a device server with class my_class_name and one instance running at tango://myhost:10000/my_domain/my_family/my_member. The update command is polled every second, and we also set some properties and attribute properties.

We now run this program (say it's stored in main.py) and pipe it into dsconfig:

python main.py | json2tango

Voila!

Metadata

Release files for dsconfig-wrapper 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dsconfig-wrapper 1.1.0
File Size Uploaded
dsconfig_wrapper-1.1.0.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dsconfig-wrapper 1.1.0
File Interpreter ABI Platform
dsconfig_wrapper-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.4 kB

Release files / dsconfig_wrapper-1.1.0.tar.gz

Download URL dsconfig_wrapper-1.1.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
03c35c7a1896c6cdc35bb532b9c25a200acc0ad6b01cc8d628974d388c0609b2
BLAKE2b-256 checksum
How to use checksums
71169558ce281b566e0f1e1d75600f752994157e278cfaa6f682ed451eb5e505
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.0 CPython/3.10.12 Linux/6.1.47

Release files / dsconfig_wrapper-1.1.0-py3-none-any.whl

Download URL dsconfig_wrapper-1.1.0-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41ba2cd8b8055007978570f631c07743bb70398afb10e5d820f77d855068fc87
BLAKE2b-256 checksum
How to use checksums
66fe174f693216ed47a5e53eab73d0a5e47a13b79fa5421f1a5e773debf295fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.3.0 CPython/3.10.12 Linux/6.1.47

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page