Command Line Utility
The SDK includes a tb.py script which is a general purpose command line utility for working with Assets, Agreements and Processes. Using this tool, many day to day tasks can be achieved without writing any custom scripts.
Setup
The tb.py script is a stand-alone script that utilizes the classes from the tripleblind library. As such, it can be run like any other Python script. However it is even more convenient if you create shortcuts so it can be used at any time and from anywhere.
Linux / Apple
alias tb='python "/home/YOURNAME/tripleblind/api-sdk/example/tb.py"'
The above assumes the SDK was installed on a system at /home/YOURNAME/tripleblind
, so you must adjust accordingly. This line can be placed in your .bashrc
or .zshrc
, making the utility automatically available via the command line shortcut tb
.
Additionally, you can add TAB-completion support by running the following command:
tb install
Then restart your terminal to load the latest completion definitions.
Windows
Create this file in a location within your Windows path, such as C:\Windows\System32\tb.bat
@echo off pushd C:\Path\To\Your\SDK conda activate tripleblind python tb.py %* popd
From here forward, we will just use tb
as shorthand for python tb.py
in this document.
Using “tb”
The tb utility groups commands under a mode which is determined by the first parameter. Context-sensitive help can be obtained by adding --help at the end of a command line, e.g. using “tb --help
” or with a mode specifier such as “tb process --help
”
Working with Assets
The default mode for tb
is asset management. If you have adequate permissions (determined by the user associated with the token set in your tripleblind.yaml), you can use the utility to create, archive/delete, retrieve, list or set properties of any owned asset. You can also list assets made available to you by other organizations.
tb asset list Test
List all assets with “Test” in the name.
tb list Test --details --mine
List details on all assets created by me with “Test” in the name.
tb list --since='4 days ago' --max=100 --order=name
List up to 100 assets created in the last 4 days, ordered by name.
tb create mydata.csv --name 'my data' --desc 'csv data' --public
Create a new asset named “my data” from the local file “mydata.csv” and make it visible to other organizations.
tb set 'my data' name 'our data'
Rename the asset “my data” to “our data”
tb retrieve 'our data'
Retrieve a copy of the owned asset (implied) with “our data” in the name.
tb remove 'our data'
Remove the “our data” asset from the Router index. The data remains on the Access Point.
tb asset delete 'our data'
Remove the “our data” asset from the Router index and delete it from the Access Point also.
Working with Processes
The tb process
(or tb ps
for short) group of commands allow discovery and management of processes from you and your organization. You must have the appropriate user permissions in order to perform actions, but otherwise this tool gives access to all of the capabilities of the web interface.
tb process list --active
Retrieve a list of all actively running processes
tb process list --waiting
Retrieve a list of all processes waiting for permission approval
tb process list --history
Retrieve a list of all completed and failed processes
tb process list --since=MM-DD-YY
Retrieve a list of process since the specified date; defaults to yesterday
tb process list Stats
Retrieve a list of all actively running processes with “Stats” in the name. Can also input a regex or a process ID
tb process retrieve 26b09421-bcf0-485d-9a48-859e3d14751c
Retrieve a local copy of the process result asset with specified ID (eg. download a trained model asset)
tb process cancel 26b09421-bcf0-485d-9a48-859e3d14751c
Cancel specified process (requires Manage Processes) permission
tb process connect 26b09421-bcf0-485d-9a48-859e3d14751c
Connect to the output stream of a running process (ex: to view model training metrics). Add --raw
flag to dump output messages as raw JSON
Working with Requests
The tb requests
commands (tb req
for short) allow viewing and responding to open access requests for assets owned by your organization.
tb requests reply all
Display and respond to all unaddressed access requests
tb requests reply 26b09421-bcf0-485d-9a48-859e3d14751c
Display and respond to unaddressed access requests for specified Asset
tb requests list --details
Display list of unaddressed access requests, with all details
tb requests list "Tabular"
Display list of unaddressed access requests containing the term “Tabular”
Working with Teams
An SDK user can be a member of multiple teams, but at any given time there is only one active team. All operations happen within the context of that team as long as it is active -- new assets are positioned to belong to that team, new processes are created and audit records tie the operation to the active team, and found/listed assets are only those visible to the team.
The default Team context can be switched using the team’s name or ID:
tb team activate NAME|ID
NOTE: The active team is stored with your tripleblind.yaml.
Your available team names and IDs can be viewed using:
tb team list
You can view your current team using:
tb team info
And you can view members of your current team using:
tb team members
Depending on your team settings, you might be able to invite others to join your team. This is done via:
tb team add [email protected]
If the user isn’t already part of your TripleBlind organization, they will receive an invitation email.
Administrators have access to more commands for adding and removing team members or changing ownership. See the Administration Guide for details.
Model Validation
The tb validate
command is different from other commands in that there is no analogue in the web interface. This command takes in a single file model file or folder containing models, outputting a report of compatibility with TripleBlind’s secure inference technique.
tb validate <local directory>
Validates and outputs report showing compatibility of local directory contents with TripleBlind’s secure inference capabilities. Folder must contain .onnx, .h5 or .pth files
tb validate <local modelfile>
Validates and outputs report showing compatibility of specified local model file with TripleBlind’s secure inference capabilities
Working with python_transform in TabularPreprocessor
The tb preproc
commands also have no equivalent in the web interface, and are meant to assist with the development and testing of python_transform preprocessors.
tb preproc create "<asset name>"
Generates a local preproc.py file that contains the pre-built template of the required format for the python_transform, and also creates a sample of mock data from the referenced asset for validation of the preprocessor script
tb preproc test preproc.py data.csv
Runs the preproc.py transform function against the mock data sample and outputs the dataframe for validation of the preprocessor script
Flags and Advanced Use
Command behavior can be modified by a variety of flags, generally preceded with double dashes. The examples above show some mode-specific flags, such as --details --mine
when listing assets. All of these can be seen in the documentation shown by appending --help
to a command.
Other useful flags can be applied at any time:
--version
Show detailed information on the operation environment and versions
--quiet
Minimize the output
--token=TOKEN
Operate using the given TOKEN instead of the token found in tripleblind.yaml
--help
Display help for the command currently in the command line
--yes
Skips confirmations with any command
--all
Applies action of command to all search matches, otherwise you will be prompted to choose the item(s) on which to run the action
--compact
Shows less information while command is running
--details
Shows more information while command is running