A Command line tool for the dicom processor library
Project description
DCM PROCESSOR
A dicom processing library setup with docker containers.
DEPENDENCIES
- Docker & Docker Compose
Getting up and running
- open the
.env
file with any text editor and set theBASEDIR
variable to a folder which will be used as a base for mounting docker volumes. - build and pull docker images with
bash build.sh
[Run withsudo
if needed]. - run docker containers with
bash run.sh
[Run withsudo
if needed]. - initialize base services with
bash init.sh
[Run withsudo
if needed]. Note: Its good to run the containers withoutsudo
. This can be achieved by creating thedocker
group is not already created and adding your user account to this group.sudo groupadd docker && sudo usermod -aG docker $USER
Containers in this library
orthanc
: The orthanc server which servers as an intermedairy between dicom providers and our services.scheduler
: The flask based service for scheduling jobs in our service registry.worker
: A worker container which executes the scheduled tasks.dashboard
: A dashboard for RQ workers. Which shows the state of scheduled jobs.
Scaling up workers
You can scale the number of workers by passing the argument --scale worker=N
to run.sh
script, where N
is the number of instances you want.
Preparing your own service
A service consist of two parts.
- An entry in the services
registry
. - An entry in the service
modules
. Once you have prepare your entries you can use theservice.sh
script to install your service.
Service entry in the registry
A service entry in the registry
is basically a folder which contains a settings.json
file and a python file.
The json file defines the job associated with the service and the python file provides a callback function whose return value determines when a job is to be run.
-
The
settings.json
file can either be an object or an array of objects with the following fields:jobName
: [string,required] the name of the job, this should be unique from other service jobs.worker
: [string,required] name of the function to be run as the worker, this should be a full function name. (see section below for details.).callback
: [string,required] name of the function which determines if a job should be scheduled for the current dicom processing or not. (see section below for details).dependsOn
: [string/list,optional] name(s) of jobs which the current service job depends on. this will make sure that those jobs run successfully before this job runs.priority
: [string,optional] the priority level assigned to this job. if not specified a default priority is assigned.timeout
: [string/number,optional] the RQ queuing timeout default is 1 hour.params
: [object,optional] this is an object with additional parameters that will be sent to the worker function.sortPosition
: [number,optional] this is a sorting variable which is used to sort the order in which jobs are scheduled (Note: independent jobs are however scheduled before dependent jobs).description
: [string,optional] this is a description for this current job. Its not used in any operation but only for third parties to have an idea what your service does.
-
The python file should contain the
callback
function(s) you stated in thesettings.json
file -
For an example check the
temp
service folder in theservices
folder.
Service entry in the modules
- A service entry in the
modules
is basically a folder which contains at least a python file with theworker
function definition and other python files and any other file needed to run the worker function. - This should usually be prepared as a python module.
- Module dependencies should be added using a
requirements.txt
in the same folder. - A special shell script
script.sh
can also be added to the same folder which will be run by the worker container.
For an example of the service entry in the modules
directory see the temp
service in the services
folder.
The callback function
A callback
function takes the following arguments
jobName
: The name of the job.headers
: The selected fields in the dicom header.params
: The params object from thesettings.json
.added_params
: This is a dictionary ofinjected
params from other jobs.**kwargs
: We recommend you add this to the list of arguments to capture all other params that may be passed.
Note:
- Arguments are passed by name which means
exact names
should be used and position is NOT important. - The callback function should return
True
if the job should be processed for the current dicom orFalse
otherwise. - It can also return a dictionary in addition to the
True/False
which will be sent to othercallbacks
andworker
functions asadded_params
. - The callback function should NOT be used to perform time intensive tasks. The actual job should be handled in the
worker
function.
The worker function
A worker
function takes the following arguments
jobName
: The name of the job.headers
: The selected fields in the dicom header.params
: The params object from thesettings.json
.added_params
: This is a dictionary ofinjected
params from other jobs. Provide the name of the service whos parameters you want to access as a key to the dictionary for e.g.added_params[servicename][keyname]
.**kwargs
: We recommend you add this to the list of arguments to capture all other params that may be passed.
Note:
- Arguments are passed by name which means
exact names
should be used and position is NOT important. - The worker function is where all the processing takes place and thats the function that will be scheduled to be handled by the RQ workers.
- The worker function should not return any value. [it can but will not be used for anything].
The service.sh
script.
This script can be used to install
, remove
, and backup
services.
- An installable service should be a parent folder with two sub-folders:
registry
: This contains the files which will go into the services registrymodule
: This contains the module files which goes into the services modules
- To install a service run
bash service.sh install <servicename> -p <parentFolderPath>
- To remove a service run
bash service.sh remove <servicename> -b <backupPath>
backup path is optional - To backup a service run
bash service.sh backup <servicename> -b <backupPath>
Install the new service automatically.
To add the new service permanently to the workflow, append the service intallation command to the init.sh
file.
TO DOs
- Support direct service installation from
git
source. - Support virtualenv based workers.
- Create a CLI which can be installed with apt or npm or pip
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dcm-processor-0.4.3.tar.gz
.
File metadata
- Download URL: dcm-processor-0.4.3.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd9ae0463c354d35018c1aa009eeb48779d91f5814a67cce577e4691b9ec915e |
|
MD5 | 2b24e8b78886f7b040448e83c2ec1244 |
|
BLAKE2b-256 | 630ce6dcc9e330ee52e0f3316e5d4e9724c667919d64d1304687671f7a015237 |
File details
Details for the file dcm_processor-0.4.3-py3-none-any.whl
.
File metadata
- Download URL: dcm_processor-0.4.3-py3-none-any.whl
- Upload date:
- Size: 11.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62dea63033e66c87fa397bdba0f4d204f37b1677ae4d11af67f0c0cf6905f878 |
|
MD5 | 192af446ecb35d813b63b1cf597cd2fb |
|
BLAKE2b-256 | f2d7cc05ccc20178797d3f80f730abf178b552775ae754a5c427d94753cdbfdc |