Skip to main content

Welcome to NeXuS Configuration Server’s documentation!

Authors: Jan Kotanski, Eugen Wintersberger, Halil Pasic

NeXuS Configuration Server is a Tango Server with its implementation based on a MySQL database. It allows to store XML configuration datasources and components. It also gives possibility to select mandatory components and perform the process of component merging.

Tango Server API: https://nexdatas.github.io/nxsconfigserver/doc_html

Installation

Install the dependencies:

MySQLdb, PyTango, sphinx

From sources

Download the latest version of NeXuS Configuration Server from

Extract the sources and run

$ python setup.py install

To set database execute

$ mysql < conf/mysql_create.sql

with proper privileges.

Debian packages

Debian Trixie, Bookworm, Bullseye and as well as Ubuntu Resolute, Noble, Jammy packages can be found in the HDRI repository.

To install the debian packages, add the PGP repository key

$ sudo su
$ curl -s http://repos.pni-hdri.de/debian_repo.pub.gpg | gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/debian-hdri-repo.gpg --import
$ chmod 644 /etc/apt/trusted.gpg.d/debian-hdri-repo.gpg

and then download the corresponding source list, e.g. for trixie

$ cd /etc/apt/sources.list.d
$ wget http://repos.pni-hdri.de/trixie-pni-hdri.sources

Finally, for python2 packages

$ apt-get update
$ apt-get install python-nxsconfigserver nxsconfigserver-db

and the NXSConfigServer tango server (from 2.10.0)

$ apt-get install nxsconfigserver

or for python3

$ apt-get update
$ apt-get install python3-nxsconfigserver nxsconfigserver-db

and the NXSConfigServer tango server (from 2.10.0)

$ apt-get install nxsconfigserver3

From pip

To install it from pip you need pymysqldb e.g.

$ python3 -m venv myvenv
$ . myvenv/bin/activate

$ pip install pymysqldb

$ pip install nxsconfigserver

Moreover it is also good to install

$ pip install pytango
$ pip install nxstools

Setting NeXus Configuration Server

To set up NeXus Configuration Server with the default configuration run

$ nxsetup -x NXSConfigServer

The nxsetup command comes from the python-nxstools package.

Description

Configuration Server is dedicated to store NXDL-like configuration needed for Tango Data Writer runs. The server uses as a storage system a MYSQL database. To create required DB tables one can use ndts.sql script from the repository.

In Configuration Server the configuration is memorized in separate elements: datasources or components.

DataSources describe access to input data, i.e to specific hardware TANGO devices or other databases as well to client data.

Components specify Nexus tree with positions of datasets for particular pieces of hardware and writing strategy for corresponding to them data.

  • They can include datasources directly as well as links to datasources defined in the server. To this end template syntax of $datasources.<ds_name> type is used.

  • Moreover, they can holds links to other components which describe their dependences. In this case $components.<comp_name> syntax is used.

  • Finally, the components can contains variables. The variables are defined in XML code by $var.<var_name> syntax and can be provided to the Configuration Server by passing a JSON string. The default value for variables is an empty string.

All elements of configuration can be created by GUI tool - ComponentDesigner. The tool can connect to Configuration Server and fetch or store the separate elements of the XML configuration.

During creation of the final configuration Configuration Server merges all required and dependent components, connected to them datasources and provided values of the variables. As a result it returns a single XML string. This XML string can be pass directly into the dedicated Tango Data Writer attribute.

Client code

# In this section we present an example how to communicate with
# Configuration Server making use of PyTango.

import tango

cnfServer = tango.DeviceProxy("p00/xmlconfigserver/exp.01")

cnfServer.JSONSettings = \
    '{"db":"ndts_p02","read_default_file":"/etc/my.cnf","use_unicode":true}'

# opens DB connection
cnfServer.Open()

# After creating the server proxy we can set configuration for connection to
#  the MYSQL DB.
# The JSONSettings attribute is memorized so you have to write it only when you
# change configuration of DB connection. Next, we open connection to
# DB specified by our JSONSettings.



