saatgut: seed everything, everywhere, all at once.
Project description
Set a seed across all your libraries and frameworks with a single function call.
from saatgut import seed_everything
# Seed everything, everywhere, all at once.
seed_everything(42)
But sometimes, the seed is not enough. To improve reproducibility even more, you can domesticate everything. This will seed your libraries and modify OS variables to ensure that the environment is as consistent as possible.
from saatgut import domesticate_everything
domesticate_everything(42)
To exterminate even the last but of randomness, you can use the hard mode.
This will disable parallel execution in libraries that support it, modify more OS variables, and overwrite some
functions from the random module. This will ensure that your code runs in a fully deterministic manner,
but it will significantly slow down your code (depending on the libraries you use) and make
cryptographic functions deterministic as well. Never use this in a production environment!
from saatgut import domesticate_everything
domesticate_everything(42, hard_mode=True)
Installation
pip install saatgut
Supported libraries
randomnumpytorchtensorflowjax
By extension, this leads to reproducibility in libraries that use these libraries, such as:
pandasscikit-learnscipy- huggingface libraries, like
transformers - opencv (
cv2) statsmodelsgensim
... and many more!
Seeding specific libraries
You can also seed specific libraries if you don't want to seed everything. This works for all the libraries listed above.
from saatgut import seed_random, seed_numpy, seed_torch, seed_tensorflow, seed_jax
# Seed only numpy and torch.
seed_numpy(42)
seed_torch(43)
Domestication is available for specific libraries as well:
from saatgut import domesticate_random, domesticate_numpy, domesticate_torch, domesticate_tensorflow, domesticate_jax
domesticate_torch(seed=42, force_matmul_precision=True)
domesticate_tensorflow(seed=43, disable_parallelism=True)
domesticate_random(seed=44, derandomize_cryptography=True)
The additional parameters used above are specific to the library and can be found in the documentation of each function.
Use them only if normal domestication is not enough for your use case.
Using hard_mode=True in domesticate_everything is equivalent to setting all the additional parameters to True in the specific domestication functions.
Why "saatgut"?
The name "saatgut" is derived from the German word for "seed" (Saatgut).
Contributing
Contributions are welcome! If you find a bug or have a feature request, please open an issue on GitHub. If you want to contribute code, please take a look at the open issues.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file saatgut-0.1.1.tar.gz.
File metadata
- Download URL: saatgut-0.1.1.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0592c35847b919cabd562dddf3b31994cf8e6a6f73a5af2cf6d7460f26364d07
|
|
| MD5 |
1ee3c76bdd433b64a36b02d91f72b36c
|
|
| BLAKE2b-256 |
b5de926ba44dbf61daed4c118d7a2100e885b5a00b9685ac5deccd6ea19068e3
|
File details
Details for the file saatgut-0.1.1-py3-none-any.whl.
File metadata
- Download URL: saatgut-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aadc1190537e9cfc2ca672bff9503b055b9269075cf9cc4407a057a93313739d
|
|
| MD5 |
45f76fddda95c36117ec316d67af63e2
|
|
| BLAKE2b-256 |
11a72b289bb985bbf87d09379060507d28d1e74817f0d0f665d2e532113aec5a
|