A simple library to handle filenames automatically for artifacts..
Project description
Filename-Manager
A simple Python library to handle filenames automatically for artifacts.
Install
pip install filenamemanager
Features
This library helps to convert a set of parameters into filenames and vice versa.
When running a script depending on parameters par1
(str) and par2
(float), you might want to save artifacts with a filename generated by these parameters.
You can decide how to format each parameter in the saved filename, e.g. fp4.4
will padd the float with leading 0
s and with 4 digits. For example, 1.2
will be 0001.2000
.
Save artifacts
from filename_manager import FilenameManager
fm = FilenameManager({"par1": "str", "par2": "fp.4.4}"}, prefix="subfolder/prefix", postfix=".csv")
# define your parameters
par1 = "Hello"
par2 = "3.11"
# super fancy script
results = "placeholder"
# create filename
filename=fm.encode(par1=par1, par2=par2)
# save
...
the filename will be subfolder/prefix_par1_Hello_par2_0003.1100.csv
.
Load artifacts
from filename_manager import FilenameManager
fm = FilenameManager({"par1": "str", "par2": "fp.4.4}"}, prefix="subfolder/prefix", postfix=".csv")
# get your filename
filename = "subfolder/prefix_par1_Hello_par2_0003.1100.csv"
# parse filename
pars = fm.decode(filename)
The variable pars
is a dictionary with {"par1": "Hello", "par2": 3.11}
.
Documentation
The documentation is given in the docstrings. Only two classes exist. Parameter
and FilenameManager
.
The supported formats are
fp*.*
for floating point parameters. E.g. "fp4.3" formats 1.2 as "0001.200"str
for string parameters.str*
for string parameters with * characters padded with 0 in the end.*str
for string parameters with * characters padded with 0 in the beginning.bool
for boolean parameters.*int
for integer parameters with * leading zeros.
Credits
This package was created with Cookiecutter and the waynerv/cookiecutter-pypackage project template.
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
Hashes for filenamemanager-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19c5d39f5aece35799130b40ea5f5015729a2d0bb72968f1cfa77eb6564f5e10 |
|
MD5 | 3d0a5905458a2c2784bd483de4662d62 |
|
BLAKE2b-256 | 7cbaac76375402a1743fba01add88883338c374c544ed18a33e009b714c6c5b5 |