-
Notifications
You must be signed in to change notification settings - Fork 26
How to Run Decision Engine
To run decisionengine from the development tree or installing it via pip
please see https://github.com/HEPCloud/decisionengine/blob/master/DEVELOPMENT.md
Alternatively you can do an initial installation of decisionengine, and decisionengine_modules, using the RPMs, like operators would. Then you can build new RPMs from your code and update the installed ones.
- The initial installation must be performed as root and is documented in https://hepcloud.github.io/decisionengine/install.html (and below until the referenced document is updated)
- RPM building must happen as non privileged user and is documented in https://github.com/HEPCloud/decisionengine/blob/master/DEVELOPMENT.md
- The RPMs will be in the dist folder and can be updated by root:
rpm -U <all file names space separated>
Decision engine uses postgresql database back-end.
You need to install first postgresql and then the Decision engine framework (decisionengine) and install and add the standard channels (decisionengine_modules).
Default postgresql installed on RH7 is 9.2 which is outdated. Suggest to remove it and install 12 instead :
- Remove old PostgreSQL
# CentOS 7
yum erase -y postgresql*
# CentOS 8
dnf module -y disable postgresql
- Install postgresql 12
# CentOS 7
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y postgresql12 postgresql12-server
# CentOS 8
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
dnf install -y postgresql12 postgresql12-server
# optional, also: postgresql12-devel
- Enable postgresql
systemctl enable postgresql-12
- Init db
/usr/pgsql-12/bin/postgresql-12-setup initdb
- edit
/var/lib/pgsql/12/data/pg_hba.conf
like so:
[root@fermicloud371 ~]# diff /var/lib/pgsql/12/data/pg_hba.conf~ /var/lib/pgsql/12/data/pg_hba.conf
80c80
< local all all peer
---
> local all all trust
82c82
< host all all 127.0.0.1/32 ident
---
> host all all 127.0.0.1/32 trust
84c84
< host all all ::1/128 ident
---
> host all all ::1/128 trust
(that is setting authentication method is trust
)
- start database
systemctl start postgresql-12
- create decisionengine
createdb -U postgres decisionengine
The schema and the connection will be created and configured during the Decision engine framework installation.
To use the database you have to add it to the environment:
export PG_VERSION=12
export PATH="/usr/pgsql-${PG_VERSION}/bin:~/.local/bin:$PATH"
- Start message broker (redis)
https://github.com/HEPCloud/decisionengine/blob/master/doc/source/redis.rst
These instructions are to be executed by root for a system installation.
- Prerequisites setup. Make sure that the required yum repositories and some required packages (python3, gcc, ...) are installed and up to date.
yum install -y http://ftp.scientificlinux.org/linux/scientific/7x/repos/x86_64/yum-conf-softwarecollections-2.0-1.el7.noarch.rpm
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# gcc, swig and make are needed for dependencies (jsonnet)
yum -y install python3 python3-pip python3-setuptools python3-wheel \
gcc gcc-c++ make \
python3-devel swig openssl-devel git rpm-build
python3 -m pip install --upgrade --prefix=/usr pip
python3 -m pip install --upgrade --prefix=/usr setuptools wheel setuptools-scm[toml]
# To install the modules you will also need GlideinWMS Frontend, which is in the OSG repository.
# Assuming the use of OSG 3.5 that supports both GSI and tokens, here is a brief summary of the setup:
yum install -y yum-priorities
yum install -y https://repo.opensciencegrid.org/osg/3.5/osg-3.5-el7-release-latest.rpm
# HTCondor 8.9.x or 9.x, required by GlideinWMS, is in the osg-upcoming repository. It should be enabled to find the dependency
# GlideinWMS 3.9.x is in osg-contrib. The repository should be enabled to find the dependency
# In both the following files set: enabled=1
vi /etc/yum.repos.d/osg-upcoming.repo
vi /etc/yum.repos.d/osg-contrib.repo
# Change the Epel repository priority to make sure that comes after the OSG repositories, which are 98. Make sure that epel has:
priority=99
vi /etc/yum.repos.d/epel.repo
The complete version of the GlideinWMS installation instructions is available here A basic installation that should work is the following:
yum install glideinwms-vofrontend
Note that from 2.0 release and onwards the decisionengine_modules rpm yum install will pull in the 2 glideinwms rpms it needs plus all their dependencies and installing the top level glideinwms-vofrontend rpm separately is no longer necessary.
- Setup the decision engine yum repositories
wget -O /etc/yum.repos.d/ssi-hepcloud.repo http://ssi-rpm.fnal.gov/hep/ssi-hepcloud.repo
wget -O /etc/yum.repos.d/ssi-hepcloud-dev.repo http://ssi-rpm.fnal.gov/hep/ssi-hepcloud-dev.repo
Note the above repos are only accessible on the site of Fermilab. There is an alternative place on github to get the rpms if you are off site.
- Install the decision engine (add
--enablerepo=ssi-hepcloud-dev
for the latest development version)
yum install decisionengine
yum install decisionengine_modules
# The modules RPM was renamed. For versions <1.7 use instead
yum install decisionengine-standard-library
- Install the required Python packages (these are taken from setup.py)
# from decisionengine
python3 -m pip install jsonnet tabulate toposort structlog
python3 -m pip install wheel DBUtils sqlalchemy
python3 -m pip install pandas==1.1.5 numpy==1.19.5
python3 -m pip install "psycopg2-binary >= 2.8.6; platform_python_implementation == 'CPython'"
python3 -m pip install "psycopg2cffi >= 2.9.0; platform_python_implementation == 'PyPy'"
# from decisionengine_modules
python3 -m pip install boto3 google_auth google-api-python-client
python3 -m pip install gcs-oauth2-boto-plugin
# Condor should be already there from the RPM, if not add: python3 -m pip install htcondor
# bill-calculator-hep is only for versions >= 1.7
python3 -m pip install bill-calculator-hep
python3 -m pip install psutil
# The following are additional requirements for v1.6 and earlier
python3 -m pip install boto packaging
# This is not in pypi
python3 -m pip install https://test-files.pythonhosted.org/packages/f4/a5/17a14b4ef85bc412a0ddb771771de3f562430328b0d83da6091a4131bb26/bill_calculator_hep_mapsacosta-0.0.10-py3-none-any.whl
decisionengine --help
should print the help message
The default configuration file lives in /etc/decisionengine/decision_engine.jsonnet
.
A number of defaults are set for you.
Each datasource has its own unique schema and cannot be used with a different datasource.
The SQLAlchemy Data Source is setup with a config like:
"datasource": {
"module": "decisionengine.framework.dataspace.datasources.sqlalchemy_ds",
"name": "SQLAlchemyDS",
"config": {
"url": "postgresql://{db_user}:{db_password}@{db_host}:{db_port}/{db_dbname}",
}
}
Any extra keywords you can pass to the sqlalchemy.engine.Engine
constructor may be set under config
.
SQLAlchemy will create any tablespace objects it requires automatically.
Start the service
systemctl start decisionengine
Decision engine decision cycles happen in channels.
You can add channels by adding configuration files in /etc/decisionengine/config.d/
and restarting the decision engine.
Here is a simple test channel configuration. This test channel is using some NOP classes currently defined in the unit tests and not distributed. First, you need to copy these classes from the Git repository. You :
cd YOUR_decisionengine_REPO
# OR download the files from GitHub
mkdir /tmp/derepo
cd /tmp/derepo
wget https://github.com/HEPCloud/decisionengine/archive/refs/heads/master.zip
unzip master.zip
cd decisionengine-master
# Now copy the files
cp -r src/decisionengine/framework/tests /lib/python3.6/site-packages/decisionengine/framework/
Then, add the channel by placing this in /etc/decisionengine/config.d/test_channel.jsonnet
:
{
sources: {
source1: {
module: "decisionengine.framework.tests.SourceNOP",
parameters: {},
schedule: 1,
}
},
transforms: {
transform1: {
module: "decisionengine.framework.tests.TransformNOP",
parameters: {},
schedule: 1
}
},
logicengines: {
le1: {
module: "decisionengine.framework.logicengine.LogicEngine",
parameters: {
facts: {
pass_all: "True"
},
rules: {
r1: {
expression: 'pass_all',
actions: ['publisher1']
}
}
}
}
},
publishers: {
publisher1: {
module: "decisionengine.framework.tests.PublisherNOP",
parameters: {}
}
}
}
Restart decision engine to start the new channel
systemctl restart decisionengine
de-client --status
should sho the active test channel