pychequepoint


Namepychequepoint JSON
Version 0.0.3 PyPI version JSON
download
home_pageNone
SummaryA simple tool that automate checkpointing.
upload_time2024-08-30 18:07:46
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

    """
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pychequepoint",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Yurun Yuan <yurun.yuan@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/a7/bd/3f2dab999801bca48f65da3eeacdf1eeb1ded335dfdfae0fcb7e8ca84fdd/pychequepoint-0.0.3.tar.gz",
    "platform": null,
    "description": "# pycheckpoint\r\n\r\n```\r\ndef pycheckpoint(\r\n        checkpoint_path: Union[str, os.PathLike]=\".pycheckpoint\",\r\n        serialization: Union[Literal[\"pickle\", \"pandas.csv\", \"pandas.parquet\", \"json\"], Tuple[Callable, Callable, str]]=\"pickle\",\r\n        serialize_function_kwargs: Tuple[dict, dict]=({}, {}),\r\n        canonical_args: bool=True,\r\n    )-> Callable:\r\n    \"\"\"\r\n    Decorator to checkpoint a function. The function will be checkpointed based on the function name, the function bytecode, and the arguments. \r\n\r\n    The checkpointed results are stored in the `checkpoint_path` directory. \r\n    The checkpointed results are stored in a directory named\r\n    `function_name_[date]_hash_pycheckpoint` where `function_name` is the name of the function, \r\n    `date` is the date of the checkpoint, and `hash` is the sha256 hash of the function bytecode. \r\n    The checkpointed results are stored in files named `args_repr_[date]_arg_hash_pycheckpoint.extension` \r\n    where `args_repr` is a string representation of the arguments, `date` is the date of the checkpoint,\r\n    `arg_hash` is the sha256 hash of the arguments, and `extension` is the file extension. \r\n    The file extension is determined by the `serialization` argument.\r\n    A copy of the function source code is stored in a file named `function_name_source.py` in the checkpoint directory.\r\n\r\n    Args:\r\n        checkpoint_path (Union[str, os.PathLike], optional): Path to store checkpoints. Defaults to \".pycheckpoint\".\r\n        serialization (Union[Literal[\"pickle\", \"pandas.csv\", \"pandas.parquet\", \"json\"], Tuple[Callable, Callable, str], optional): \r\n            Serialization method. Defaults to \"pickle\". If Tuple, the first element is the serialization function, \r\n            the second element is the deserialization function, and the third element is the file extension. \r\n            The serialization function should have the signature `def serialize_function(obj, path, **kwargs)`.\r\n            The deserialization function should have the signature `def deserialize_function(path, **kwargs)`.\r\n        serialize_function_kwargs (Tuple[dict, dict], optional): Keyword arguments for serialization and deserialization functions. Defaults to ({}, {}).\r\n        canonical_args (bool, optional): If True, the function will be checkpointed based on the canonical arguments. If true, all positional arguments \r\n            and kwargs are represented in a unified form. Defaults to True.\r\n\r\n    \"\"\"\r\n```\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A simple tool that automate checkpointing.",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/yurun-yuan/pycheckpoint",
        "Issues": "https://github.com/yurun-yuan/pycheckpoint/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68dabf3612d46958ea7e85d92a83fc145c2005ce4c34a2014eaf80c4281216cc",
                "md5": "61d3c9f001abab6821535f324d2154bb",
                "sha256": "f53c2899d86c45acf146443330a0bb4c36bb11e8adca23bb7b3f3a7b3aa49231"
            },
            "downloads": -1,
            "filename": "pychequepoint-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "61d3c9f001abab6821535f324d2154bb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5844,
            "upload_time": "2024-08-30T18:07:45",
            "upload_time_iso_8601": "2024-08-30T18:07:45.432948Z",
            "url": "https://files.pythonhosted.org/packages/68/da/bf3612d46958ea7e85d92a83fc145c2005ce4c34a2014eaf80c4281216cc/pychequepoint-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a7bd3f2dab999801bca48f65da3eeacdf1eeb1ded335dfdfae0fcb7e8ca84fdd",
                "md5": "af37e7cf67176775b09a208ada0fa431",
                "sha256": "40481eccf98f4d66da7f41bed92733217ee05fde27e80c13f6ebf179f7041a74"
            },
            "downloads": -1,
            "filename": "pychequepoint-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "af37e7cf67176775b09a208ada0fa431",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 4945,
            "upload_time": "2024-08-30T18:07:46",
            "upload_time_iso_8601": "2024-08-30T18:07:46.954808Z",
            "url": "https://files.pythonhosted.org/packages/a7/bd/3f2dab999801bca48f65da3eeacdf1eeb1ded335dfdfae0fcb7e8ca84fdd/pychequepoint-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-30 18:07:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yurun-yuan",
    "github_project": "pycheckpoint",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pychequepoint"
}
        
Elapsed time: 0.73834s