{ "info": { "author": "ianlini", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Topic :: Utilities" ], "description": "Please visit the `GitHub repository `_\nfor more information.\n\nSerialTime\n==========\n.. image:: https://img.shields.io/travis/ianlini/serialtime/master.svg\n :target: https://travis-ci.org/ianlini/serialtime\n.. image:: https://img.shields.io/pypi/v/serialtime.svg\n :target: https://pypi.python.org/pypi/serialtime\n.. image:: https://img.shields.io/pypi/l/serialtime.svg\n :target: https://pypi.python.org/pypi/serialtime\n\nSerialTime is a Python serialization tool containing many serialization and deserialization shortcuts with timing. There are many modules that can serialize Python object such as:\n\n- `Joblib `_\n- `PyYAML `_\n- `Python built-in pickle/cPickle `_\n- `Python built-in json `_\n- `Python built-in pickle/cPickle + gzip `_\n\nHowever, remembering their API is very difficult, and there are many differences in their API.\nFor example, ``json.dump`` only accept file-like object as its argument, so we need to open the file first, and then give the function the file-like object, while ``joblib.dump`` only accept file path as its argument.\nBesides, there is no compression shortcut for Python built-in pickle/cPickle, so we also need to remember how to use something like gzip.\n\nThis package aims to solve these problems and provides very simple and unified API shortcuts for some popular serialization methods.\nIn addition, we use `BisTiming `_ to calculate the execution time, so you can also easily know how quick the serialization is.\n\n\nInstallation\n------------\n- Install ``serialtime``\n\n .. code:: bash\n\n pip install serialtime\n\n- If you want to use ``save_joblib_pkl`` or ``load_joblib_pkl``:\n\n .. code:: bash\n\n pip install scikit-learn scipy\n\n- If you want to use ``try_load_yaml``:\n\n .. code:: bash\n\n pip install PyYAML\n\n\nDocumentation\n-------------\n\nShortcuts\n+++++++++\n- Python built-in pickle/cPickle\n\n .. code:: python\n\n serialtime.save_pkl(obj, path, log_description=None, logger=None,\n logging_level=logging.INFO, verbose_start=True,\n verbose_end=True, end_in_new_line=True, log_prefix=\"...\")\n\n .. code:: python\n\n obj = serialtime.load_pkl(path, log_description=None, logger=None,\n logging_level=logging.INFO, verbose_start=True,\n verbose_end=True, end_in_new_line=True, log_prefix=\"...\")\n\n- Python built-in pickle/cPickle + gzip\n\n .. code:: python\n\n serialtime.save_pklgz(obj, path, log_description=None, logger=None,\n logging_level=logging.INFO, verbose_start=True,\n verbose_end=True, end_in_new_line=True, log_prefix=\"...\")\n\n .. code:: python\n\n obj = serialtime.load_pklgz(path, log_description=None, logger=None,\n logging_level=logging.INFO, verbose_start=True,\n verbose_end=True, end_in_new_line=True, log_prefix=\"...\")\n\n- Joblib\n\n .. code:: python\n\n serialtime.save_joblib_pkl(obj, path, log_description=None, logger=None,\n logging_level=logging.INFO, verbose_start=True,\n verbose_end=True, end_in_new_line=True, log_prefix=\"...\")\n\n .. code:: python\n\n obj = serialtime.load_joblib_pkl(path, log_description=None, logger=None,\n logging_level=logging.INFO, verbose_start=True,\n verbose_end=True, end_in_new_line=True, log_prefix=\"...\")\n\nInteractive trying of loading YAML\n++++++++++++++++++++++++++++++++++\nSometimes we want to load the configuration file in the middle of a program.\nIf we run the program very long and the file format is incorrect, the program may directly raise an error and exit, so we don't have any chance to fix the file.\n``serialtime.try_load_yaml`` can try to load the file, and pause when it encounter any error, and ask you whether to reload the file.\nWe can then fix the file and continue running the program.\n\n.. code:: python\n\n serialtime.try_load_yaml(yaml_path)\n\nDataset wrapper\n+++++++++++++++\n``PartialPreprocessedDataset`` is used to transparrently reindex the data without moving or copying the original memory.\n\nSometimes we want to reindex the data, for example:\n\n.. code:: python\n\n In [1]: import numpy as np\n\n In [2]: dset = np.asarray([1, 2, 3])\n\n In [3]: dset\n Out[3]: array([1, 2, 3])\n\n In [4]: idx = [2, 0]\n\n In [5]: dset2 = dset[idx]\n\n In [6]: dset2\n Out[6]: array([3, 1])\n\nHowever, if the data is very large or it's on disk, this may use too much memory.\nWe may not need all the convenient API in ``numpy.ndarray`` or ``h5py.dataset``, but some modules only accept a full ``numpy.ndarray`` or ``h5py.dataset`` (i.e., ``keras.image.ImageDataGenerator.flow()``).\nOur solution is to use an object to remember the new index, and translate the index while getting the value. For example:\n\n.. code:: python\n\n In [1]: import numpy as np\n\n In [2]: from serialtime import PartialPreprocessedDataset\n\n In [3]: dset = np.asarray([[0, 1], [2, 3], [4, 5]])\n\n In [4]: dset\n Out[4]:\n array([[0, 1],\n [2, 3],\n [4, 5]])\n\n In [5]: idx = [2, 0]\n\n In [6]: dset2 = PartialPreprocessedDataset(dset, idx, shape=(2,), preprocess_func=lambda x: x*2)\n\nWe can also use an optional ``preprocess_func`` to preprocess the instance while we are getting it.\nIn this example, we just double the values in the array.\nThe ``shape`` we give to ``PartialPreprocessedDataset`` is the shape of one instance (the shape of the array that we can get after ``preprocess_func(dset[x]))``. Then we can do something like:\n\n.. code:: python\n\n In [7]: dset2.shape\n Out[7]: (2, 2)\n\n In [8]: len(dset2)\n Out[8]: 2\n\n In [9]: dset2[0]\n Out[9]: array([ 8, 10])\n\n In [10]: dset2[1]\n Out[10]: array([0, 2])\n\n In [11]: dset2[2]\n IndexError: list index out of range\n\nTesting\n-------\n- For the current environment: ``python setup test``.\n- For Python 2.7, 3.4, 3.5, 3.6 and installation test: ``tox``.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ianlini/serialtime", "keywords": "", "license": "BSD 2-Clause License", "maintainer": "", "maintainer_email": "", "name": "serialtime", "package_url": "https://pypi.org/project/serialtime/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/serialtime/", "project_urls": { "Homepage": "https://github.com/ianlini/serialtime" }, "release_url": "https://pypi.org/project/serialtime/0.1.1/", "requires_dist": [ "bistiming", "numpy", "six" ], "requires_python": "", "summary": "A Python serialization tool containing many serialization and deserialization shortcuts with timing.", "version": "0.1.1" }, "last_serial": 2636644, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "fe75034e6d64b49950dfc8e923937ef1", "sha256": "44427370b1c69d1973f480d578da67421900bbc4ab08a5b9f07ea3ea2408ffaa" }, "downloads": -1, "filename": "serialtime-0.1.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fe75034e6d64b49950dfc8e923937ef1", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8014, "upload_time": "2016-10-18T11:07:18", "url": "https://files.pythonhosted.org/packages/10/c3/9ca2e46ed085e442a7994af3f0e409698b9fe0004072cb815b53ae36c49a/serialtime-0.1.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "65908626976d36db1da57f7fed7d718b", "sha256": "3126aa5c01b2cee6a71f4447fddab8297ba100174a13594e60a8d47ab46132d0" }, "downloads": -1, "filename": "serialtime-0.1.0.tar.gz", "has_sig": false, "md5_digest": "65908626976d36db1da57f7fed7d718b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4568, "upload_time": "2016-10-18T11:07:21", "url": "https://files.pythonhosted.org/packages/47/0a/3b47b24f73aff5460c3a62b1d9f05730819ce485e3a3906c36b918d38c78/serialtime-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "dcd2ff941e076391d12ce26f2f454af9", "sha256": "a85d9acfb078b163e234c493f28b15c2d1a544bdf8e375d9e9093bd71f0c7dfe" }, "downloads": -1, "filename": "serialtime-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dcd2ff941e076391d12ce26f2f454af9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8023, "upload_time": "2017-02-12T13:41:29", "url": "https://files.pythonhosted.org/packages/57/bd/eae66ab2451d6cde751b7cc1c71a3093ba7457222f05929a9270af54c501/serialtime-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c261a3c0f3d4a264f99b28846fc48f3a", "sha256": "490a96d0f877202e8a196d42d43f10834df34e443f8e9981f6882f990da834e4" }, "downloads": -1, "filename": "serialtime-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c261a3c0f3d4a264f99b28846fc48f3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4890, "upload_time": "2017-02-12T13:41:31", "url": "https://files.pythonhosted.org/packages/da/3b/9177729a593d259667a1b076060d2ee99727e08ed995fa34903dbe6fe1c3/serialtime-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dcd2ff941e076391d12ce26f2f454af9", "sha256": "a85d9acfb078b163e234c493f28b15c2d1a544bdf8e375d9e9093bd71f0c7dfe" }, "downloads": -1, "filename": "serialtime-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "dcd2ff941e076391d12ce26f2f454af9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8023, "upload_time": "2017-02-12T13:41:29", "url": "https://files.pythonhosted.org/packages/57/bd/eae66ab2451d6cde751b7cc1c71a3093ba7457222f05929a9270af54c501/serialtime-0.1.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c261a3c0f3d4a264f99b28846fc48f3a", "sha256": "490a96d0f877202e8a196d42d43f10834df34e443f8e9981f6882f990da834e4" }, "downloads": -1, "filename": "serialtime-0.1.1.tar.gz", "has_sig": false, "md5_digest": "c261a3c0f3d4a264f99b28846fc48f3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4890, "upload_time": "2017-02-12T13:41:31", "url": "https://files.pythonhosted.org/packages/da/3b/9177729a593d259667a1b076060d2ee99727e08ed995fa34903dbe6fe1c3/serialtime-0.1.1.tar.gz" } ] }