This is the developer/maintainer guide for fusionpipe
.
fusionpipe
is lightwise pipeline orchestrator to help organise data-analysis, simulation, machine learning pipelines. It is composed by the following components:
- Frontend in Svelte.
- FASTAPI web-app as backend.
- A postgresSQL database which is used
With the current guidelines fusionpipe
This guide has different level of complexity depending on what is your role an your deployment solution:
- user (without installation): In case you are only using
fusionpipe
which is already set-up by your IT, refer to the user guide - user (with installation): In case you would like to run
fusionpipe
locally on your device and use it. This is the same set-up as for the maintainer. If you are the only user, the installation is simplified. - developer: In this case you would like to contribute to the development of
fusionpipe
. You will have some special command to run the different systems in debugging mode. It is expected that in this set-up you will be developing the application as a single user. - maintainer: If you are a maintainer of
fusionpipe
, you are deploying fusion for yourself and potentially other users. In case you will have multiple users using the service, you will need some extra set-up to grant the necessary permission to the different users.
Some operation during the installation process will require to have sudo access. Reach out to your admin if needed. The operation that requires sudo are:
- Setting up
postgresSQL
- Grant access to
docker
group to your user. - Extend permission r/w permission if setting up the deployment for multiple users.
- Networking in case you are deploying the solution on a server which firewall and port restriction.
In summary fusionpipe
has the following things to be set-up:
- Svelte application
- FAST-API backend
- PostgresSQL database
In case of multiple users installation, also the following needs to be set-up.
- Shared access folder for the data.
- Shared access folder for the
uv
caching folder environment. - Shared access for the user API utilities folder.
Prerequistes
Postgres
PostgreSQL is used as a database to keep track of the relation between nodes and pipeline and other metadata. - Set-up postgres in your local machine. - Use docker to set up postgres.
local installation (need sudo)
-
Install postgres
-
Initialise postgtes
sudo /usr/bin/postgresql-setup --initdb
Usually postgres is initialised creating the OS user postgres
, which serves as admin the database operation.
The default set-up for postgres to check the OS user, to grant access to the database (peer
option).
In this condition, in order to perform admin operation on the database, you need to log as postgres
user (requires sudo access).
It is possibile to change the postgres authentication defualt, changing the file pg_hba.conf
usually found in the location
/var/lib/pgsql/data/pg_hba.conf
. Changing peer
to md5
will ask for password authentication at the login instead of
After changing the authorisatio, reload postgres
docker installation
- TO BE UPDATED *
Set the env variable.
-
Modify the variables into the
developer.env
file. -
Navigate the docker folder
-
Set up the variables in
docker-compose-psg.yml
. See documentation in the file. - If you already have a database and you want to remove all the data related to it, delete the folder with the database location. Otherwise, to continue with the existing database, skip this step.
- Run the docker compose command to start the postgres database.
This will startup yuor postgres database in a docker container, and expose to the port specified in the
docker-compose-psg.yml
file.
Test connection
UV package manager
UV package manager is the solution used to in order to deal with python packages.
Set-up the database
The following commands needs to be run from the OS user postgres
which has all the access.
It is assumed that there is a priviledge OS user, which is the maintainer/developer for fusionpipe
in your machine.
There are different possibilities for that.
- If you are the only user/developer, use your user as admin.
- If you are the maintainer for fusionpipe on a server, we recommend to create an OS user which will manage the
fusionpipe
installation. We will assume this user to be to be calledfusionpipeadmin
in the following.
The following opeartion must be done in the order they are presented
-
Log in as
postgres
user in your machine -
Create the database
-
Check that the database has been created
-
Create a ROLE which will be able to modify the database. User will be added to this role
-
Grant connection to the role
fusionpipeusers
-
Grant usage to the role
fusionpipeusers
-
As we want only the admin user to have the possibility to create table in the datanase, revoke some access access to other users.
-
Grant the possibility to the ROLE
fusionusers
to be modify the table in the database. -
Grant the possibiliy to possibility to create tables to the
fusionpipeadmin
. -
Extend the priviledges of
fusionpipeusers
tofusionpipeadmin
. When you addfusionpipeadmin
to thefusionpipeusers
role in PostgreSQL:
This extends the permissions of fusionpipeadmin
to include all privileges granted to fusionpipeusers
. The fusionpipeadmin
will retain its own privileges and additionally inherit those of fusionpipeusers
. It does not restrict fusionpipeadmin
to only the permissions of fusionpipeusers
; instead, it is a superset of both.
- The following command updates the default privileges for tables created in the
public
schema of thefusionpipe_prod1
database. It ensures that any new tables will automatically grantSELECT
,INSERT
,UPDATE
, andDELETE
permissions to thefusionpipeusers
role. Run this command as thefusionpipeadmin
user:
Create and initialise the required tables for database
⚠️ WARNING: The following operations will modify your PostgreSQL database. Ensure you have backed up any important data before proceeding. Only users with the appropriate privileges should perform these actions.
The database needs to be initialised with the tables for the fusionpipe
application. Given the role that have been granted in the previous step, only the fusionpipeadmin
user is able to create this.
-
Add to the
.bash_profile
offusionpipeadmin
user. This will allow thefusionpipeuser
to connect to the database throughpeer
connection. (See postgres SQL documentation). -
Initialise the tables in the database. This is conveniently done runnig the script.
Create data folder and extend R/W access for multiple users
- Create the folder that will contain application data for
fusionpipe
data application.
The following steps are only needed if you are setting-up fusionpipe
for multiple users to have access to your machine.
If you are single developer, or single user you can skip them.
-
Create a group. This way you will be able to control the user access to data based on the group.
-
Log out and log in again to allow the propagation of the new group.
-
Add
fusionpipeadmin
admin user to the group -
Log out and log in every time you add a new user.
-
Set group permission permission to the shared data folder
-
Enforce Permissions with ACLs. This will let other user to write on files generated by other users, independently of the user mask.
The second special folder is the one containing the user utility scripts. This needs to be (only) readable by all users offusionpipe
. -
Login with
fusionpipeadmin
in the folder containing the source code of fusion pipe. - Grant reading access to the group
fusionpipeusers
Set enviroment variables
If you are the maintainer or single developer user, we recommend to collect all your environment variables into a single file <myenvfile>.env
.
Careful with the syntax, .env
file does not allow for spaces in the definition definition of the environment variables. The strings needs to be withing ""
and not ''
.
The full set of environment variables needed to run all services of fusionpipe
are:
FUSIONPIPE_DATA_PATH="<absolute/path/to/fusionpipe/data/folder>"
UV_CACHE_DIR="<absolute/path/to/uv/cache/dir>"
DATABASE_URL="dbname=<database_name> port=<postgres_port>"
BACKEND_HOST="localhost"
BACKEND_PORT=<backend_port>
VITE_BACKEND_PORT=${BACKEND_PORT}
VITE_BACKEND_HOST=${BACKEND_HOST}
VITE_FRONTEND_PORT=<frontend_port>
VITE_FRONTEND_HOST="localhost"
USER_UTILS_FOLDER_PATH="<absolute/path/to/user/utils>"
FP_MATLAB_RUNNER_PATH="<abosolute/path/to/matlab/executable>"
VIRTUAL_ENV="<(optional) default virtual env to activate when running the backend>"
DATABASE_URL_TEST="dbname=<database_test_name> port=<postgres_port>"
In the following some explanation of the different environment variables:
<absolute/path/to/fusionpipe/data/folder>
: Data fromfusionpipe
will be stored in this folder.<absolute/path/to/uv/cache/dir>
: This will contain the cache for the uv environment.<database_name>
: The database name that you have created in previous steps.<postgres_port>
: The port where postgresSQL is avilable in your host. Defaulat 5432<backend_port>
: Port for the FAST-API backend. We recommend to user a port >8000<frontend_port>
: This is the port for Svelte frontent. Usually Svelte is using a port >5000<absolute/path/to/user/utils>
: This is the absolute path where the user utilities, which needs to be readable by all users, are stored.<abosolute/path/to/matlab/executable>
: It is conveninet to set-up the path to your local installation of matlab if you are considering using it for development.<database_test_name>
: The database name used for the test suite. Usuallyfusionpipe_test
.
Run the frontend and backend (developer mode)
-
Open a new terminal
-
Set the environment variable for the terminal. You can set all the variables from your env file with the command.
-
Navigate the backend folder
-
Start the backend service
-
Open a new terminal
-
Set the environment variable as above also in this terminal
-
Navigate the frontend folder
-
Start the Svelte application in debug mode
-
Open the browser at the port where the frontend is served. For example
If your are developing the application and your environment variables are not change, you can consider to add them in your .bashrc
or .bashrc_profile
in order to have them loaded directly when you log with your user.
Compile the frontend and serve
If you want to compile the frontend
You need to set the environment variable before building the app as the environemtn variable will be backed in the app
Run the frontend and backend (production)
Run fusionpipe in as systemd (Need review not fully working at the moment)
-
Save the enviroment variable file in location, hidden from the user and protect it.
-
Create the user systemd service directory (if it doesn’t exist):
-
Write
systemd
configuration file~/.config/systemd/user/fusionpipe_backend.service
[Unit] Description=Run the backend [Service] Type=simple WorkingDirectory=/home/fusionpipeadmin/Documents/fusionpipe/src/fusionpipe/api EnvironmentFile=/home/fusionpipeadmin/Documents/environment/production.env ExecStart=/home/fusionpipeadmin/Documents/fusionpipe/.venv/bin/uv run python main.py Restart=on-failure [Install] WantedBy=default.target
-
Write
systemd
configuration file~/.config/systemd/user/fusionpipe_frontend.service
[Unit] Description=Run fusionpipe frontend [Service] Type=simple EnvironmentFile=/home/fusionpipeadmin/Documents/environment/production.env WorkingDirectory=/home/fusionpipeadmin/Documents/fusionpipe/src/fusionpipe/frontend ExecStart=npx serve -s dist -l $VITE_FRONTEND_PORT Restart=on-failure [Install] WantedBy=default.target
-
Reload the deamon
-
Enable and start the backend
-
Enable and start the frontend
-
Let the user systemd be run when the user disconnect
-
Stop services
-
kill processes if they don't stop by themselves.
Upgrade the production version
- Login with the `fusionpipe
- Navigate the
fusionpipeadmin
user. - Pull the desired version of fusionpipe
-
Stop services
-
Navigate the frontend folder
-
Set the environment variable from from your production env. See section above
-
Recompile the frontend
-
Start the systemd services
-
Check that the services are working properly
Onboard a new user
- Create new user with
<newusername>
in postgres
psql -U postgres -d fusionpipe_prod1 -c "CREATE USER <newusername>;"
- Grant user access to role
fusionpipeusers
in postgres database
psql -U postgres -d fusionpipe_prod1 -c "GRANT fusionpipeusers TO <newusername>;"
- Ask user to write the following line in the
.profile
or.bashrc_profile
, in order to persist the access to the database when it log in.
-
Write the location of the user utils in the
.profile
,.bashrc_profile
. -
Add user to the group in the server, in order for him to have access to the shared repository
User set-up
-
Communicate the username to the admin
-
Install
uv
-
ssh to the machine and forward the port with the frontend and backend. Ask admin to tell the port used for deployment.
-
Write the following line in the
.profile
. This allows the user to have access to the database -
Write the location of the user utils in the
.profile
-
When switching to a node run, if you want to user jupyter notebooks, run the following command to initialise the python kernel.
Set up docker at system level. (require sudo)
Or ask your admin to do that for you.
Start docker service at system level
Add your user to docker
Re-start your user session, and check your user is in the docker group
Check if docker compose is installed
Otherwise install it with
Docker can load many images, that can occopy space in your disk. You might want to consider to set the location where docker images are saved.