Skip to main content

A simple tool that automate checkpointing.

Project description

pycheckpoint

def pycheckpoint(
        checkpoint_path: Union[str, os.PathLike]=".pycheckpoint",
        serialization: Union[Literal["pickle", "pandas.csv", "pandas.parquet", "json"], Tuple[Callable, Callable, str]]="pickle",
        serialize_function_kwargs: Tuple[dict, dict]=({}, {}),
        canonical_args: bool=True,
    )-> Callable:
    """
    Decorator to checkpoint a function. The function will be checkpointed based on the function name, the function bytecode, and the arguments. 

    The checkpointed results are stored in the `checkpoint_path` directory. 
    The checkpointed results are stored in a directory named
    `function_name_[date]_hash_pycheckpoint` where `function_name` is the name of the function, 
    `date` is the date of the checkpoint, and `hash` is the sha256 hash of the function bytecode. 
    The checkpointed results are stored in files named `args_repr_[date]_arg_hash_pycheckpoint.extension` 
    where `args_repr` is a string representation of the arguments, `date` is the date of the checkpoint,
    `arg_hash` is the sha256 hash of the arguments, and `extension` is the file extension. 
    The file extension is determined by the `serialization` argument.
    A copy of the function source code is stored in a file named `function_name_source.py` in the checkpoint directory.

    Args:
        checkpoint_path (Union[str, os.PathLike], optional): Path to store checkpoints. Defaults to ".pycheckpoint".
        serialization (Union[Literal["pickle", "pandas.csv", "pandas.parquet", "json"], Tuple[Callable, Callable, str], optional): 
            Serialization method. Defaults to "pickle". If Tuple, the first element is the serialization function, 
            the second element is the deserialization function, and the third element is the file extension. 
            The serialization function should have the signature `def serialize_function(obj, path, **kwargs)`.
            The deserialization function should have the signature `def deserialize_function(path, **kwargs)`.
        serialize_function_kwargs (Tuple[dict, dict], optional): Keyword arguments for serialization and deserialization functions. Defaults to ({}, {}).
        canonical_args (bool, optional): If True, the function will be checkpointed based on the canonical arguments. If true, all positional arguments 
            and kwargs are represented in a unified form. Defaults to True.

    """

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

pychequepoint-0.0.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pychequepoint-0.0.3-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file pychequepoint-0.0.3.tar.gz.

File metadata

  • Download URL: pychequepoint-0.0.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for pychequepoint-0.0.3.tar.gz
Algorithm Hash digest
SHA256 40481eccf98f4d66da7f41bed92733217ee05fde27e80c13f6ebf179f7041a74
MD5 af37e7cf67176775b09a208ada0fa431
BLAKE2b-256 a7bd3f2dab999801bca48f65da3eeacdf1eeb1ded335dfdfae0fcb7e8ca84fdd

See more details on using hashes here.

File details

Details for the file pychequepoint-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pychequepoint-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for pychequepoint-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f53c2899d86c45acf146443330a0bb4c36bb11e8adca23bb7b3f3a7b3aa49231
MD5 61d3c9f001abab6821535f324d2154bb
BLAKE2b-256 68dabf3612d46958ea7e85d92a83fc145c2005ce4c34a2014eaf80c4281216cc

See more details on using hashes here.

Supported by

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