LogDir
A Python library for managing logging directories.
| Source | PyPI | Conda | CI/CD | Docs | Docs Status |
|---|---|---|---|---|---|
| GitHub | logdir.btjanaka.net |
Installation
To install from PyPI, run:
pip install logdir
To install from Conda, run:
conda install -c conda-forge logdir
To install from source, clone this repo, cd into it, and run:
pip install .
logdir is tested on Python 3.7+. Earlier Python versions may work but are not guaranteed.
Usage
If your experiment is called My Experiment, you can create a logging directory
for it with:
from logdir import LogDir
logdir = LogDir("My Experiment")
This will create a logging directory of the form
./logs/YYYY-MM-DD_HH-MM-SS_my-experiment; you can change ./logs by
passing in a second argument for the root directory when initializing LogDir,
i.e. LogDir("My Experiment", "./different-log-dir").
You now have access to useful methods for creating files and saving data in the
directory. For example, start writing to a file new.txt in the directory with:
with logdir.pfile("new.txt").open() as file:
file.write("Hello World!")
This takes advantage of the
pfile() method, which
creates a pathlib.Path to the new file. It also uses pathlib.Path.open().
pfile() will also create intermediate directories, so this will work even if
foo/bar/ does not exist in the logging directory already:
with logdir.pfile("foo/bar/new.txt").open() as file:
file.write("Hello World!")
There is also save_data(), which saves data to a file. JSON, YAML, TOML, and pickle files are currently supported.
logdir.save_data({"a": 1, "b": 2, "c": 3}, "file.json")
Finally, readme() adds a README.md to the directory with multiple pieces of information. For instance, this command:
logdir.readme(date=True, git_commit=True)
Will create something like:
# My Experiment
- Date: 2020-10-04 23:04:05
- Git Commit: e3rftyt543rt5y67jhtgr4yhju
See the API for all available methods.
Release files for logdir 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| logdir-0.13.0.tar.gz | 6.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| logdir-0.13.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.8 kB
Release files / logdir-0.13.0.tar.gz
| Download URL | logdir-0.13.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b04e4a58220489fbb7e6ba4781a3f45f872ffbd529aa295ba8b4495007f1a7b5
|
|
BLAKE2b-256 checksum How to use checksums |
6b1db98e43359fb75d7c4e1fdfeb400df3440f2410ac86f72ce1906e6dbce477
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1039-azure
|
Release files / logdir-0.13.0-py3-none-any.whl
| Download URL | logdir-0.13.0-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
702dcd4952d14c54086ac0b58c71816ca068a9e589db6d8a123746090ee318c9
|
|
BLAKE2b-256 checksum How to use checksums |
c27b681636a7a7422c113354ce06422b3722a339624ea21e6a06d7e5ac98d3b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.7.17 Linux/5.15.0-1039-azure
|