Skip to main content

Async CSV performance logging

Project description

Async CSV Logger

This module is intent to be a csv logger which will write to file async-ly. This is especially useful for logging performance (e.g. benchmarking some algorithms) at each iteration/time-step.

Internally, it utilise threading to write to async write to file. There are two way to initialise and use the logger.

1. Recommended way (with block)

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
    # ......

    import datetime
    for i in range(10):
        # perform calculation
        # ....
        # write results to file
        logger.write([datetime.datetime.now(), acc, num_nodes])

2. The normal way

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)

    def run(self):
        # perform calculation
        # ...
        logger.write([acc, num_nodes])


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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asynccsv-1.0.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

asynccsv-1.0.0-py3-none-any.whl (1.8 kB view details)

Uploaded Python 3

File details

Details for the file asynccsv-1.0.0.tar.gz.

File metadata

  • Download URL: asynccsv-1.0.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5

File hashes

Hashes for asynccsv-1.0.0.tar.gz
Algorithm Hash digest
SHA256 99f108a4c4ed21729b2bfedc8e40ab87e37a207f786cbdaad92f588fee987772
MD5 6b15c2ef4510419ad188fd5e3f9b47bc
BLAKE2b-256 f6d1ddffb40a94d537403a9439ff15688975714edc87dd677b5c4f14472fa385

See more details on using hashes here.

File details

Details for the file asynccsv-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: asynccsv-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.5

File hashes

Hashes for asynccsv-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 657ebc0c9b9aaa1818c1e9184bd41a2e3d018e71ff9e62944a9a6d3466f283a4
MD5 557a221580c6d08af73ae20eb797f5aa
BLAKE2b-256 ac968b1f7c1053d32af603f1c7339fd6aeff63f87fe9483b2c96aa0b40dffe71

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page