Skip to main content

trojai-sdk

TrojAI's SDK and command line interface. This tool is used for submitting and monitoring jobs for evaluation by the TrojAI engine.

Uses

Command Line Functions

IMPORTANT: We've updated our authentication methods! Older auth configs required an id_token key and a refresh_token key. These keys are no longer required and should be removed from auth configs going forward. The only key required moving forward is the api_key.

The behaviour for submitting jobs using the command line is as follows:

Submit a valid config

tsdk -c path/to/config.json

The following arguments are intended to be used together to download failed results of a given job. Any feedback on this feature is appreciated!

Download failed samples from a given run

tsdk -dl_fails -job_name "trojeval-tabular-24052023-142652-850205" -auth_config ".\trojsdk\examples\auth_config_dev.json" -save_path "./failed_samples.json"

job_name: Can be found by using kubectl get pods. K8s creates the pods with an extra tag at the end, be sure to remove the randomly generated characters that prevent pod collisions.

Example: k8s pod name: trojeval-tabular-25052023-170036-121934-tknf5 valid job name: trojeval-tabular-25052023-170036-121934

Copy the job name of the evaluation when completed. You can also find the job name by clicking the Status column link in the front end project view for any run. auth_config: A path to a valid auth config for your cluster. Valid endpoint and api key are required save_path: where the resulting json file will be saved to

Programmatic Functions

We've added a more programmatic version of the config builder to be used in any python script. This TrojExperimenter is designed to be an aggregator for your trojai config files, and configs can be swapped in code instead of manually modifying json files.

A test example is detailed below:

conf_handler = TrojExperimenter("./trojsdk/examples/auth_config_dev.json")
proj = "test_proj"
dataset = "credit_dataset"
model = "logistic_model"
conf_handler.create_experiment(proj, dataset, model, delete_existing=True)
conf_handler.log_testing_data(path_to_dset_file="s3://trojai-object-storage/stars_tabular/stars_validation.csv", label_column="Type", classes_dictionary= {
    "red dwarf": 0,
    "brown dwarf": 1,
    "white dwarf":  2,
    "main sequence": 3,
    "super giants": 4,
    "hyper giants": 5
})
conf_handler.log_model(model = "s3://trojai-object-storage/stars_tabular/StarKNNPipe.pkl", model_wrapper_file = "s3://trojai-object-storage/stars_tabular/StarKNNWrapper.py")
conf_handler.log_attacks("./trojsdk/examples/star_attacks.json")
conf_handler.log_docker_metadata("trojai/troj-engine-base-tabular:tabular-dev-latest", "trojaicreds", "IfNotPresent")
k8s_dict = {
        "container_port": 80,
        "resources": {
            "requests": {
                "cpu": "250m",
                "memory": "800M"
            },
            "limits": {
                "cpu": "500m",
                "memory": "2000M"
            }
        },
        "tolerations": [
            {
                "effect": "NoSchedule",
                "operator": "Equal",
                "value": "robustness-evaluation",
                "key": "dedicated"
            }
        ]
    }
conf_handler.log_k8s_metadata(k8s_dict)
conf_handler.construct_base_config(task_type="tabular")
tjh = conf_handler.run_troj_evaluation(proj, dataset, model, no_ssl=True)

Config

For examples and explanations on creating valid your config files, please visit our gitbook.
Intro to TrojAI
NLP
Tabular

Metadata

Release files for trojai-sdk 0.2.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trojai-sdk 0.2.4.3
File Size Uploaded Provenance Actions
trojai-sdk-0.2.4.3.tar.gz 22.7 kB Without provenance Details for trojai-sdk-0.2.4.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trojai-sdk 0.2.4.3
File Interpreter ABI Platform Actions
trojai_sdk-0.2.4.3-py3-none-any.whl Python 3 none any Details for trojai_sdk-0.2.4.3-py3-none-any.whl

Total release size: 51.0 kB

Release files / trojai-sdk-0.2.4.3.tar.gz

Download URL trojai-sdk-0.2.4.3.tar.gz
Size 22.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8c592035d0795ab0205917d9f204efdbd8bdb232003535f44674d17f75158a24
BLAKE2b-256 checksum
How to use checksums
5612646d9390ce4c280137660177ff3ebb406a8874ca08c0088d366ac881368d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.5

Release files / trojai_sdk-0.2.4.3-py3-none-any.whl

Download URL trojai_sdk-0.2.4.3-py3-none-any.whl
Size 28.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e4199022b77f5ef8ae383ce346aae708b40b880e515939d1a7f5c20675a68e4
BLAKE2b-256 checksum
How to use checksums
8ad96a63aa799546e0cf6ebc4eb2d281e0a96329142297cdef1f0684b6899caa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.5

Security for trojai-sdk 0.2.4.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page