Skip to main content

Mastering Atari with Discrete World Models

Project description

ChunkedFile

A file handle that groups subsequence writes together and periodically writes them as separate files. Useful for file systems like GCS FUSE that do not support file appending. Pathlib can be patched to replace files opened in append mode with chunked files, so external libraries need not be changed.

Usage

Using ChunkedFile:

import time
import chunkedfile

# Write chunks up to every 10 minutes.
with chunkedfile.ChunkedFile('filename.txt', 600) as f:

  # The first chunk will be written on the first write after the sleep.
  f.write('Lorem\n')
  time.sleep(1000)
  f.write('Ipsum\n')

  # The last chunk is automatically written when the file is closed.
  f.write('Dolor\n')
  f.write('Sit\n')

# The directory now contains two files:
# - filename.txt-1-20210904T130400
# - filename.txt-2-20210904T132100

Using pathlib.Path:

import time
import pathlib
import chunkedfile

# Path objects opened in append mode will be replaced by chunked files.
chunkedfile.patch_pathlib_append(600)

# Write chunks up to every 10 minutes.
with pathlib.Path('filename.txt').open('a') as f:

  # The first chunk will be written during the sleep command.
  f.write('Lorem\n')
  f.write('Ipsum\n')
  time.sleep(1000)

  # The last chunk is automatically written when the file is closed.
  f.write('Dolor\n')
  f.write('Sit\n')

# The directory now contains two files:
# - filename.txt-1-20210904T130400
# - filename.txt-2-20210904T132100

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

chunkedfile-0.1.0.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file chunkedfile-0.1.0.tar.gz.

File metadata

  • Download URL: chunkedfile-0.1.0.tar.gz
  • Upload date:
  • Size: 2.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for chunkedfile-0.1.0.tar.gz
Algorithm Hash digest
SHA256 73a602ba5f9f9f59c0f3555af0266aae094016aaefb20549e9c81484c27eeacb
MD5 5ba8b5f687d86dd272bf2859a3f565db
BLAKE2b-256 731e178e62af54586895ea7cffd36bb5c68495817e71228dd32e40f31f5f20ff

See more details on using hashes here.

Supported by

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