Replicate of MDPFuzz
This repository contains a re-implementation the policy testing framework MDPFuzz, whose original code can be found here. This tool has been used in the paper Replicability Study: Policy Testing with MDPFuzz.
Installation
You can install the package with pip:
pip install mdpfuzz
One can also want to install the package locally:
git clone https://github.com/QuentinMaz/MDPFuzz_Replication mdpfuzz
cd mdpfuzz
pip install -e .
In the latter case, don't forget to append the folder mdpfuzz/ to your path.
Usage
The Fuzzer class (mdpfuzz/mdpfuzz.py) provides functions for fuzzing with and without GMM guidance, as well as a simple random testing procedure.
It inputs an Executor object, which is responsible for generating and mutating inputs (also called seeds), loading the policy under test and executing test cases (i.e., running the policy with a given input).
As such, using the package involves 3 simple steps:
- Implementing a Executor class for your use case.
- Creating an executor, loading the model under test and instantiate a fuzzer.
- Running the fuzzer (fuzzing - with or without GMM guidance - or Random Testing) with the testing budget you want!
Example
In the file dqn_mountain_car.py, we test a DQN agent (learnt using the library Stable Baselines3) for the Mountain Car environment.
Setup
Setup a virtual environment with, for instance, conda:
conda create -n demo python=3.10.12
conda activate demo
pip install mdpfuzz
# install gymnasium and stable-baselines3 dependencies
pip install gymnasium==0.29.1
pip install stable-baselines3==2.2.1
Make sure to activate the virtual environment (conda activate demo) before executing the script!
Additionally, we provide the script as a Jupyter notebook in which with we detail each step of the demonstration.
If you use the notebook, install the following dependency in the virtual environment: pip install ipykernel.
The demonstration consists of:
- Learning and saving the DQN agent (
dqn_mountain_car.zip). - Testing the agent with a budget of 2500 test cases, with both Random Testing and MDPFuzz. The results of Random Testing are recorded in the current directory prefixed by
random_testing, while the results of MDPFuzz are prefixed bymdpfuzz. - Plotting the evolution of the number of failures found over the test cases by the two methods in the file
failure_results_comparison_demo.png.
Metadata
Release files for mdpfuzz 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mdpfuzz-0.0.3.tar.gz | 22.9 kB | With provenance | Details for mdpfuzz-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mdpfuzz-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for mdpfuzz-0.0.3-py3-none-any.whl |
Total release size: 46.8 kB
Release files / mdpfuzz-0.0.3.tar.gz
| Download URL | mdpfuzz-0.0.3.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc9258f2a3d1cc38e78c2c3270a32656235ce5874e4ffc0ba737467c0575b1eb
|
|
BLAKE2b-256 checksum How to use checksums |
6216c68560b9470c488d040ee33dc2ae6489395690395d0c51e8e9b41d996b60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 20, 2025.
Transparency logRelease files / mdpfuzz-0.0.3-py3-none-any.whl
| Download URL | mdpfuzz-0.0.3-py3-none-any.whl |
|---|---|
| Size | 23.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4febd7470c47fdd95d905b413deb0613780c73b4b17900b6478a249552f91b73
|
|
BLAKE2b-256 checksum How to use checksums |
5172cd6bfc1acb058d03a0479f122dd64f13e8c9bc280e00dd407aa4e37d5f9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 20, 2025.
Transparency logSecurity for mdpfuzz 0.0.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mdpfuzz-0.0.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 20, 2025.
Transparency logA 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.