Prerequisites:
- Install
uv(see the uv installation instructions) - Install necessary system packages:
- on RHEL-based systems:
dnf install pkgconf-pkg-config systemd-devel - on Debian-based systems:
apt install build-essential python3-dev libsystemd-dev pkg-config
- on RHEL-based systems:
- For the GUI, you will need some native libraries installed:
- on RHEL-based systems:
dnf install python3-qt5 - on Debian-based systems:
apt install qtbase5-dev qtwebengine5-dev
- on RHEL-based systems:
Some useful uv commands:
uv python list: show available Python versions (both system-wide and those managed by uv).
uv tree: print a dependency tree of the current project.
uv run: execute a command from the current project.
uv venv: create a virtual environment.
Inside the repository, first use uv sync to create a local virtual environment with the specific packages and extras you want:
uv sync --all-packages --extra gui
This will build all packages (use --package for specific packages or leave out for only the core) and install all dependencies including the gui optional ones.
After this, run:
% uv run | grep nicos
- designer-nicos
- nicos-aio
- nicos-cache
- nicos-client
- nicos-collector
- nicos-daemon
- nicos-demo
...
% uv run nicos-gui
to start any of the scripts directly. Note that you will have to prefix these commands when mentioned in the sections below with uv run.
You can also install NICOS into the uv managed tools to have its commands available inside your PATH:
uv tool install nicos
- run
uv buildfrom the package root directory to build (only) the core package. - run
uv build --package <name>to build a specific package, e.g.nicos_demo. - run
uv build --all-packagesto build all available packages.
The resulting source tarball and wheel files will be located in the dist directory.
Place the NICOS configuration file (nicos.conf) for your choice of instrument into one of the following locations, searched in order:
- in the site-wide directory, i.e.
/etc/xdg/nicos/nicos.confon GNU/Linux, or - the
nicosdirectory in your standard user configuration path, i.e. on GNU/Linux systems, this would be~/.config/nicos/nicos.conf.
Both these paths can be modified by setting the XDG_CONFIG_DIRS or XDG_CONFIG_HOME environment variable, respectively, to point to a different location.
See the corresponding XDG variable documentation for reference.
For backwards compatibility, the nicos_root folder (i.e. the root of the repository) will be searched first.
When NICOS has been deployed as package, this path would most likely not point to a suitable location.
Therefore, prefer the XDG standard directories as place for nicos.conf
To set up the NICOS server on your local machine, follow these steps.
Follow one of the described methods above to install NICOS locally.
Note that confluent-kafka requires librdkafka, which may result in this step failing if the wheel needs to be built in your environment
Create a directory for storing NICOS data:
mkdir /opt/nicos-dataNote: This may require sudo rights. Ensure the directory has the correct ownership.
Link the configuration file for your chosen instrument or copy it at the location described in the section "Configure NICOS" above:
ln -s nicos_ess/<instrument>/nicos.conf ~/.config/nicos/nicos.confA good starting instrument is ymir, which is a test instrument.
Start the NICOS cache server:
nicos-cacheTo configure what cache database to use, see section Configure Cache Database.
In a separate terminal, start the NICOS poller:
nicos-pollerIf required, start the NICOS collector in another terminal:
nicos-collectorFinally, in another terminal, start the NICOS daemon:
nicos-daemonInstall the necessary packages for the NICOS GUI by following the installation instructions above.
Start the NICOS client with your selected instrument's configuration:
nicos-gui -c nicos_ess/<instrument>/guiconfig.pyIf you prefer QT6, use the following command (not required on macOS with silicon architecture):
NICOS_QT=6 ./bin/nicos-gui -c nicos_ess/<instrument>/guiconfig.pyNICOS supports different cache databases. You can use MemoryCacheDatabase, FlatfileCacheDatabase, or RedisCacheDatabase. For local development, MemoryCacheDatabase or FlatfileCacheDatabase are easiest to set up.
Edit the cache.py setup file to choose your cache database:
vim nicos_ess/<instrument>/setups/special/cache.pyNo changes needed if you are using the default MemoryCacheDatabase:
DB=device(
"nicos.services.cache.database.MemoryCacheDatabase",
loglevel="info",
)To use FlatfileCacheDatabase, update the setup file as follows:
DB=device(
"nicos.services.cache.database.FlatfileCacheDatabase",
storepath="/opt/nicos-data/cache",
loglevel="info",
)For Redis-based caching, RedisCacheDatabase, configure as follows:
DB=device(
"nicos.services.cache.database.RedisCacheDatabase",
historydays=14,
# Flat numeric tuples, lists and dictionaries up to this size use native
# RedisTimeSeries component series.
maxnativecomponents=50,
# Serialized text and mixed or larger structures are not archived by
# default. Set a short retention period here to opt in.
arbitraryhistorydays=None,
loglevel="info",
)historydays controls native RedisTimeSeries retention for scalar numbers and
flat, fully numeric tuples, lists and dictionaries. maxnativecomponents limits
how many component series one value may create. Device status is treated
separately: its numeric status code is archived natively while its descriptive
text remains part of the current value. If a native structure changes shape or
container type at runtime, its existing component history is replaced so that
older samples cannot be reconstructed with the wrong layout.
The separate arbitraryhistorydays setting controls serialized history for
text, mixed structures and numeric structures above the native component limit;
None disables it, 0 keeps it indefinitely, and a positive value retains
that many days. Current values are stored regardless of the history setting.
When arbitrary history is disabled, its old history keys are removed the next
time that value is reported. Each report with a new timestamp is archived even
if its value is unchanged.
In the case of RedisCacheDatabase, you need to set up Redis and RedisTimeSeries. See section Redis Setup for instructions.
To set up your environment for development, install the additional required packages:
pip install -r requirements-dev.txtInstall the pre-commit hook to ensure code quality:
pre-commit installThis section guides you through installing Redis, an in-memory data store, and RedisTimeSeries, a module for time-series data processing. With Redis versions lower than version 8, the RedisTimeSeries module is mandatory.
The instructions are for Linux systems (tested on ubuntu 22.04 and CentOS 7). For other operating systems, refer to the Redis and RedisTimeSeries documentation.
Download and extract the Redis package:
wget http://download.redis.io/releases/redis-6.2.14.tar.gz
tar xzf redis-6.2.14.tar.gz
cd redis-6.2.14Compile the Redis source code:
makeOptional but recommended: Run tests to ensure Redis is functioning correctly.
make testInstall Redis on your system:
sudo make installCreate a directory for the Redis configuration file:
sudo mkdir /etc/redisCopy the default configuration file:
sudo cp redis.conf /etc/redis/redis.confOpen the configuration file to apply necessary settings:
sudo vim /etc/redis/redis.confIMPORTANT: Ensure Redis is bound to localhost for security:
bind 127.0.0.1 ::1
protected-mode yes
supervised systemd
dir /var/lib/redisCreate a service file to manage Redis with systemd:
sudo vim /etc/systemd/system/redis.servicePaste the following configuration, replacing nicos with your username (on the nicosservers, it's nicos):
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=nicos
Group=nicos
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.targetCreate and set permissions for the Redis data directory:
sudo mkdir /var/lib/redis
sudo chown nicos:nicos /var/lib/redis
sudo chmod 770 /var/lib/redisEnable and start the Redis service:
sudo systemctl enable redis
sudo systemctl start redisOptionally, check the status to ensure Redis is running smoothly:
sudo systemctl status redisFind the Redis CLI tool:
sudo find / -name redis-cliAdd Redis binaries to your system PATH:
vim ~/.bashrc
export PATH=$PATH:/usr/local/bin
source ~/.bashrcTest that Redis is installed and running correctly:
redis-cli pingNote: Starting with Redis 8, the Time Series data structure is integral to Redis. If you have installed a Redis version equal or higher to 8, you don't need to install this module separately.
Clone the RedisTimeSeries repository:
git clone --recursive https://github.com/RedisTimeSeries/RedisTimeSeries.git -b v1.8.10
cd RedisTimeSeriesSet up the environment and build the module:
./sbin/setup
bash -l
makeCopy the RedisTimeSeries module to the appropriate directory:
cp RedisTimeSeries/bin/linux-x64-release/redistimeseries.so /etc/redis/redistimeseries.soTo load the RedisTimeSeries module, add this line to redis.conf:
loadmodule /etc/redis/redistimeseries.soRestart Redis to apply changes:
sudo systemctl restart redisCheck that the RedisTimeSeries module is loaded correctly:
redis-cli MODULE LIST