Prerequisites: Install uv (see the uv installation instructions
)
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.server.MemoryCacheDatabase",
loglevel="info",
)To use FlatfileCacheDatabase, update the setup file as follows:
DB=device(
"nicos.services.cache.server.FlatfileCacheDatabase",
storepath="/opt/nicos-data/cache",
loglevel="info",
)For Redis-based caching, RedisCacheDatabase, configure as follows:
DB=device(
"nicos.services.cache.server.RedisCacheDatabase",
loglevel="info",
)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. 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 pingClone 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