Tutorial¶
Installing¶
To install from pypi simply use:
pip install ctp-client
Alternatively, you can get yourself a copy of the source code:
git clone https://gitlab.com/radiology/infrastructure/data-curation-tools/CTPy
Create a connection¶
To create a connection import the package and use the connect function:
>>> import ctpy
>>> connection = ctpy.connect("http://ctp.example.com", port=8080, username="myuser", password="secret")
Once connected you can use the CTP client object to query data from the CTP server.
Note
The module to import for the ctp-client is called ctpy
Getting summaries¶
Getting the summary for all pipelines can be done with a single method:
>>> connection.get_ctp_summary()
If you want the information about a single step for a pipeline you can use:
>>> connection.get_ctp_step(pipeline=0, step=1)
User management¶
Getting the users and their roles with method:
Above code will return a list of Users. Each of the Users will have a name and a list of UserRoles.
To add a new user:
.. code-block::python
>>> from ctpy.helpers import User
>>> from ctpy.helpers import UserRoles
>>> new_user = User('Audit', [UserRoles.audit, UserRoles.qadmin])
>>> new_user.password = 'password'
>>> users.append(new_user)
>>> ctpy.update_password(users)
If you prefer to create the users before starting the CTP it is possible to create the users.xml (CTP’s method to store users/roles and passwords). This can be done using CTPy’s command line interface: .. code-block::bash
ctpy create-users-xml -u Audit,password,audit,qadmin -u admin,qwerty,admin -u king,password,admin -u test,test,admin
Each user (-u) is represented as a comma seperated string {username},{password},{role_1},..,{role_n}.