{ "info": { "author": "Chris Piatt", "author_email": "chris@pyython.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 7 - Inactive", "Framework :: Jupyter", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: Other/Proprietary License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "cache-magic\n===========\n\nThis package adds ``%cache`` line-magic to Jupyter notebooks.\n\nWarning!!!\n----------\n\nThe author of this Python package makes no commitment to maintain it. It\nwas forked from `this\nproject `__ and\nyou\u2019re probably better off using that! That said, if you like the tweaks\nI made (added compression, bug fixes, style preferences, etc.), feel\nfree to use it how you see fit. Just be sure to respect the original\nauthor\u2019s license (see LICENSE copied\n`here `__\nfor your convenience).\n\nQuickstart\n----------\n\n- The pip-package is called ``cache-magic``\n- The python module is called ``cache_magic``\n- The magic is called ``%cache``\n\nSo you can run the magic by entering this into an Jupyter cell:\n\n.. code:: python\n\n !pip install cache-magic\n import cache_magic\n %cache a = 1+1\n %cache\n\ninstallation\n============\n\ninstall directly from notebook\n------------------------------\n\n1. open jupyter notebook\n2. create new cell\n3. enter ``!pip install cache-magic``\n4. execute\n\ninstall into conda-environment\n------------------------------\n\n.. code:: bash\n\n conda create -n test\n source activate test\n conda install -c pyython cache-magic\n jupyter notebook\n\nusage\n=====\n\nActivate the magic by loading the module like any other module. Write\ninto a cell ``import cache_magic`` and excecute it.\n\nWhen you want to apply the magic to a line, just prepend the line with\n``%cache``\n\nexample\n-------\n\n::\n\n %cache myVar = someSlowCalculation(some, \"parameters\")\n\nThis will calculate ``someSlowCalculation(some, \"parameters\")`` once.\nAnd in subsequent calls it restores myVar from storage.\n\nThe magic turns this example into something like this (if there was no\nipython-kernel and no versioning):\n\n.. code:: python\n\n try:\n with open(\"myVar.pkl.gz\", 'rb') as fp:\n myVar = pickle.loads(zlib.decompress(fp.read()))\n except:\n myVar = someSlowCalculation(some, \"parameters\")\n with open(\"myVar.pkl.gz\", 'wb') as fp:\n fp.write(zlib.compress(pickle.dumps(myVar)))\n\ngeneral form\n------------\n\n::\n\n %cache = \n\n**Variable**: This Variable\u2019s value will be fetched from cache.\n\n**Expression**: This will only be excecuted once and the result will be\nstored to disk.\n\nfull form\n---------\n\n::\n\n %cache [--version ] [--reset] [--debug] variable [= ]\n\n**-v or \u2013version**: either a variable name or an integer. Whenever this\nchanges, a new value is calculated (instead of returning an old value\nfrom the cache).\n\nif version is \u2018\\*\u2019 or omitted, the hashed expression is used as version,\nso whenever the expression changes, a new value is cached.\n\n**-r or \u2013reset**: delete the cached value for this variable. Forces\nrecalculation, if ```` is present\n\n**-d or \u2013debug**: additional logging\n\nshow cache\n----------\n\n.. code:: python\n\n %cache\n\nshows all variables in cache as html-table\n\nfull reset\n----------\n\n.. code:: python\n\n %cache -r\n %cache --reset\n\ndeletes all cached values for all variables\n\nwhere is the cache stored?\n--------------------------\n\nIn the directory where the kernel was started (usually where the\nnotebook is located) in a subfolder called ``.cache``\n\ndeveloper Notes\n===============\n\npush to pypi\n------------\n\nprepare environment:\n\n.. code:: bash\n\n gedit ~/.pypirc\n chmod 600 ~/.pypirc\n sudo apt install pandoc\n\nupload changes to test and production:\n\n.. code:: bash\n\n pandoc -o README.rst README.md\n restview --pypi-strict README.rst\n # update version in setup.py\n rm -r dist\n python setup.py sdist\n twine upload dist/* -r testpypi\n firefox https://testpypi.python.org/pypi/cache-magic\n twine upload dist/*\n\ntest install from testpypi\n\n.. code:: bash\n\n pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple cache-magic --no-cache-dir --user\n\ntest installation\n\n.. code:: bash\n\n sudo pip install cache-magic --no-cache-dir --user\n\neditable import\n---------------\n\nInstall into environment with ``-e``:\n\n.. code:: python\n\n !pip install -e .\n\nreload after each change:\n\n.. code:: bash\n\n import cache_magic\n from imp import reload\n reload(cache_magic)\n\nAlternatively (if you don\u2019t want to install python, jupyter & co), you\ncan use the docker-compose.yml for development:\n\n.. code:: bash\n\n cd cache-magic\n docker-compose up\n\ncreate Conda Packet\n-------------------\n\nrequires the bash with latest anaconda on path\n\n.. code:: bash\n\n bash\n mkdir test && cd test\n conda skeleton pypi cache-magic\n conda config --set anaconda_upload yes\n conda-build cache-magic -c conda-forge\n\nrunning tests\n-------------\n\n.. code:: bash\n\n bash\n conda remove --name test --all\n conda env create -f test/environment.yml\n source activate test\n conda remove cache-magic\n pip uninstall cache-magic\n pip install -e .\n ./test/run_example.py\n\nIf there is any error, it will be printed to stderr and the script\nfails.\n\nthe output can be found in \u201ctest/temp\u201d.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pyython/cache-magic", "keywords": "", "license": "BSD-3-Clause", "maintainer": "", "maintainer_email": "", "name": "cache-magic", "package_url": "https://pypi.org/project/cache-magic/", "platform": "", "project_url": "https://pypi.org/project/cache-magic/", "project_urls": { "Homepage": "https://github.com/pyython/cache-magic" }, "release_url": "https://pypi.org/project/cache-magic/1.0.4/", "requires_dist": null, "requires_python": "", "summary": "Versatile cache line magic for jupyter notebooks, based on https://pypi.org/project/ipython-cache/", "version": "1.0.4" }, "last_serial": 4145426, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "0979a874e26f0ff78f62773d72528330", "sha256": "f0ad0e6cd554ca0059d1bdf1a897f30aad7b7d48070914df3265c0c75a262f7c" }, "downloads": -1, "filename": "cache-magic-1.0.0.tar.gz", "has_sig": false, "md5_digest": "0979a874e26f0ff78f62773d72528330", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7032, "upload_time": "2018-08-06T04:40:20", "url": "https://files.pythonhosted.org/packages/38/60/16e96739c3a999525d85b19e54177a138b8e8514f645406c4f5cbc955d57/cache-magic-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "aec95bbcb227a54d3a4d933fd4b10d74", "sha256": "0885bf1c5acd60468d0b12300bbb7b4eaf92dc5a27942136f6008070c92f5651" }, "downloads": -1, "filename": "cache-magic-1.0.1.tar.gz", "has_sig": false, "md5_digest": "aec95bbcb227a54d3a4d933fd4b10d74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6781, "upload_time": "2018-08-07T17:09:30", "url": "https://files.pythonhosted.org/packages/14/1e/40c4cc805b36a083b16ecb21ceefc85a2c660e3775a7530575f87646e1a9/cache-magic-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "8bc646fe31ed4da39a20374654dd1c0e", "sha256": "0281392b8ca032108f7c4d2c3ca79a943410f9a4bc0925c9d5657e9bbfc2c767" }, "downloads": -1, "filename": "cache-magic-1.0.2.tar.gz", "has_sig": false, "md5_digest": "8bc646fe31ed4da39a20374654dd1c0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7023, "upload_time": "2018-08-07T18:14:48", "url": "https://files.pythonhosted.org/packages/52/94/86b96ffbf4a7f0e9a16d4d65bd5a05e6e9476385ef163a494a2de724cc90/cache-magic-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "f35a1e0781f74b09236acf24c28ce81c", "sha256": "88fb0249cc02ff0282ed4a9aa98913c1ed603b3b195e067363a701e4b5d3bcd8" }, "downloads": -1, "filename": "cache-magic-1.0.3.tar.gz", "has_sig": false, "md5_digest": "f35a1e0781f74b09236acf24c28ce81c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7009, "upload_time": "2018-08-07T18:23:13", "url": "https://files.pythonhosted.org/packages/2c/38/03540467ad075a573ad6330193f38d9d157359af8394756f350cbd676df6/cache-magic-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "3e119b67f8f1c269a02567801986f41f", "sha256": "d74fd3be75bcb4e6f60edbdd7bb4fd280a63fd0179f052aa3bcad4f09fd4c816" }, "downloads": -1, "filename": "cache-magic-1.0.4.tar.gz", "has_sig": false, "md5_digest": "3e119b67f8f1c269a02567801986f41f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6991, "upload_time": "2018-08-07T18:28:54", "url": "https://files.pythonhosted.org/packages/03/94/4cbb25895b80704027453fca297825c0b5924b4ba7533329e0b32a4905a2/cache-magic-1.0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3e119b67f8f1c269a02567801986f41f", "sha256": "d74fd3be75bcb4e6f60edbdd7bb4fd280a63fd0179f052aa3bcad4f09fd4c816" }, "downloads": -1, "filename": "cache-magic-1.0.4.tar.gz", "has_sig": false, "md5_digest": "3e119b67f8f1c269a02567801986f41f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6991, "upload_time": "2018-08-07T18:28:54", "url": "https://files.pythonhosted.org/packages/03/94/4cbb25895b80704027453fca297825c0b5924b4ba7533329e0b32a4905a2/cache-magic-1.0.4.tar.gz" } ] }