### Initial Project Setup and Run Source: https://github.com/fnndsc/chris_ultron_backend/blob/master/README.md Clones the ChRIS Ultron Backend repository and starts the development environment using 'just'. This is the primary command for getting the backend running. ```shell git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd.git cd ChRIS_ultron_backEnd just ``` -------------------------------- ### Start Vagrant Environment Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Vagrant-Setup-OSX Initiates the Vagrant virtual machine, provisioning it with the necessary software and configurations. This process can take a significant amount of time due to software installations. ```shell $ vagrant up ``` -------------------------------- ### Setup Python Environment and Services Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Workflow-notes Steps to set up the Python virtual environment, activate it, and start the Django and pman services required for the ChRIS Ultron backend. ```bash export WORKON_HOME=~/src/python-env source /usr/local/bin/virtualenvwrapper.sh workon chris_env cd ~/src/ChRIS_ultron_backend/chris_backend manage.py runserver localhost:8000 pman --rawmode 1 --http --port 5010 --listeners 12 ``` -------------------------------- ### Certbot Installation and HTTPS Setup Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Deployment Installs Certbot and the Apache plugin on Ubuntu, then uses Certbot to automatically obtain SSL certificates and configure Apache for HTTPS. ```bash # install (on Ubuntu) sudo apt install certbot python3-certbot-apache # enable HTTPS using magic. gets certs and write apache configs sudo certbot --apache ``` -------------------------------- ### Start Orthanc Instance Source: https://github.com/fnndsc/chris_ultron_backend/wiki/PACS-Pull-wokflow Command to start the Orthanc server. After starting, access the web interface to upload DICOM data. ```shell ~/work/orthancAndPluginsOSX.stable$ ./startOrthanc.command ``` -------------------------------- ### CLI API Request Example Source: https://github.com/fnndsc/chris_ultron_backend/blob/master/README.md Demonstrates making an HTTP request to the ChRIS API using the 'xh' tool and processing the JSON response with 'jnv'. Requires 'xh' and 'jnv' to be installed. ```shell xh -a chris:chris1234 :8000/api/v1/ | jnv ``` -------------------------------- ### Apache VirtualHost Basic Example Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Deployment A basic Apache VirtualHost configuration combining reverse proxy for API requests and serving a static front-end SPA from a specified DocumentRoot. ```apache ServerName chrisstore.co ProxyPass "/api" "http://localhost:8010/api" ProxyAddHeaders On # this is the default anyways RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME} DocumentRoot /var/src/ChRIS_store_ui/build ErrorLog ${APACHE_LOG_DIR}/chrisstore.error.log CustomLog ${APACHE_LOG_DIR}/chrisstore.access.log combined ``` -------------------------------- ### ChRIS Ultron Backend Setup and Environment Variables Source: https://github.com/fnndsc/chris_ultron_backend/wiki/2.4.2-ChRIS-FS--DS--DS-plugin-worflow-summary-[moc] Commands to clone the ChRIS Ultron backend repository, perform initial setup, and set essential environment variables for API interaction. ```bash git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd cd ChRIS_ultron_backEnd *destroy* ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS ; *make* -U -I -s export HOST_IP=$(ip route | grep -v docker | awk '{if(NF==11) print $9}') export HOST_PORT=8000 ``` -------------------------------- ### Install Sphinx Dependencies Source: https://github.com/fnndsc/chris_ultron_backend/blob/master/README.md Installs Sphinx and the sphinxcontrib-httpdomain package, which is useful for documenting REST APIs within Sphinx documentation. These are prerequisites for building HTML documentation. ```shell pip install Sphinx pip install sphinxcontrib-httpdomain ``` -------------------------------- ### Start Django Development Server Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Vagrant-Setup-OSX Starts the Django development server, making the ChRIS-ultron-backend application accessible. It listens on all network interfaces on port 8000. ```shell (chris-ultron)$ python manage.py runserver 0.0.0.0:8000 ``` -------------------------------- ### Install Vagrant Guest Additions Plugin Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Vagrant-Setup-OSX Installs the `vagrant-vbguest` plugin, which ensures VirtualBox guest additions are installed and updated within the Vagrant VM. This is crucial for proper folder sharing and integration. ```shell $ vagrant plugin install vagrant-vbguest ``` -------------------------------- ### Install HTTPie and Swift Client Source: https://github.com/fnndsc/chris_ultron_backend/wiki/1.2-ChRIS-FS-plugin-workflow:-upload-files-to-CUBE-and-create-a-new-top-level-feed-(pl-pacscopy) Installs the httpie and swift command-line tools, which are dependencies for pushing data to CUBE storage. ```bash pip install httpie pip install swift ``` -------------------------------- ### Install Required Python Packages Source: https://github.com/fnndsc/chris_ultron_backend/wiki/2.4-ChRIS-FS--DS--DS-plugin-worflow:-simulate-a-FreeSurfer---MPC---heatmap-workflow Installs the 'httpie' and 'swift' Python packages, which are command-line applications used for interacting with the CUBE API and swift storage respectively. ```bash pip install httpie ``` ```bash pip install swift ``` -------------------------------- ### ChRIS API: GET Homepage Source: https://github.com/fnndsc/chris_ultron_backend/wiki/0.-ChRIS-preliminary-workflow:-intro Fetches the root endpoint of the ChRIS API to get general system information and available links. It uses 'pfurl' with authentication and specifies pretty-printing for the JSON output. ```bash pfurl --auth chris:chris1234 --verb GET --raw --http ${HOST_IP}:8000/api/v1/ \ --quiet --jsonpprintindent 4 ``` ```javascript { "collection": { "items": [ ], "links": [ { "href": "http://10.17.24.163:8000/api/v1/tags/", "rel": "tags" }, { "href": "http://10.17.24.163:8000/api/v1/plugins/", "rel": "plugins" } ], "queries": [ { "data": [ { "name": "name", "value": "" }, { "name": "min_id", "value": "" }, { "name": "max_id", "value": "" }, { "name": "min_creation_date", "value": "" }, { "name": "max_creation_date", "value": "" } ], "href": "http://10.17.24.163:8000/api/v1/search/", "rel": "search" } ], "version": "1.0", "href": "http://10.17.24.163:8000/api/v1/" } } ``` -------------------------------- ### Instantiate CUBE Backend Source: https://github.com/fnndsc/chris_ultron_backend/wiki/2.4.1-ChRIS-FS--DS--DS-plugin-worflow-summary Steps to clone the ChRIS_ultron_backEnd repository, navigate to the directory, and prepare the environment by destroying existing configurations and making the system. It emphasizes skipping unit and integration tests. ```bash git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd cd ChRIS_ultron_backEnd *destroy* ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS ; *make* -U -I -s ``` -------------------------------- ### Monitor Plugin Instance Status with pfurl Source: https://github.com/fnndsc/chris_ultron_backend/wiki/5.-ChRIS-plugin-geretrieve This example shows how to poll the status of a plugin instance using pfurl. It retrieves the instance details via a GET request to the API, allowing users to check if a plugin has finished successfully. ```bash pfurl --auth chris:chris1234 \ --verb GET --http ${HOST_IP}:8000/api/v1/plugins/instances/1/ \ --content-type application/vnd.collection+json \ --quiet --jsonpprintindent 4 ``` -------------------------------- ### Clone and Navigate ChRIS Backend Source: https://github.com/fnndsc/chris_ultron_backend/wiki/2.4-ChRIS-FS--DS--DS-plugin-worflow:-simulate-a-FreeSurfer---MPC---heatmap-workflow Clones the ChRIS_ultron_backEnd repository from GitHub and navigates into the project directory. This is the initial setup step for working with the CUBE backend. ```bash git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd cd ChRIS_ultron_backEnd ``` -------------------------------- ### Apache Reverse Proxy Configuration Example Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Deployment Conceptual setup for Apache to serve ChRIS_store_ui on the root domain and its backend API on the /api/v1/ path, assuming a single server with a specific domain name. ```apache # Example Apache configuration for ChRIS_store # Assumes: Backend on http://127.0.0.1:8010/api/v1/ # ChRIS_store_ui cloned to /var/src/ChRIS_store_ui # Domain name chrisstore.co points to server IP ServerName chrisstore.co SSLEngine on SSLCertificateFile /path/to/your/certificate.crt SSLCertificateKeyFile /path/to/your/private.key # Serve ChRIS_store_ui (SPA) DocumentRoot /var/src/ChRIS_store_ui Options Indexes FollowSymLinks AllowOverride All Require all granted # For SPA routing, rewrite all non-file requests to index.html RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.html [L] # Proxy API requests to the backend ProxyPass /api/v1/ http://127.0.0.1:8010/api/v1/ ProxyPassReverse /api/v1/ http://127.0.0.1:8010/api/v1/ ErrorLog ${APACHE_LOG_DIR}/chrisstore.error.log CustomLog ${APACHE_LOG_DIR}/chrisstore.access.log combined # Redirect HTTP to HTTPS ServerName chrisstore.co Redirect permanent / https://chrisstore.co/ ``` -------------------------------- ### Create a Plugin via API Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Vagrant-Setup-OSX Demonstrates creating a new plugin resource using an HTTP POST request to the ChRIS-ultron-backend API. It uses `httpie` for making the request and basic authentication. ```shell $ brew install httpie $ http -a chris:Chris1234 POST http://127.0.0.1:8001/api/v1/plugins/ Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json template='{"data":[{"name":"name","value":"Feed1"}, {"name":"plugin","value":1}, {"name":"type","value":"fs"}]}' ``` -------------------------------- ### Internal Collection+JSON href Example Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Deployment An example of the internal Collection+JSON structure, highlighting incorrect and correct href formats for API endpoints. It shows how browsers might block mixed content requests (HTTP AJAX from HTTPS origin). ```json { "collection": { "href": "http://cube.example.com/api/v1/", "items": [], "links": [ { "href": "http://cube.example.com/api/v1/files/", "rel": "files" }, { "href": "http://cube.example.com/api/v1/computeresources/", "rel": "compute_resources" } ], "total": 0, "version": "1.0" } } ``` -------------------------------- ### HTTP Request and Response Example Source: https://github.com/fnndsc/chris_ultron_backend/blob/master/docs/source/collections/plugin.rst Illustrates a typical HTTP GET request to the plugin collection endpoint and its corresponding successful response structure. ```http GET /api/v1/plugins/ HTTP/1.1 Host: localhost:8000 Accept: application/vnd.collection+json ``` ```http HTTP/1.1 200 OK Allow: GET Content-Type: application/vnd.collection+json { "collection": { "href": "https://localhost:8000/api/v1/plugins/", "items": [ { "data": [ { "name": "name", "value": "simpledsapp" }, { "name": "type", "value": "ds" } ], "href": "https://localhost:8000/api/v1/plugins/13/", "links": [ { "href": "https://localhost:8000/api/v1/plugins/13/parameters/", "rel": "parameters" }, { "href": "https://localhost:8000/api/v1/plugins/13/instances/", "rel": "instances" } ] }, { "data": [ { "name": "name", "value": "simplefsapp" }, { "name": "type", "value": "fs" } ], "href": "https://localhost:8000/api/v1/plugins/12/", "links": [ { "href": "https://localhost:8000/api/v1/plugins/12/parameters/", "rel": "parameters" }, { "href": "https://localhost:8000/api/v1/plugins/12/instances/", "rel": "instances" } ] } ], "links": [ { "href": "https://localhost:8000/api/v1/", "rel": "feeds" } ], "version": "1.0" } } ``` -------------------------------- ### Instantiate CUBE Backend Source: https://github.com/fnndsc/chris_ultron_backend/wiki/2.4-ChRIS-FS--DS--DS-plugin-worflow:-simulate-a-FreeSurfer---MPC---heatmap-workflow Commands to instantiate the CUBE backend. The first command performs a full build with tests, while the second skips tests and intro for a faster setup. Both commands clean up previous instances. ```bash *unmake* ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS ; *make* ``` ```bash *destroy* ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS ; *make* -U -I -s ``` -------------------------------- ### Setup Environment Variables and Aliases Source: https://github.com/fnndsc/chris_ultron_backend/wiki/MICCAI-Work-Flow-(WIP) Sets up essential environment variables for host IP and port, and creates a Docker alias for the pfurl command-line tool. ```shell export HOST_IP=$(ip route | grep -v docker | awk '{if(NF==11) print $9}') export HOST_PORT=8000 alias pfurl='docker run --rm --name pfurl fnndsc/pfurl' ``` -------------------------------- ### Minimal Setup for Fedora 32 (Moby) Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Fedora-32-Support-for-Docker Installs Moby engine and docker-compose on Fedora 32, configures the kernel for cgroup v1 compatibility, enables the Docker service, and reboots the system. ```shell sudo dnf install -y moby-engine docker-compose sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0" sudo systemctl enable docker sudo systemctl reboot ``` -------------------------------- ### Workflow Step 1: Call simplefs Plugin Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Workflow-notes Initiates a 'simplefs' plugin execution by sending a POST request with directory input. ```bash # 1. Call a 'simplefs' plugin purl --auth chris:chris1234 \ --content-type application/vnd.collection+json \ --verb POST \ --raw --jsonwrapper template \ --http 10.17.24.163:8000/api/v1/plugins/1/instances/ \ --msg \ '{ "data": [{ "name": "dir", "value": "/home"}] }' --quiet | underscore print --color ``` -------------------------------- ### Retrieve Plugin Collection via API Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Vagrant-Setup-OSX Fetches a list of all available plugins from the ChRIS-ultron-backend API using an HTTP GET request. It authenticates with the 'ubuntu' user credentials. ```shell $ http -a ubuntu:chrisultron http://127.0.0.1:8001/api/v1/plugins ``` -------------------------------- ### Create Plugin Instance (simplefsapp) Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Chris-workflow Demonstrates a POST request to create an instance of the 'simplefsapp' plugin. It uses basic authentication and specifies the content type and template data for the new instance. ```http http -a bob:bob-pass POST http://127.0.0.1:8000/api/v1/plugins/6/instances/ Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json template:='{"data":[{"name":"prefix","value":"myprefix"}]}' ``` ```json { "collection": { "href": "http://127.0.0.1:8000/api/v1/plugins/6/instances/", "items": [ { "data": [ { "name": "id", "value": 37 }, { "name": "plugin_name", "value": "simplefsapp" }, { "name": "owner", "value": "bob" } ], "href": "http://127.0.0.1:8000/api/v1/plugins/instances/37/", "links": [ { "href": "http://127.0.0.1:8000/api/v1/20/", "rel": "feed" }, { "href": "http://127.0.0.1:8000/api/v1/plugins/6/", "rel": "plugin" }, { "href": "http://127.0.0.1:8000/api/v1/plugins/string-parameter/36/", "rel": "string_param" } ] } ], "links": [], "version": "1.0" } } ``` -------------------------------- ### Prepare Vagrant Working Directory Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Vagrant-Setup-OSX Creates the necessary directory structure for Vagrant to manage the ChRIS-ultron-backend environment. This directory will house configuration files. ```shell $ mkdir -p ~/work/vagrant/chris-ultron ``` -------------------------------- ### Apache Reverse Proxy Configuration Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Deployment Configures Apache to proxy API requests to a backend service. It forwards requests starting with '/api' to 'http://localhost:8010/api' and sets the X-Forwarded-Proto header. ```apache ProxyPass "/api" "http://localhost:8010/api" ProxyAddHeaders On # this is the default anyways RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME} ``` -------------------------------- ### PACS Server Move-SCU Request Log Source: https://github.com/fnndsc/chris_ultron_backend/wiki/PACS-Pull-wokflow An example log message from the PACS Server indicating that a Move-SCU request has been received for the CHRIS-ULTRON-LIS Application Entity. This confirms the server is processing the retrieval request. ```log W0123 10:03:05.789730 OrthancMoveRequestHandler.cpp:175] Move-SCU request received for AET "CHRIS-ULTRON-LIS" ``` -------------------------------- ### Setup Django Database Migrations Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Vagrant-Setup-OSX Connects to the Vagrant VM via SSH and runs Django's database migration commands. This initializes the database schema required by the ChRIS-ultron-backend application. ```shell $ vagrant ssh (chris-ultron)$ cd ~/chris-ultron-backend/chris_backend (chris-ultron)$ python manage.py migrate ``` -------------------------------- ### Clone ChRIS-ultron-backend Repository Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Vagrant-Setup-OSX Clones the ChRIS_ultron_backEnd project from GitHub into a specified directory. This is the first step to obtain the project's source code. ```shell $ mkdir -p ~/work/gitroot $ cd ~/work/gitroot $ git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd.git chris-ultron-backend ``` -------------------------------- ### Pause CUBE Execution for Debugging Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Debugging-CUBE-Containerized-Services Starts the CUBE system with the '-p' flag to pause execution after initial container setup but before full instantiation. This allows for manual restarting of ancillary services for log monitoring or debugging. ```bash ./make.sh -p ``` -------------------------------- ### Apache VirtualHost Full Example with SSL Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Deployment A comprehensive Apache VirtualHost configuration for HTTPS, including a redirect from HTTP, reverse proxy for API, SPA serving, and detailed SSL/TLS settings for security. ```apache ServerName chrisstore.co RewriteEngine on RewriteCond %{SERVER_NAME} =chrisstore.co RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] ServerName chrisstore.co ProxyPass "/api" "http://localhost:8010/api" ProxyAddHeaders On # this is the default anyways RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME} DocumentRoot /var/www/ChRIS_store_ui/build ErrorLog ${APACHE_LOG_DIR}/chrisstore.error.log CustomLog ${APACHE_LOG_DIR}/chrisstore.access.log combined SSLEngine on SSLCertificateFile /etc/letsencrypt/live/chrisstore.co/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/chrisstore.co/privkey.pem SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS SSLHonorCipherOrder on SSLCompression off SSLOptions +StrictRequire ``` -------------------------------- ### Start ChRIS Ultron Backend System Source: https://github.com/fnndsc/chris_ultron_backend/wiki/0.-ChRIS-preliminary-workflow:-intro Initiates the ChRIS Ultron Backend (CUBE) system. This command is typically executed from the root of the CUBE source repository. ```bash make ``` -------------------------------- ### API: Fetch API Root and Plugin List Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Chris-workflow Demonstrates fetching the API root to discover available resources and then retrieving the list of registered plugins. Uses httpie with basic authentication. ```shell http -a bob:bob-pass http://127.0.0.1:8000/api/v1/ ``` ```APIDOC HTTP/1.0 200 OK Allow: GET, HEAD, OPTIONS Content-Type: application/vnd.collection+json Date: Tue, 09 Aug 2016 20:22:04 GMT Server: WSGIServer/0.2 CPython/3.5.1+ Vary: Accept, Cookie X-Frame-Options: SAMEORIGIN { "collection": { "href": "http://127.0.0.1:8000/api/v1/", "items": [], "links": [ { "href": "http://127.0.0.1:8000/api/v1/plugins/", "rel": "plugins" } ], "version": "1.0" } } ``` ```shell http -a bob:bob-pass http://127.0.0.1:8000/api/v1/plugins/ ``` ```APIDOC HTTP/1.0 200 OK Allow: GET, HEAD, OPTIONS Content-Type: application/vnd.collection+json Date: Tue, 09 Aug 2016 20:23:18 GMT Server: WSGIServer/0.2 CPython/3.5.1+ Vary: Accept, Cookie X-Frame-Options: SAMEORIGIN { "collection": { "href": "http://127.0.0.1:8000/api/v1/plugins/", "items": [ { "data": [ { "name": "name", "value": "simpledsapp" }, { "name": "type", "value": "ds" } ], "href": "http://127.0.0.1:8000/api/v1/plugins/7/", "links": [ { "href": "http://127.0.0.1:8000/api/v1/plugins/7/parameters/", "rel": "parameters" }, { "href": "http://127.0.0.1:8000/api/v1/plugins/7/instances/", "rel": "instances" } ] }, { "data": [ { "name": "name", "value": "simplefsapp" }, { "name": "type", "value": "fs" } ], "href": "http://127.0.0.1:8000/api/v1/plugins/6/", "links": [ { "href": "http://127.0.0.1:8000/api/v1/plugins/6/parameters/", "rel": "parameters" }, { "href": "http://127.0.0.1:8000/api/v1/plugins/6/instances/", "rel": "instances" } ] } ], "links": [ { "href": "http://127.0.0.1:8000/api/v1/", "rel": "feeds" } ], "version": "1.0" } } ``` -------------------------------- ### Query Job State with pfurl Source: https://github.com/fnndsc/chris_ultron_backend/wiki/5.-ChRIS-plugin-geretrieve This snippet shows how to query the state of a job or plugin instance using its ID. It performs a GET request to the specific instance endpoint, allowing for monitoring of the job's progress and status. ```bash pfurl --auth chris:chris1234 \ --verb GET \ --http ${HOST_IP}:8000/api/v1/plugins/instances/2/ \ --content-type application/vnd.collection+json \ --quiet --jsonpprintindent 4 ``` -------------------------------- ### Instantiate CUBE from Source Source: https://github.com/fnndsc/chris_ultron_backend/wiki/1.2-ChRIS-FS-plugin-workflow:-upload-files-to-CUBE-and-create-a-new-top-level-feed-(pl-pacscopy) Commands to start CUBE from its repository source directory. Includes options for removing volume containers and necessary sudo commands for filesystem cleanup. ```bash *destroy* ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS ; *make* ``` -------------------------------- ### Vagrant Setup for Docker on Fedora Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Fedora-32-Support-for-Docker This example demonstrates how to set up a Vagrant virtual machine using a Debian Buster image to run Docker. It includes cloning the ChRIS_ultron_backend repository, configuring the Vagrantfile with memory and port forwarding, and provisioning the VM with Docker and docker-compose. ```bash git clone https://github.com/FNNDSC/ChRIS_ultron_backEnd.git cd ChRIS_ultron_backEnd cat > Vagrantfile << EOF Vagrant.configure("2") do |config| config.vm.box = "debian/buster64" config.vm.provider "virtualbox" do |vb| vb.memory = "8096" end config.vm.network "forwarded_port", guest: 8000, host: 8000 # cube config.vm.network "forwarded_port", guest: 8010, host: 8010 # store config.vm.network "forwarded_port", guest: 5005, host: 5005 # pfcon config.vm.network "forwarded_port", guest: 5010, host: 5010 # pman config.vm.network "forwarded_port", guest: 5055, host: 5055 # pfioh config.vm.provision "shell", inline: <<-SHELL wget -qO /usr/local/bin/docker-compose "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" chmod +x /usr/local/bin/docker-compose wget -qO /tmp/get-docker.sh https://get.docker.com sh /tmp/get-docker.sh > /dev/null 2>&1 systemctl enable --now docker SHELL end EOF vagrant up vagrant ssh -c 'cd /vagrant && sudo ./make.sh' ``` -------------------------------- ### Caddy Reverse Proxy Configuration Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Deployment Example Caddyfile configuration for routing traffic to ChRIS backend services (CUBE, store) and serving ChRIS UI applications. It demonstrates automatic HTTPS with Let's Encrypt and header injection for SSL. ```caddyfile cube.chris.example.com { reverse_proxy localhost:8000 { header_up X-Forwarded-Proto {http.request.scheme} } log } api.store.chris.example.com { reverse_proxy localhost:8010 { header_up X-Forwarded-Proto {http.request.scheme} } log } chris.example.com { root * /srv/ChRIS_ui/build file_server try_files {path} /index.html } store.chris.example.com { root * /srv/ChRIS_store_ui/build file_server try_files {path} /index.html } # optional but very awesome monitoring app # https://github.com/netdata/netdata netdata.chris.example.com { reverse_proxy localhost:19999 } ``` -------------------------------- ### API: Fetch Plugin Instances and Create Instance Source: https://github.com/fnndsc/chris_ultron_backend/wiki/Chris-workflow Demonstrates fetching the instances list for a specific plugin (e.g., 'fs' type) and then performing a POST request to create a new instance. The POST request includes data payload based on the template provided by the API. ```shell http -a bob:bob-pass http://127.0.0.1:8000/api/v1/plugins/6/instances/ ``` ```APIDOC HTTP/1.0 200 OK Allow: GET, POST, HEAD, OPTIONS Content-Type: application/vnd.collection+json Date: Tue, 09 Aug 2016 20:27:29 GMT Server: WSGIServer/0.2 CPython/3.5.1+ Vary: Accept, Cookie X-Frame-Options: SAMEORIGIN { "collection": { "href": "http://127.0.0.1:8000/api/v1/plugins/6/instances/", "items": [], "links": [ { "href": "http://127.0.0.1:8000/api/v1/plugins/6/", "rel": "plugin" } ], "template": { "data": [ { "name": "previous", "value": "" }, { "name": "dir", "value": "" } ] }, "version": "1.0" } } ``` ```shell http -a bob:bob-pass POST http://127.0.0.1:8000/api/v1/plugins/6/instances/ Content-Type:application/vnd.collection+json Accept:application/vnd.collection+json template:='{"data":[{"name":"dir","value":"./"}, {"name":"previous","value":""}]}' ``` ```APIDOC HTTP/1.0 201 Created Allow: GET, POST, HEAD, OPTIONS Content-Type: application/vnd.collection+json Date: Tue, 09 Aug 2016 20:33:09 GMT Location: http://127.0.0.1:8000/api/v1/plugins/instances/37/ Server: WSGIServer/0.2 CPython/3.5.1+ Vary: Accept, Cookie X-Frame-Options: SAMEORIGIN { "collection": { "href": "http://127.0.0.1:8000/api/v1/plugins/6/instances/", "items": [ { "data": [ { "name": "previous", "value": "" }, { "name": "dir", "value": "./" } ], "href": "http://127.0.0.1:8000/api/v1/plugins/instances/37/" } ], "links": [ { "href": "http://127.0.0.1:8000/api/v1/plugins/6/", "rel": "plugin" } ], "version": "1.0" } } ``` -------------------------------- ### Instantiate CUBE Environment Source: https://github.com/fnndsc/chris_ultron_backend/wiki/1.1-ChRIS-FS-plugin-workflow:-upload-files-to-CUBE-and-create-a-new-top-level-feed-(pl-dircopy) Prepares and starts the ChRIS Ultron Back End (CUBE) environment. This involves cleaning up previous instances and then making a new one, ensuring a fresh state. ```bash *unmake* ; sudo rm -fr CHRIS_REMOTE_FS; rm -fr CHRIS_REMOTE_FS ; *make* ``` -------------------------------- ### ChRIS API: Get Plugin Parameters Source: https://github.com/fnndsc/chris_ultron_backend/wiki/5.-ChRIS-plugin-geretrieve This API documentation describes how to fetch the parameter definitions for a specific ChRIS plugin using its ID. It outlines the endpoint for retrieving parameter information and the structure of the returned parameter data, including type, optionality, and help text. ```APIDOC GET /api/v1/plugins//parameters/ Description: Retrieves the parameter definitions for a specific plugin. Authentication: Requires user credentials (e.g., chris:chris1234). Parameters: --auth :: Authentication credentials. --http :8000: The base URL of the CUBE backend. : The unique identifier of the plugin. --quiet: Suppresses verbose output. --jsonpprintindent 4: Formats the JSON output with an indent of 4 spaces for readability. Example Call: pfurl --auth chris:chris1234 --http ${HOST_IP}:8000/api/v1/plugins/9/parameters/ --quiet --jsonpprintindent 4 Response Structure (Example): { "collection": { "href": "http://:/api/v1/plugins/9/parameters/", "items": [ { "href": "http://:/api/v1/plugins/parameters//", "data": [ {"name": "name", "value": "parameter_name"}, {"name": "type", "value": "string"}, {"name": "optional", "value": true}, {"name": "default", "value": ""}, {"name": "help", "value": "Description of the parameter."} ] } ] } } Related Actions: - Fetching specific plugin details. - Running plugin instances. ``` -------------------------------- ### Execute Shell Commands in CUBE Container Source: https://github.com/fnndsc/chris_ultron_backend/wiki/5.-ChRIS-plugin-geretrieve Provides a bash function `dke` to execute commands within a specified Docker container by its name. It also shows an example of using `ls` to list files in a directory after entering the container, demonstrating file system inspection. ```bash dke () { NAME=$1; ID=$(dkl | grep $NAME | head -n 1 | awk '{print $1}'); docker exec -ti $ID /bin/bash } ``` ```bash dke chris_dev_backend root@10bd34cb1dc2:/usr/src/chris_backend# cd /usr/users/chris/feed_1/simplefsapp_1/geretrieve_2/data/demo-upload/data/1033/ root@10bd34cb1dc2:/usr/users/chris/feed_1/simplefsapp_1/geretrieve_2/data/demo-upload/data/1033# ls Axial_FLAIR-33_months-5 Axial_T2-33_months-4 Coronal_T2-33_months-6 Sagittal_T1-33_months-12 root@10bd34cb1dc2:/usr/users/chris/feed_1/simplefsapp_1/geretrieve_2/data/demo-upload/data/1033# ```