TrojAI provides the troj Python convenience package to allow users to integrate TrojAI adversarial protections and robustness metrics seamlessly into their AI development pipelines.
Project description
trojai-sdk
TrojAI's SDK and command line interface.
Utils
from trojsdk.core import client_utils, data_utils
The client_utils provide and easy way to submit jobs to the cluster. It can be used programatically, or through the command line. The data_utils provide simple functions which can help to use the SDK's components.
python
# Submit a job using a provided config file
job_handler = client_utils.submit_evaluation("path/to/config.json")
# Check the status of the job. Alternatively, use 'kubectl describe pod <trojeval job>' within your terminal, with the context set to the cluster.
job_handler.check_job_status()
command line
trojsdk -c path/to/config.json
python
# Use the load_json_from_disk function to recursively load JSON data from a file, and its json sub-files, which can be specified by a path string.
config_dict = data_utils.load_json_from_disk("path/to/config.json")
# Create the config object and retrieve the dict containing the docker_metadata if it is present within the config dict.
config, docker_metadata = data_utils.config_from_dict(config_dict)
SDK Components
Config
from trojsdk.config.nlp import NLPTrojConfig
from trojsdk.config.tabular import TabularTrojConfig
from trojsdk.config.vision import VisionTrojConfig
from trojsdk.config.auth import TrojAuthConfig
For examples and explinations on configuring your config files, please visit our gitbook.
Intro to TrojAI
NLP
Tabular
Client
from trojsdk import TrojClient
# Load the json config file into a dictionary
config_dict = data_utils.load_json_from_disk(Path("C:/Users/macjo/Downloads/tabular_SMOTETomek_logistic_base.json"))
# Split the docker_metadata from the config dict, and create a config object file.
config, docker_metadata = client_utils.config_from_dict(config_dict)
# Create the client with its auth credentials and endpoint.
client = TrojClient(auth_config=config.auth_config)
# Post the job with the config object and docker information.
res = client.post_job(config, docker_metadata)
time.sleep(2) # It will take a couple seconds to submit the job.
jobs = client.get_job_status(res["data"]["job_name"])
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
trojai-sdk-0.1.6.tar.gz
(16.5 kB
view hashes)
Built Distribution
trojai_sdk-0.1.6-py3-none-any.whl
(21.7 kB
view hashes)
Close
Hashes for trojai_sdk-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7de1433802321603cb73eade0db81ad0c3785dd7ae82a9b575cf073bc612cbd2 |
|
MD5 | 2358c83fc55814343b57cbe287c5c355 |
|
BLAKE2b-256 | 86c26342222a93012f71fdb580ae5d578fb88b245ea13a0618ff935f369446b1 |