# stores default component
cpxml = open("default.xml", 'r').read()
cnfServer.XMLString = cpxml
cnfServer.StoreComponent('default')

# stores slit1 component in DB
cpxml = open("slit1.xml", 'r').read()
cnfServer.XMLString = cpxml
cnfServer.StoreComponent('slit1')

# stores slit2 component in DB
cpxml = open("slit2.xml", 'r').read()
cnfServer.XMLString = cpxml
cnfServer.StoreComponent('slit2')

# stores slit3 component in DB
cpxml = open("slit3.xml", 'r').read()
cnfServer.XMLString = cpxml
cnfServer.StoreComponent('slit3')

# stores pilatus300k component in DB
cpxml = open("pilatus.xml", 'r').read()
cnfServer.XMLString = cpxml
cnfServer.StoreComponent('pilatus300k')


# stores motor01 datasource in DB
dsxml = open("motor.ds.xml", 'r').read()
cnfServer.XMLString = dsxml
cnfServer.StoreDataSource('motor01')

# stores motor02 datasource in DB
dsxml = open("motor.ds.xml", 'r').read()
cnfServer.XMLString = dsxml
cnfServer.StoreDataSource('motor02')



# removes slit3 component from DB
cnfServer.DeleteComponent('slit3')

# removes motor02 datasource from DB
cnfServer.DeleteDataSource('motor02')

# If someone cannot use ComponentDesigner it is also an option to store
# or delete components and datasources using directly tango interface
# as it is shown above.



# provides names of available components
cmpNameList = cnfServer.AvailableComponents()
# provides names of available datasources
dsNameList = cnfServer.AvailableDataSources()

# To get information about names of available components and datasources
# in Configuration Server we use the above commands.



# provides a list of required components
cmpList = cnfServer.Components(cmpNameList)
# provides a list of required Datasources
dsList = cnfServer.DataSources(dsNameList)

# Having names of stored elements we can get their XML code.

# provides a list of Datasources from a given Component
dsList = cnf.Server.ComponentDataSources('pilatus300k')
dsList = cnf.Server.ComponentsDataSources(['pilatus300k', 'slit1'])

# as well as query Configuration Server which datasource
# are related to the particular component.

# provides a dependent components
cpList = cnf.Server.DependentComponents(['pilatus300k', 'slit3'])


# Moreover, one can also query Configuration Server for a list of
# dependent components

# provides a list of Variables from a given components
varList = cnf.Server.ComponentVariables('pilatus300k')
varList = cnf.Server.ComponentsVariables(['pilatus300k', 'slit3'])

#or ask for a list of variables which are related to the particular components.

# sets values of variables
cnf.Server.Variables = '{"entry_id":"123","beamtime_id":"123453535453"}'

#The variable values can be passed to the Configuration Server
# via a JSON string.



# sets given component as mandatory for the final configuration
cnfServer.SetMandatoryComponents(['default','slit1'])
# un-sets given component as mandatory for the final configuration
cnfServer.UnsetMandatoryComponents(['slit1'])

# provides names of mandatory components
man =  cnfServer.MandatoryComponents()

# Some of the component can be set as mandatory in
# the final configuration. To define them Configuration Server provides
# above commands.



# provides the current configuration version
version =  cnfServer.Version

# Each configuration has a revision number. It can be found
# together with Configuration Server version in Version attribute.

# creates the final configuration from slit2 and pilatus300k
# as well as all mandatory components
cnfServer.CreateConfiguration('slit2', 'pilatus300k')
# XML string ready to use by Tango Data Server
finalXML = cnfServer.XMLString

# In order to create our final configuration we execute CreateConfiguration
# command with a list of names of required components. The command merges
# these components with mandatory ones and provides the resulting NXDL-like
# configuration in the XMLString attribute.




# merges given components
mergedComp = cnfServer.Merge(['slit2', 'pilatus300k'])

