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.2.3.3.tar.gz
(53.3 kB
view hashes)
Built Distribution
Close
Hashes for trojai_sdk-0.2.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 013fdcf17d6a5d8e2cfaa42e152a852158aab9dfa41ad3c99ad9b82f10c0154c |
|
MD5 | 5c59c908d4e1c84514d9ee85066f7a3a |
|
BLAKE2b-256 | 6381330ce2a4512e6faa7b12a52d8a877d477d4304ea2d4e12547fb713374362 |