Skip to main content

save-and-restore-api

save-and-restore-api is a Python library for communicating with Save-and-Restore service (CS Studio Phoebus). The package provides syncronous (thread-based) and asynchronous (asyncio) versions of the API functions.

How to Use the Library

The following example code creates a folder node named "My Folder" under the root node:

from save_and_restore_api import SaveRestoreAPI

with SaveRestoreAPI(base_url="http://localhost:8080/save-restore") as SR:
    SR.auth_set(username="user", password="user_password")

    root_folder_uid = SR.ROOT_NODE_UID
    node={"name": "My Folder", "nodeType": "FOLDER"}

    folder = SR.node_add(root_folder_uid, node=node)

    print(f"Created folder metadata: {folder}")

Here is an async version of the same code:

from save_and_restore_api.aio import SaveRestoreAPI

async with SaveRestoreAPI(base_url="http://localhost:8080/save-restore") as SR:
    await SR.auth_set(username="user", password="user_password")

    root_folder_uid = SR.ROOT_NODE_UID
    node={"name": "My Folder", "nodeType": "FOLDER"}

    folder = await SR.node_add(root_folder_uid, node=node)
    print(f"Created folder metadata: {folder}")

save-and-restore CLI Tool

save-and-restore CLI tool is installed with the package. The tool allows performing a limited set of basic operations on the nodes of the Save-and-Restore service. The currently selected set of operations:

  • LOGIN: test login credentials;

  • CONFIG ADD: create configuration node based on a list of PVs read from a file;

  • CONFIG UPDATE: update an existing configuration node based on a list of PVs read from a file;

  • CONFIG GET: get information about an existing configuration node, including the list of PVs.

The tool was primarily developed for adding snapshot configurations to Save-and-Restore based on lists of PVs loaded from local files. Typical use case is to create a configuration based on a list of PVs read from an autosave (.sav) file saved by an IOC. Currently only autosave files are supported, but support for other formats can be added if needed. The list of supported functions can also be extended.

How to use save-and-restore CLI Tool

Check login credentials. User password is requested interactively. Alternatively, the password can be passed using environment variable `SAVE_AND_RESTORE_API_USER_PASSWORD``.

save-and-restore --base-url http://localhost:8080/save-restore --user-name=user LOGIN

Read the configuration node named 'eiger_config'. Print the full configuration data (the list of PVs):

save-and-restore --base-url http://localhost:8080/save-restore \
CONFIG GET --config-name /detectors/imaging/eiger_config --show-data=ON

Create a new configuration node named 'eiger_config'. Load the list of PVs from file eiger_pvs.sav. Automatically create any missing parent folders in the path:

save-and-restore --base-url=http://localhost:8080/save-restore --user-name=user \
--create-folders=ON CONFIG ADD --config-name=/detectors/imaging/eiger_config \
--file-name=eiger_pvs.sav --file-format=autosave

Update the existing configuration node named 'eiger_config'. Load the list of PVs from the file eiger_pvs.sav:

save-and-restore --base-url http://localhost:8080/save-restore --user-name=user \
CONFIG UPDATE --config-name /detectors/imaging/eiger_config \
--file-name eiger_pvs.sav --file-format autosave

Add new or update the existing configuration node named 'eiger_config'. Load the list of PVs from the file eiger_pvs.sav:

save-and-restore --base-url http://localhost:8080/save-restore --user-name=user \
CONFIG ADD-OR-UPDATE --config-name /detectors/imaging/eiger_config \
--file-name eiger_pvs.sav --file-format autosave

Print full list of options:

save-and-restore -h

Metadata

Release files for save-and-restore-api 0.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 save-and-restore-api 0.1.0
File Size Uploaded
save_and_restore_api-0.1.0.tar.gz 49.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for save-and-restore-api 0.1.0
File Interpreter ABI Platform
save_and_restore_api-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 73.5 kB

Release files / save_and_restore_api-0.1.0.tar.gz

Download URL save_and_restore_api-0.1.0.tar.gz
Size 49.7 kB
Tags Source
SHA-256 checksum
How to use checksums
38c868640fd6fc90a450a98bb0c7cd1ed3ecba61f17379bfb7c8b0d471f8ad93
BLAKE2b-256 checksum
How to use checksums
831a8074ea00a4bbfb99f6dd697098b922c60a02b7ae83ec1f9836f5618b28b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / save_and_restore_api-0.1.0-py3-none-any.whl

Download URL save_and_restore_api-0.1.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65971ebf822181fd66e2aef601167c8bf473ddf03830c948da26a18f4e256552
BLAKE2b-256 checksum
How to use checksums
1e68c6c96aee551bc4bcb77e100da32b9b79b0d57504d4740ed9bf1b7b3613dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

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