# Similarly, the Merge command provides configuration by unresolved links
# to datasoures and with non-assigned variable values.


# closes connection to DB
cnfServer.close()

# Command close terminates our connection to the DB server.

Configuration Variables

Values of configuration variables can be also define inside the component xmls. Let’s consider two following components:

mydetector with a general detector transformation group

<definition>
  <group type='NXentry' name='entry'>
    <group type='NXinstrument' name='instrument'>
       <group type='NXdetector' name='$var.detector#\"mydetector\"'>
          <group type='NXtransformations' name='transformations'/>
       </group>
    </group>
  </group>
</definition>

and pilatus created for the particular detector

<definition>
  <group type='NXentry' name='entry'>
    <group type='NXinstrument' name='instrument'>
       <group type='NXdetector' name='pilatus'>
          <field type='NX_FLOAT64' name='data'/>
       </group>
    </group>
  </group>
  <doc>$var(detector=pilatus)</doc>
</definition>

Creating configuration without variables

cnfServer.Variables = '{}'
cnfServer.CreateConfiguration(["mydetector"])

results in

<definition>
  <group type='NXentry' name='entry'>
    <group type='NXinstrument' name='instrument'>
       <group type='NXdetector' name='mydetector'>
          <group type='NXtransformations' name='transformations'/>
       </group>
    </group>
  </group>
</definition>

When configuration variables are defined

cnfServer.Variables = '{"detector": "det1"}'
cnfServer.CreateConfiguration(["mydetector"])

one can get

<definition>
  <group type='NXentry' name='entry'>
    <group type='NXinstrument' name='instrument'>
       <group type='NXdetector' name='det1'>
          <group type='NXtransformations' name='transformations'/>
       </group>
    </group>
  </group>
</definition>

Finally, creating configuration xml from our two components without variables

cnfServer.Variables = '{}'
cnfServer.CreateConfiguration(["mydetector", "pilatus"])

results in

<definition>
<group name="entry" type="NXentry">
  <group name="instrument" type="NXinstrument">
    <group name="pilatus" type="NXdetector">
      <group name="transformations" type="NXtransformations"/>
      <field name="data" type="NX_FLOAT64"/>
      </group>
    </group>
  </group>
  <doc>$var(detector=pilatus)</doc>
</definition>

Metadata

Release files for nxsconfigserver 2.24.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 nxsconfigserver 2.24.0
File Size Uploaded
nxsconfigserver-2.24.0.tar.gz 114.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nxsconfigserver 2.24.0
File Interpreter ABI Platform
nxsconfigserver-2.24.0-py3-none-any.whl Python 3 none any Details

Total release size: 147.8 kB

Release files / nxsconfigserver-2.24.0.tar.gz

Download URL nxsconfigserver-2.24.0.tar.gz
Size 114.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e12d68e9732872459b8a35a93e7cb3dd1dddfb0fa0657b99050589edf761ffdd
BLAKE2b-256 checksum
How to use checksums
aa070f8e9db220c28390c85ba78a6806a0cc82e0c67c61c468cd11125f0b50ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / nxsconfigserver-2.24.0-py3-none-any.whl

Download URL nxsconfigserver-2.24.0-py3-none-any.whl
Size 33.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b61b1a447fa808877879710e27579ab1788bdea67a5a20ac8b432940d3ef7c4
BLAKE2b-256 checksum
How to use checksums
28a2ad9c1885d0a5777805b79f99958ec60545b5a3be1cbecd894e105380dd3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

2.25.0

1 release file

This release

2.24.0 This release

2 release files

2.23.0

2 release files

2.21.2

2 release files

2.21.1

2 release files

2.20.0

2 release files

2.19.0

2 release files

2.18.1

2 release files

2.18.0

2 release files

2.17.0

2 release files

2.15.0

2 release files

2.14.2

2 release files

2.14.1

2 release files

2.14.0

2 release files

2.13.2

2 release files

2.13.1

1 release file

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