Testing with Python
Test your agent before deploying it to production
Evaluate your app’s performance before deploying it to production.
The phospho testing framework allows you to test your app with historical data, custom datasets, and custom tests.
The phospho python module parallelizes the function calls to speed up the testing process.
Getting started
To get started, install the phospho python module.
Create a new file phospho_testing.py
:
In this file, you can then write your tests.
Backtesting
To use data from the phospho platform, you can use the backtest source loader.
Dataset .CSV, .XLSX, .JSON
To test with a custom dataset, you can use the dataset source loader.
Supported file formats: csv
, xlsx
, json
The columns of the dataset file should match the function arguments.
Example of a local csv file:
Custom tests
To write custom tests, you can just create a function and decorate it with @phospho_test.test()
.
At the end, add phospho.log
to send the data to phospho for analysis.
Run using python
To run the tests, use the run
method of the PhosphoTest
class.
The executor_type
can be either:
parallel
(default): parallelizes the backtest and dataset source loader calls.parallel_jobs
: all functions are called in parallel.sequential
: great for debugging.
Run using the phospho CLI
You can also use the phospho command line interface to run the tests. In the folder where phospho_testing.py
is located, run:
The executor type can be specified with the --executor-type
flag.
Learn more using the --help
flag:
phospo CLI
Learn how to install phospho command line interface
Was this page helpful?