Async CSV Logger
This module is a async csv logger that helps you log performance of your algorithm.
Description
This module is intented to be a csv logger which will write to file async-ly.
With the hope to have minimum performance impact on benchmarking your algorithm (i.e. I/O blocking to write to disk), this is especially useful for logging performance at each iteration/time-step. Internally, it utilise threading to async write to file.
There are two way to initialise and use the logger.
Install
pip install asynccsv
1. Recommended way (with block)
import time
import datetime
from asynccsv import AsyncCSVLogger
with AsyncCSVLogger('path_of_your_log.csv') as logger:
# csv titles
logger.write(['Time', 'Accuracy', 'Num of nodes'])
# do your other stuff
# ......
for i in range(10):
# perform calculation
# ....
# write results to file
logger.write([datetime.datetime.now().strftime("%S.%f"), acc, num_nodes])
time.sleep(0.5)
2. The normal way
import time
from asynccsv import AsyncCSVLogger
class MyAwesomeAlgorithm():
def __init__(self):
# with the 'log_timestamp' flag it will automatically log timestamp
self.logger = AsyncCSVLogger('path_of_your_log.csv', log_timestamp=True)
self.logger.write(['Time', 'Accuracy', 'Num of nodes'])
def run(self):
# perform calculation
# ...
logger.write([acc, num_nodes])
time.sleep(0.5)
if __name__ == '__main__':
awesome = MyAwesomeAlgorithm()
for i in range(10):
awesome.run()
# You SHOULD run this to properly close the threading and force
# everything to be written to disk
# This is automatically done by the 'with' block in previous example
awesome.logger.close()
With both methods, the final content of path_of_your_log.csv will look something like:
"Time","Accuracy","Num of nodes"
"57.689359","92.5","11"
"58.189979","93.5","12"
"58.690520","94.22","13"
"59.191268","93.5","15"
"59.692062","92.2","17"
"00.192850","92.4","22"
"00.693661","94.8","26"
"01.194634","96.6","27"
"01.695368","94.1","30"
"02.196014","97.5","42"
Metadata
Release files for asynccsv 1.0.2
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 |
|---|---|---|---|---|
| asynccsv-1.0.2.tar.gz | 2.2 kB | Without provenance | Details for asynccsv-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| asynccsv-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for asynccsv-1.0.2-py3-none-any.whl |
Total release size: 4.3 kB
Release files / asynccsv-1.0.2.tar.gz
| Download URL | asynccsv-1.0.2.tar.gz |
|---|---|
| Size | 2.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0cb64424c2582a9366287a714f6984085c4316d474b8f36c0cd13c0d2aae235
|
|
BLAKE2b-256 checksum How to use checksums |
5792a99566d946e31d920706a0e5503e7a2add2708ff23cc35282b02371876c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5
|
Release files / asynccsv-1.0.2-py3-none-any.whl
| Download URL | asynccsv-1.0.2-py3-none-any.whl |
|---|---|
| Size | 2.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd6c7eb69c6e5b1582d00d7d0602952e5df9fd13a18dbfdd9159b9eac29bc03e
|
|
BLAKE2b-256 checksum How to use checksums |
2869e9dd299df6b30d5b019a350eea35e774a341e40b157b35ecf84dcb7998aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.5
|
Security for asynccsv 1.0.2
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.