ExpRun
exprun allows building simple python pipelines for reproducible numerical experiments.
Quick start
With exprun, an experiment is run using an instance of the Runner class, based on a yaml configuration file, with a specified results directory, save directory and number of repeats.
from exprun import Experiment, Runner
class MyExperiment(Experiment):
# Define the experiment here (see below)
...
config_path = './config.yml'
result_dir = './results/'
save_dir = './saves/'
runner = Runner()
runner.run(MyExperiment, config_path, result_dir, repeats=10)
runner.plot(MyExperiment, config_path, result_dir, save_dir)
The above code runs 10 times MyExperiment, each result is saved at result_dir as a pickle file.
The results found in this directory that match the current configuration are recovered, plotted, and saved at save_dir as a pickle file.
In the MyExperiment class, four functions need to be specified by the user:
setup(self) -> None: Set up the experiment from the information in the configuration file.run(self) -> dict: Perform one run of the experiment and return the results as a dict.cleanup(self) -> None: Clean up the experimental data.plot(self, results: list) -> dict: Process the results obtained from a list of all the results found in the results directory that match the configuration file. Returns the plot data that must be saved.
For instance, a simple experiment that computes the sum of two numbers within a range specified in the configuration file could be defined as follows.
First, let's write the config.yml file.
min: 1
max: 10
Next, let's fill the MyExperiment class functions.
class MyExperiment(Experiment):
def setup(self) -> None:
from random import randrange
# You can access the config data from self.config
self.a = randrange(self.config["min"], self.config["max"])
self.b = randrange(self.config["min"], self.config["max"])
def run(self) -> dict:
# You can access the data of the setup function
return {"sum": self.a + self.b}
def cleanup(self) -> None:
# Nothing to clean up here
pass
def plot(self, results: list) -> dict:
# Print the mean of the sums among all the results
# found matching the current configuration file
sums = [result["sum"] for result in results]
print("Mean of sums:", sum(sums) / len(sums))
return {"sums": sums}
And as simple as that, you have a reproducible experiment that can be run multiple times with different configurations. More advanced examples can be found in the examples directory.
Contribute
exprun is still in its early stages of development.
Feel free to contribute by reporting any bugs on the issue page or by opening a pull request.
Any feedback or contribution is welcome.
License
exprun is distributed under the
MIT license.
Metadata
Release files for exprun 0.0.1
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 |
|---|---|---|---|---|
| exprun-0.0.1.tar.gz | 5.0 kB | Without provenance | Details for exprun-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| exprun-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for exprun-0.0.1-py3-none-any.whl |
Total release size: 10.7 kB
Release files / exprun-0.0.1.tar.gz
| Download URL | exprun-0.0.1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
43ba9da18f1ed8e1b7c78d39d0c0b728f741f02501e705a5253ae7601ef0859a
|
|
BLAKE2b-256 checksum How to use checksums |
5c2b5372fee84e3106e0a7d948a87fcf5d707e63981e7f25691adcb5a89e93ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.19
|
Release files / exprun-0.0.1-py3-none-any.whl
| Download URL | exprun-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f76152ecb597af0fbc9d7b185b6c1e00dd9af03348d546f884458c38a875fa6
|
|
BLAKE2b-256 checksum How to use checksums |
4a234b3ef28b6c8fd8cfd76d62ddf534cfe7eb25e0daf4f9ec79eaee8eceb678
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.19
|
Security for exprun 0.0.1
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.