# Cache Reproduction Tests

This directory contains scripts that use the JSON output generated by `../pyc-finder/main.py` and then systematically tries to reproduce the pycache files of the given packages.

## General

All scripts expect [`uv`](https://docs.astral.sh/uv/) to be available, and can then be run by actually executing the script itself, or using `uv run --script <script_name>`.
This leverages `uv` to automatically install dependencies and use the correct python version.


## Data Cleanup
The script [`1-cleanup-data.py`](./1-cleanup-data.py) takes the JSON output of [`../pyc-finder/evaluate.py`](../pyc-finder/evaluate.py) as input, and creates a more compact version of it, only containing the data that we actually use for the next steps.
The path to the input JSON file can be set by modifying the `INPUT_PATH` constant near the top of the file.
It writes the output to `./results/compact.json`.

You can run the script using `uv` via `uv run 1-cleanup-data.py`.

## Reproduction

The script [`2-recreate-cache.py`](./2-recreate-cache.py) tries to recreate the cache files.
Since it uses `docker` to create containers with specific python versions, it expects a docker daemon running on the system, and the users running the script needs privileges to interact with the daemon.
It also expects the output of `1-cleanup-data.py` as its own input.
The path to the input file can be set via the `INPUT_PATH` constant near the top of the file.
It will then start reproducing the respective packages multiprocessed via docker.
The resulting data is written to `./results/reproducibility-results.json`.

## Data Analysis

The script [`3-analyze-results.py`](./3-analyze-results.py) analyzes the reproduction results and prints some statistics about them.
It reads data from `./results/reproducibility-results.json`.

