Saravanan666/pypi-org huggingface dataset:
Package: cached-path
cached-pathA file utility library that provides a unified, simple interface for accessing both local and remote files.
This can be used behind other APIs that need to access files agnostic to where they are located.Quick linksDocumentationPyPI PackageContributingLicenseInstallationcached-pathrequires Python 3.7 or later.Installing withpipcached-pathis availableon PyPI. Just runpipinstallcached-pathInstalling from sourceTo installcached-pathfrom source, first clonethe repository:gitclonehttps://github.com/allenai/cached_path.gitcdcached_pathThen runpipinstall-e.Usagefromcached_pathimportcached_pathGiven something that might be a URL or local path,cached_path()determines which.
If it's a remote resource, it downloads the file and caches it to thecache directory, and
then returns the path to the cached file. If it's already a local path,
it makes sure the file exists and returns the path.For URLs,http://,https://,s3://(AWS S3),gs://(Google Cloud Storage), andhf://(HuggingFace Hub) are all supported out-of-the-box.
Optionallybeaker://URLs in the form ofbeaker://{user_name}/{dataset_name}/{file_path}are supported, which requiresbeaker-pyto be installed.For example, to download the PyTorch weights for the modelepwalsh/bert-xsmall-dummyon HuggingFace, you could do:cached_path("hf://epwalsh/bert-xsmall-dummy/pytorch_model.bin")For paths or URLs that point to a tarfile or zipfile, you can also add a path
to a specific file to theurl_or_filenamepreceeded by a "!", and the archive will
be automatically extracted (provided you setextract_archivetoTrue),
returning the local path to the specific file. For example:cached_path("model.tar.gz!weights.th",extract_archive=True)Cache directoryBy default the cache directory is~/.cache/cached_path/, however there are several ways to override this setting:set the environment variableCACHED_PATH_CACHE_ROOT,callset_cache_dir(), orset thecache_dirargument each time you callcached_path().Teamcached-pathis developed and maintained by the AllenNLP team, backed bythe Allen Institute for Artificial Intelligence (AI2).
AI2 is a non-profit institute with the mission to contribute to humanity through high-impact AI research and engineering.
To learn more about who specifically contributed to this codebase, seeour contributorspage.Licensecached-pathis licensed underApache 2.0.
A full copy of the license can be foundon GitHub.
Package: cachedprop
cachedpropcached property method decoratorDemofromcachedpropimportcpdclassLabRat:def__init__(self)->None:self._hp=Nonedefexpensive_hp_getter(self)->int:...@cpddefhp(self):returnself.expensive_hp_getter()rat=LabRat()print(rat.hp)# expensive_hp_getter is called, value gets "cached", prints valueprint(rat.hp)# prints "cached" value only.
Package: cached-property-bel
Cached PropertyThis module adds a decoratorcached_propertyand a functiondrop_cache.Examplefromcached_propertyimportcached_property,drop_cacheimporttimeclassDummy:@cached_propertydefthe_answer(self):time.sleep(0.5)return42dummy=Dummy()t0=time.time()err=dummy.the_answerdt=time.time()-t0print(dt)# dt -> ~0.5 secondst0=time.time()err=dummy.the_answerdt=time.time()-t0print(dt)# dt -> ~1e-6 secondsdrop_cache(dummy,'the_answer')t0=time.time()err=dummy.the_answerdt=time.time()-t0print(dt)# dt -> ~0.5 secondsLicense and CopyrightCopyright 2019 Brain Electrophysiology Laboratory Company LLCLicensed under the Apache License, Version 2.0 (the "License");
you may not use this module or the code  within it except in
compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Package: cache-em-all
A simple decorator to cache the results of function calls.Installationpipinstallcache_em_allExamplefromcache_em_allimportCachable@Cachable("answer.json")defanswer_to(question):ifquestion=="life":importtimetime.sleep(236500000000000)return42answer_to("life")# Takes 7.5 million yearsanswer_to("life")# Pretty much instantAfter the first call toanswer_to, the result of the function is
stored in a filecache/answer/answer__life.json. When the function
is called again (with the same parameters), instead of executing the
function, the decorator will get the result from the file.Advanced usageFile typesVarious file types are supported.extensionDescriptioncsvUses pandas to save the
result in a csv file.
The return value for the
function must be a
DataFrame or Series.jsonSaves the result in a
json file. Useful for
lists, dictionaries and
primitive types.pklPickles the return
value. Return type can
be just about anything.
May not work well for
large (>~2GB) filespaUses pyarrow to save
files. This is generally
faster than pkl and
supports larger files
(tested up to 50GB)VersioningTheCachabledecorator can accept a version number. This is useful
for when you update a function. For example,You had the following code:fromcache_em_allimportCachable@Cachable("add.json")defadd(x,y):returnx+xThis is a bug (should bex+y, notx+x), but you’ve run this
function multiple times and there are lots of cached results. Rather
than manually deleting the cache folder, you can bump the version number
(version numbers start at 0).fromcache_em_allimportCachable@Cachable("add.json",version=1)defadd(x,y):returnx+yNow next time the function is called it will invalidate the cache and
re-run the function.Do not use this feature in multi-processing code because the writes to
the version file do not (yet) use locks.FolderBy default all cached files are stored in a folder calledcache.
This can be changed for each function by passingfoldertoCachable.fromcache_em_allimportCachable@Cachable("add.json",folder="/mnt/ram/fastcache")defadd(x,y):returnx+yYou can also change the default cache dir so that all cache files are by
default saved elsewhere.fromcache_em_allimportCachable,set_cache_dirset_cache_dir("/mnt/huge_hdd")@Cachable("add.json")defadd(x,y):returnx+yDisable cacheYou can also disable the cache by settingusetoFalse.fromcache_em_allimportCachable@Cachable("add.json",use=False)defadd(x,y):returnx+yThis can be useful for debugging or optmizing the function.
Package: cacheflow
CacheFlow is a caching workflow engine, capable of executing dataflows while
reusing previous results where appropriate, for efficiency. It is very
extensible and can be used in many projects.Goals☑ Python 3 workflow system☑ Executes dataflows from JSON or YAML files☐Can also load from SQL database☐Parallel execution☐Streaming/batching☑ Extensible: can add new components, new storage formats, new caching mechanism, new executors☐ Pluggable: extensions can be installed from PyPI without forking☑ Re-usable: can execute workflows by itself, but can also be embedded into applications. Some I plan on developing myself:☑Literate programming app: snippets or components embedded into a markdown file, which are executed on render (similar to Rmarkdown). Results would be cached, making later rendering fast☐ Integrate in some of my NYU research projects (VisTrails, Vizier, D3M)☐Web-based interface allowing collaborative edition of workflows, with automatic re-execution on changeOther ideas:☐ Use Jupyter kernels as backends to execute code (giving me quick access to all the languages they support)☐ Isolate script execution (to run untrusted Python/… code, for example with Docker)Non-goalsMake a super-scalable and fast workflow execution engine: I’d rathermake executors based on Spark, Dask, Raythan try to re-implement those from scratch.StatusBasic structures are here, extracted from D3M. Execution works. Very few components available. Working on web interface.
Package: cachefly
The CacheFly CDN exposes an HTTP based API for forcefully purging content from their reverse proxying CDN solution. Thecacheflymodule provides a simple interface for performing those actions.Furthermore, thedjango_cacheflymodule provides a convient way to configure and access an application wide API client instance through your Django settings.InstallationTo installcacheflyanddjango_cachefly, do yourself a favor and don’t use anything other thanpip:$pipinstallcacheflyInstallation in DjangoAfter the module has been installed, you need to adddjango_cacheflyto your list ofINSTALLED_APPSin your application configuration:INSTALLED_APPS=(...'django_cachefly',)You also need to configure your CacheFly API key in your application’s settings file:CACHEFLY_API_KEY='..'The CacheFly API client can now be easily accessed from the entire application:fromdjango_cacheflyimportclient...TestingTesting requires a set of valid credentials. All tests are performed against URLs in the/_testingpath for the CDN node your select. Credentials are loaded from the environment during testing for security:CACHEFLY_API_KEYAPI key to use for testing.
Package: cachefunc
cachefuncCaching functions and coroutines result with decoratorsUsageBasic usage with default dict cache:importaiohttpimportasyncioimportrequestsfromcachefuncimportcachefunc,cachecoro@cachefunc()defyour_func(url):response=requests.get(url)returnresponse.text@cachecoro()asyncdefyour_async_func(url):asyncwithaiohttp.ClientSession()assession:asyncwithsession.get(url)asresponse:html=awaitresponse.text()returnhtmlThere are two available caches - dict and redis:fromcachefuncimportcachefunc,DictCache,RedisCachedict_cache=DictCache()redis_cache=RedisCache()@cachefunc(dict_cache)defyour_func_cached_in_dict(url):response=requests.get(url)returnresponse.text@cachefunc(redis_cache)defyour_func_cached_in_redis(url):response=requests.get(url)returnresponse.textFor DictCache it is possible to setup distinct timeout for each function:fromdatetimeimporttimedelta@cachefunc(dict_cache,timeout=timedelta(hours=2))defyour_func_cached_for_two_hours(url):response=requests.get(url)returnresponse.text@cachefunc(dict_cache,timeout=timedelta(minutes=10))defyour_ohter_func_cached_for_ten_minutes(connection,query):cursor=connection.execute(query)returncursor.fetchall()Also custom cache can be created from BaseCache, you should implement
methods _get() and _set():fromcachefuncimportBaseCacheclassCustomCache(BaseCache):def_get(self,key:int)->Any:...def_set(self,key:int,result:Any,**kwargs)->None:...LicenseMIT
Package: cache-function-deepakmishra
Cache FunctionYou can use this python decoratorGithub-flavored Markdownto cache a result of a function.Installationpip install -ihttps://test.pypi.org/simple/cache-function-deepakmishraUsageProduction Settingfromcache_functionimportcache_functioncache_function.cache=**yourcacheobjectwhichhasgetandsetfunctions**Development Settingfromcache_functionimportcache_function,test_cache_functioncache_function.cache=test_cache_function.DummyCache()Usage: Cache a function resultfromcache_function.cache_functionimportcache_function@cache_function(expiry=30)# time in secondsdeffoo(a,b,c):returna+b+c
Package: cachegenius
CacheGeniusSpeed-up your code by automatically identifying functions that should use caching!View Demo·Report BugAbout The ProjectHave you ever spent hours trying to speed up some code, only to finally realize you're computing the same things 2 or 3 times, which means some caching does the trick ? What a waste of time !🧞‍♂️ CacheGenius automatically identifies functions that should use caching in your code, so you can speed-up your code effortlessly!Getting StartedUsing CacheGenius is very simple.Install CacheGenius with pip :pipinstallcachegeniusTo analyse an entire modulemypackage, with all the functions and methods it contains, add this lines at the begginning of your code:importmypackageimportcachegeniuscachegenius(mypackage)Now, use your module functions as usual. CacheGenius will automatically analyze all the functions you call, and will tell you if you should use caching or not.>>> cachegenius.report()
Function: mokemodule.mokescript.my_func
Should cache: TrueAdvanced usageYou can use the different parameters ofcachegenius.report()to change the temporary files path, and print more infos usingdebug.Two parameters are available to tune the cost of computing and memory, that are used to decide if caching is worth it or not.defreport(autocache_path:str="cachegenius_data/",debug:bool=True,cost_per_comput_hr:float=0.1,# $/hrcost_per_mem_gb:float=0.2# $/gb)You can clean all temporary files withcachegenius.empty().(back to top)How to contributeContributing is an awesome way to learn, inspire, and help others. Any contributions you make aregreatly appreciated, even if it's just about styling and best practices.If you have a suggestion that would make this project better, please fork the repo and create a pull request.Don't forget to give the project a star! Thanks again!Fork the ProjectCreate your Feature Branch (git checkout -b feature/YourAmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestAuthorsThis library was created byNicolas MICAUX.
Package: cache-guiosoft
CACHE GUIOSOFTCaching data using files, Redis or local SQLite[]Local files for cachingfromcache_gsimportCacheGS# Storage on local directoryfile_cache=CacheGS('path://directory_for_cache_storage')# Storage on local SQLite databaseslite_cache=CacheGS('sqlite://directory_or_file_for_storage')# Storage on Redisredis_cache=CacheGS('redis://host:6379')[Moreoptionsforredis](#Redis options and example)UsageLike INI files, data is grouped in section/key names.Installingpipinstallcache-guiosoftWriting valuecache.set_value(section,key,value,ttl:int=0)# ttl is the life time of value in seconds from the time is createdReading valuevalue=cache.get_value(section,key,default=None)Deleting valuecache.delete_value(section,key)Purging expired dataOnRediscache, this is handled by the server, automatically.OnSQLitecache, purging is executing on every instantiation.OnLocal Filecache, purging is automatically executed once a day, checked on every instantiation.Force purging expired datacache.purge_expired()Redis options and exampleRedis connection uses theredis-py componentfrom Andy McCurdy.
You can use the same connection strings that the Redis class uses:redis://[[username]:[password]]@localhost:6379/0rediss://[[username]:[password]]@localhost:6379/0unix://[[username]:[password]]@/path/to/socket.sock?db=0Three URL schemes are supported:

  - ```redis://``
    <http://www.iana.org/assignments/uri-schemes/prov/redis>`_ creates a
    normal TCP socket connection
  - ```rediss://``
    <http://www.iana.org/assignments/uri-schemes/prov/rediss>`_ creates a
    SSL wrapped TCP socket connection
  - ``unix://`` creates a Unix Domain Socket connection

  There are several ways to specify a database number. The parse function
  will return the first specified option:
      1. A ``db`` querystring option, e.g. redis://localhost?db=0
      2. If using the redis:// scheme, the path argument of the url, e.g.
         redis://localhost/0
      3. The ``db`` argument to this function.

  If none of these options are specified, db=0 is used.Redis on dockerdocker-compose.yamlredis:container_name:'redis'image:'redis:4-alpine'command:redis-server --requirepass 1234ports:-'6379:6379'For testing, just run:docker-composeup
Package: cacheing
cacheing - Pure Python Cacheing LibraryMotivationThe initial motivation behind this package was twofold: fix the long insertion/eviction times incachetools.LFUCacheand provide an alternative to thecachetools.TTLCacheoffering variable per-key TTL's.Installationpip install -U cacheingAnd then in your python interpreter:importcacheingUpdatingUsage>>>fromcacheingimportLFUCache>>>cache=LFUCache(capacity=2)>>>cache[1]=2>>>cache[2]=3>>>cache[3]=4>>>cacheLFUCache{2:3,3:4}Benchmarkcacheing has an included benchmarking library found in./benchmark.$python3./benchmark.py--help

usage:benchmark[-h][--cache[CACHE[CACHE...]]][--method[{get,set,delete}[{get,set,delete}...]]]arguments:-h,--helpshowthishelpmessageandexit--cache[CACHE[CACHE...]],-c[CACHE[CACHE...]]cache(s)tobenchmark.example:cacheing.LRUCache.--method[{get,set,delete}[{get,set,delete}...]],-m[{get,set,delete}[{get,set,delete}...]]method(s)tobenchmark.Run the Benchmarks:$cdbenchmark

$python3./benchmark.py--cachecachetools.LRUCachecacheing.LRUCache--methodsetgetdeletePerformanceAll benchmark times were measured using the providedbenchmarklibrary. See thebenchmark sectionfor details. The default benchmarking configuration executes 100,000 get operations,
20,000 set operations andn = cache_sizedelete operations. The median, p90, and p99 times for each
operation, measured in microseconds, or1e-6, are displayed in the figures below.Get (LFU Cache)                         Delete (LFU Cache)Set (LFU Cache)                        Set - Cross Section (LFU Cache)Set (LRU Cache)                         Get (LRU Cache)Delete (LRU Cache)
Package: cache_it
cache_it====__cache_it__ is a decorator which wraps caching(read/write) routine.Decorated functions automatically access your memcache and get/set values depending on the situation.All you have to do is decorate your function by __@cache_it__.## Basic Usage```python>>> from cache_it import init_cache, cache_it>>> init_cache(['127.0.0.1:11211'])>>> @cache_it(prefix='PREFIX:')>>> def cached_function(key):>>>     return 'value'>>> cached_function('key')'value' # cached => key:'PREFIX:key' value:'value'>>> cached_function('key')'value' # getting from a cache```## As a methodYou can decorate not only functions but also methods in the same way.```pythonclass User(Document)@cache_it(prefix='PREFIX')def __getitem__(self, key):return user[key]```## ignore_exception (False by default)If you want to ignore exceptions occured when accessing memcache, you have to set "ignore_exception" into True.```python@cache_it(prefix='PREFIX', ignore_exception=True)def cached_function(key):return 'value'```## ttl (24*60*60 sec by default)```python@cache_it(prefix='PREFIX', ttl=60) # 60secdef cached_function(key):return 'value'```## encoder/decoderEncoders are called before setting a value.Decoders, on the other hand, are called after getting a value.```python@cache_it(prefix='PREFIX',encoder=lambda x: x['foo'],decoder=lambda x: {'foo': x})def cached_function(key):return {'foo': 'bar'}```
Package: cachel
Fast caches for python.Features:Sync and async caches (cachel.base.BaseCacheandcachel.base.AsyncBaseCache).Cache decorator supports sync and async (for python >= 3.5) functions.Batched requests via.objectsdecorator method.Explicit cache keys.Custom ttl for returned values (cachel.expire).Configurable serializers: (none, unicode, json/ujson, msgpack, pickle).
Package: cachelib
A collection of cache libraries in the same API interface. Extracted
from Werkzeug.InstallingInstall and update usingpip:$ pip install -U cachelibDonateThe Pallets organization develops and supports Flask and the libraries
it uses. In order to grow the community of contributors and users, and
allow the maintainers to devote more time to the projects,please
donate today.LinksDocumentation:https://cachelib.readthedocs.io/Changes:https://cachelib.readthedocs.io/changes/PyPI Releases:https://pypi.org/project/cachelib/Source Code:https://github.com/pallets/cachelib/Issue Tracker:https://github.com/pallets/cachelib/issues/Twitter:https://twitter.com/PalletsTeamChat:https://discord.gg/pallets
Package: cachelite
DocumentationThe full documentation is athttps://cachelite.readthedocs.org/QuickstartInstall cachelite:pip install cacheliteThen you can use it.importcachelitefromCacheLitecache=CacheLite("/tmp/YOUR_TO_CACHE_DIR")#put a key-valuecache["YOUR_KEY"]="YOUR_VALUE"#get a valuevalue=cache["YOUR_KEY"]#delete a valuedelcache["YOUR_KEY"]#get size of data entrieslen(cache)#iterationforaincache:print(a)
Package: cachelock
python-cachelock================[![Supported Versions](https://img.shields.io/pypi/pyversions/cachelock.svg)](https://pypi.python.org/pypi/cachelock)[![Build Status](https://travis-ci.org/douglasfarinelli/python-cachelock.svg?branch=master)](https://travis-ci.org/douglasfarinelli/python-cachelock)[![Coverage Status](https://coveralls.io/repos/github/douglasfarinelli/python-cachelock/badge.svg?branch=master)](https://coveralls.io/github/douglasfarinelli/python-cachelock?branch=master)[![PyPI version](https://badge.fury.io/py/cachelock.svg)](https://pypi.python.org/pypi/cachelock)The `cachelock` serves to ensure that your code block or function is executed one at a time using the cache as acquirer.How to install:===============pip install cachelockorpipenv install cachelockHow to use==========You can use of two forms:- Use the `Lock` class to your blocks;- Or use the decorator `once` to block your functions or tasks;With cachelock.Lock===================Arguments:with cachelock.Lock(key=...cache=...,) ...You should use the Lock class as with context:with cachelock.Lock(key='foo'):...your code ...If it is already locked, the LockError will be raised.With cachelock.once===================Arguments:@cachelock.once(key=...cache=...,raises_if_lock=False)...With the decorator, you can guarantee the unique execution of some function. It also allows you to configure your key according to the arguments of the function.@celery.task@cachelock.once(key='foo-{arg_a}-{arg_b}')def func(arg_a, arg_b):passThat way, if it is locked, the function quits silently. You can also ask `once` to raise `LockError`:@celery.task@cachelock.once(key='foo-{arg_a}-{arg_b}',raise_if_lock=True)def func(arg_a, arg_b):passIntegrate with Django=====================The cachelock checks whether django is installed, and if so, it uses django's own cache as aquirer. And if you wish, you can modify the default cache with `DEFAULT_CACHELOCK_ALIAS` configuration through django settings. The value must be an alias of some existing cache, by default it uses `default`*Remembering that by `default`, `cachelock` uses its own internal cache in memory if there is no integration with `django`.*Customizing your own cache==========================To work it is necessary that the implementation of the cache has the `get`, `delete` and `set` methods. Ex.:class DummyCache:def set(self, key, value):passdef get(self, key, default=None):passdef delete(self, key):passcache = DummyCache()use:@cachelock.once(key=..., cache=cache)orwith cachelock.Lock(key..., cache=cache) ...