Happi Database Access for LCLS Beamline Devices
Project description
HAPPI
Motivation • Features • Installation • Contributing • Basic Usage • Documentation
Motivation
LCLS endstations deal with dynamic sets of instrumentation. Information like
ports, triggers and aliases are all important for operation, but hard to manage
when spread across a multitude of applications. Happi solves this problem
by creating a single access point for all the metadata required to interface
with LCLS instrumentation. Using a flexible container based system Happi
allows the enforcement of specific conventions while still permitting flexible
data entry where required.
Features
- Manage information for specific device types using containers
- Input arbitrary metadata associated with a specific device
- Flexible backend support for multiple types of databases; MongoDB, JSON e.t.c
- Easily search database entries for device/s that match a set of keys
Installation
Install the most recent tagged build: conda install happi -c pcds-tag -c conda-forge
Install the most recent development build: conda install happi -c pcds-dev -c conda-forge
Contributing
Developers should check out the contributing docs.
Basic Usage
The happi.Client is your main interface to the underlying device database.
You have the choice of either creating your database backend by hand or using
the environment variable $HAPPI_BACKEND to create a persistent reference to
your database type. By default, the Client assumes a JSON file database:
import happi
client = happi.Client(path='path/to/my_db.json')
If your database has entries, you should either be able to search by key variables for individual or multiple devices.
client.find_device(name="My Device")
client.search(stand='DG2')
Once you have the device you want, you can edit the information just as you
would any other Python object. View the device information in a
convenient table using .show_info:
dev = client.find_device(name="My Device")
dev.z = 432.1
dev.show_info()
Output
+--------------+----------------------+
| EntryInfo | Value |
+--------------+----------------------+
| active | True |
| beamline | LCLS |
| name | My Device |
| parent | None |
| prefix | MY:DEV:01 |
| stand | None |
| system | None |
| z | 432.10000 |
+--------------+----------------------+
After you are satisfied with your changes, push the information back to the
database using the .save method. If this is a new device, you will have to
call Client.add_device. Before the entry is modified in the database, the
happi.Client confirms that the new changes meet all the requirements
specified by the container.
dev.save()
Command Line Interface
You can also view and manipulate device databases using the happi cli:
happi [OPTIONS] COMMAND [ARGS]...
You can try out happi commands on a simple test database as follows (this assumes you are running from the happi project root dir):
happi --path examples/example.cfg COMMAND [ARGS]
The simple test database is located at happi/examples/db.json, which is specified in example.cfg.
Please refer to the documentation for a list of possible commands and their arguments.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file happi-3.0.1.tar.gz.
File metadata
- Download URL: happi-3.0.1.tar.gz
- Upload date:
- Size: 112.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
972d9e8a57c3a2e5082316d909cd0dbb1663465a8deff2d27a37a214cee1c900
|
|
| MD5 |
8f46f3c4ab7270809ed2e37aeafa8d8e
|
|
| BLAKE2b-256 |
a10d8a41c86d5c71084e554cd5b92df482722f4e53e7f100f4569694bc9f11e1
|
File details
Details for the file happi-3.0.1-py3-none-any.whl.
File metadata
- Download URL: happi-3.0.1-py3-none-any.whl
- Upload date:
- Size: 94.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0bbf16da6935f2f892ddc78b3ebfecb7c84a6a432d1b2ed49530a6136645d7f5
|
|
| MD5 |
96c4c346853091fefdd66e2398e4055d
|
|
| BLAKE2b-256 |
ce2783314cfd4800ada7542ba49efc772c7a8949d349c7bec177e4e7fa5257e0
|