Saravanan666/pypi-org huggingface dataset:
Package: ratelimit-anyio
This packages introduces a function decorator preventing a functions from being called more often than allowed.
This should prevent API providers from banning your applications by conforming to their rate limits.It's similar toratelimitwith the following differences:also handles async functionsaccepts multiple limits (burst mode)allows applying rate limit to many functionsallows assigning a costsleep_and_retry utility is a function and accepts a limit of retries (1 by default)Thanks toanyioit works under asyncio and trio event loops.Usagefromdatetimeimporttimedeltafromratelimit_anyioimport*limiter=RateLimiter((RateLimit(timedelta(seconds=10),10),RateLimit(timedelta(minutes=10),100),))@limiter(cost=1)asyncdeffunction():# Simulate a remote callimportasyncioawaitasyncio.sleep(3)This function can be called up to 100 times within 10 minutes, and 10 times within any 10 seconds (burst mode).
You can also declare functions cost (1 by default) which is useful when applying to more than one function, and they use the quota by different values
Package: rate-limit-async
安装方式pip install rate-limit-async使用说明基于redis-cell扩展的限流，使用该包需要安装redis-cell扩展，支持分布式限流。目前只支持异步方法的限流，使用方式如下：from ratelimit.decorators import async_rate_limit

# 这里的key_name必须要在一个服务中唯一，不然会有冲突
@async_rate_limit("key_name")
async def need_limit_method():
    ...修改配置from ratelimit.base.constants import RedisConfig, LimitConfig

# 这里是redis连接信息
RedisConfig.host = '127.0.0.1'
RedisConfig.port = 6379
RedisConfig.passwors = ''
RedisConfig.db = 0

# 这里是默认的限流配置
LimitConfig.service = 'default'         # 限流器所属服务
LimitConfig.total_quota = 100           # 总令牌桶数量
LimitConfig.quota = 3                   # 单位时间内生成的令牌数
LimitConfig.limit_second = 1            # 单位时间
LimitConfig.once_quota = 1              # 一次请求获取的令牌数
LimitConfig.default_handle = 'discard'  # 被限流时的处理方式，默认丢弃【discard丢弃；queue排队；retry重试】配置写在redis中在redis中可以根据实际情况配置限流信息，格式如下：
    "service": {
        "key_name": {
            "total_quota": 100,          # 令牌桶大小
            "limit_second": 10,          # 生成令牌的单位时间
            "limit_quota": 3,            # 单位时间内生成的令牌数量
            "once_quota": 1,             # 每次请求消费的令牌数量
            "handle": "discard",         # discard丢弃；queue排队；retry重试
            "handle_params": {},         # 处理方式对应的参数
        }
    }
这里的key_name要对应装饰器的key_name

handle_params的配置如下：
1、handle 为 discard 类型的，无需配置
2、handle 为 queue 类型的，配置如下：
    {
        "delay": 3,               # 延时执行时间，单位【秒】
        "limit_delay": 1,         # 执行再次被限制的情况下，延迟执行时间，单位【秒】
        "queue_type": "redis",    # 队列类型：redis【基于redis队列】、local【基于本地内存队列】
    }
3、handle 为 retry 类型的，配置如下：
    {
        "retry_count": 3,    # 重试次数
        "retry_wait": 0,     # 每次重试间隔，默认不等待，单位【秒】
        "current_count": 0,  # 当前已重试几次
    }
Package: rate_limited_queue
A Queue That Respects Rate Limits.The original prototype for this code was written to rate-limit calls to a
geocoding api viageopy.importgeopyfromrate_limited_queueimportRateLimitedQueue,RateLimitaddresses=open("some_file_of_addresses.txt").read().splitlines()# No more than ten addresses geocoded per secondrate_limit=RateLimit(duration=1,max_per_interval=10)geocoder=geopy.geocoder.OpenMapQuest()q=RateLimitedQueue(addresses,processing_function=geocoder.geocode,rate_limits=[rate_limit])# Grabs the geocoded locations, but doesn't process# more than ten per secondgeocoded_locations=q.process()Check outthe docsfor more information.InstallationIt’s upon PyPI, so just do a:pip install rate_limited_queueor:sudo pip install rate_limited_queue
Package: ratelimiter
Simple Python module providing rate limiting.OverviewThis package provides theratelimitermodule, which ensures that an
operation will not be executed more than a given number of times on a
given period. This can prove useful when working with third parties APIs
which require for example a maximum of 10 requests per second.UsageDecoratorfromratelimiterimportRateLimiter@RateLimiter(max_calls=10,period=1)defdo_something():passContext ManagerfromratelimiterimportRateLimiterrate_limiter=RateLimiter(max_calls=10,period=1)foriinrange(100):withrate_limiter:do_something()CallbackThe callback is called in its own thread, so your callback may usesleepwithout delaying the rate limiter.importtimefromratelimiterimportRateLimiterdeflimited(until):duration=int(round(until-time.time()))print('Rate limited, sleeping for{:d}seconds'.format(duration))rate_limiter=RateLimiter(max_calls=2,period=3,callback=limited)foriinrange(3):withrate_limiter:print('Iteration',i)Output:Iteration 0
Iteration 1
Rate limited, sleeping for 3 seconds
Iteration 2asyncioTheRateLimiterobject can be used in anasync withstatement on
Python 3.5+. Note that the callback must be a coroutine in this context.
The coroutine callback is not called in a separate thread.importasyncioimporttimefromratelimiterimportRateLimiterasyncdeflimited(until):duration=int(round(until-time.time()))print('Rate limited, sleeping for{:d}seconds'.format(duration))asyncdefcoro():rate_limiter=RateLimiter(max_calls=2,period=3,callback=limited)foriinrange(3):asyncwithrate_limiter:print('Iteration',i)loop=asyncio.get_event_loop()loop.run_until_complete(coro())LicenseOriginal work Copyright 2013 Arnaud PorterieModified work Copyright 2016 Frazer McLeanLicensed under the Apache License, Version 2.0 (the “License”); you may
not use this file 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.
See the License for the specific language governing permissions and
limitations under the License.
Package: ratelimitpy
InstallationTo install ratelimitpy, simply use pip:$pipinstallratelimitpyor install directly from source to include latest changes:$pipinstallgit+https://github.com/saporitigianni/ratelimitpy.gitor clone and then install:$gitclonehttps://github.com/saporitigianni/ratelimitpy.git$cdratelimitpy$python3setup.pyinstallUsageSimply decorate anything that requires a rate limit and specify calls and periodfromratelimitpyimportratelimitpy# Function to be rate limited# Will print no more than 10 calls for every 3 second period@ratelimitpy(calls=10,period=3)defprint_limited(data):print(data)forxinrange(30):print_limited(x)ContributingPlease read theCONTRIBUTINGdocument before making changes that you would like adopted in the code.Code of ConductEveryone interacting in theratelimitpyproject’s codebase, issue
trackers, chat rooms, and mailing lists is expected to follow thePyPA Code of Conduct.ETH 0xaD1F09626b9B8e701D5f0F4a237193Df73d3C445BTC 199zsVqCusefv8yjdYQhUQZmLCyh75dqNVLTC LUBqs7VxC43ttPsQuM1jaZFmshKTAU1Rs9
Package: ratelimitqueue
RateLimitQueueA rate limited wrapper for Python's thread safe queues.Some external APIs have rate limits that allow faster-than-consecutive queries, e.g. if the rate limit is very high or the API response is quite slow. To make the most of the API, the best option is often to make API calls from multiple threads. Then you can put the requests or URLs to call in aqueue.Queueand have the threads consume the URLs as they make the calls. However, you still have to make sure that the total calls from all your threads don't exceed the rate limit, which requires some nontrivial coordination.Theratelimitqueuepackage extends the three built-in Python queues from fromqueuepackage -Queue,LifeQueue, andPriorityQueue- with configurable, rate limited counterparts. Specifically, theget()method is rate limited across all threads so that workers can safely consume from the queue in an unlimited loop, and putting the items in the queue doesn't need to require blocking the main thread.InstallationTo get started, install it withpip:pipinstallratelimitqueue
Package: ratelimit_requests_cache
ratelimit_requests_cacheRatelimit requests in Python, but only if they're not served from the cacheThis package combines the best bits of theratelimitmodule and therequests_cachemodule.
It will rate limit outgoing requests, but not count invocations if a request can be served from the cache.Usageimportrequestsimportrequests_cachefromratelimitimportsleep_and_retryfromratelimit_requests_cacheimportlimits_if_not_cached@sleep_and_retry@limits_if_not_cached(calls=1,period=1)defget_from_httpbin(i):returnrequests.get(f'https://httpbin.org/anything?i={i}')# Enable requests cachingrequests_cache.install_cache()# Notice that only the first ten requests will be ratelimited to 1 request / second# After that, it's a lot quicker since requests can be served from the cache# and the ratelimiter does not engageforiinrange(100):get_from_httpbin(i%10)print(i)Installationpython3-mpipinstallratelimit_requests_cache
Package: ratelimit-whl-copy
APIs are a very common way to interact with web services. As the need to
consume data grows, so does the number of API calls necessary to remain up to
date with data sources. However many API providers constrain developers from
making too many API calls. This is know as rate limiting and in a worst case
scenario your application can be banned from making further API calls if it
abuses these limits.This packages introduces a function decorator preventing a function from being
called more often than that allowed by the API provider. This should prevent
API providers from banning your applications by conforming to their rate
limits.InstallationPyPiAdd this line to your application’s requirements.txt:ratelimitAnd then execute:$pipinstall-rrequirements.txtOr install it yourself:$pipinstallratelimitGitHubInstalling the latest version from Github:$gitclonehttps://github.com/tomasbasham/ratelimit$cdratelimit$pythonsetup.pyinstallUsageTo use this package simply decorate any function that makes an API call:fromratelimitimportlimitsimportrequestsFIFTEEN_MINUTES=900@limits(calls=15,period=FIFTEEN_MINUTES)defcall_api(url):response=requests.get(url)ifresponse.status_code!=200:raiseException('API response:{}'.format(response.status_code))returnresponseThis function will not be able to make more then 15 API call within a 15 minute
time period.The arguments passed into the decorator describe the number of function
invocation allowed over a specified time period (in seconds). If no time period
is specified then it defaults to 15 minutes (the time window imposed by
Twitter).If a decorated function is called more times than that allowed within the
specified time period then aratelimit.RateLimitExceptionis raised. This
may be used to implement a retry strategy such as anexpoential backofffromratelimitimportlimits,RateLimitExceptionfrombackoffimporton_exception,expoimportrequestsFIFTEEN_MINUTES=900@on_exception(expo,RateLimitException,max_tries=8)@limits(calls=15,period=FIFTEEN_MINUTES)defcall_api(url):response=requests.get(url)ifresponse.status_code!=200:raiseException('API response:{}'.format(response.status_code))returnresponseAlternatively to cause the current thread to sleep until the specified time
period has ellapsed and then retry the function use thesleep_and_retrydecorator. This ensures that every function invocation is successful at the
cost of halting the thread.fromratelimitimportlimits,sleep_and_retryimportrequestsFIFTEEN_MINUTES=900@sleep_and_retry@limits(calls=15,period=FIFTEEN_MINUTES)defcall_api(url):response=requests.get(url)ifresponse.status_code!=200:raiseException('API response:{}'.format(response.status_code))returnresponseLicenseThis project is licensed under theMIT License.
Package: ratemate
ratemateThere's a bunch of python rate limiting modules out there, but they all seem to suffer from similar problems:Weird APIs, usually inflexible decorators that you need to wrap your calls inLack ofmultiprocessingsupport (eg, two processes will be unaware of each other, and thus double the intended rate)Unnecessary coupling to other librariesratemate, meanwhile, gives you a simpleRateLimitobject that avoids all these problems.It works like this. Declare aRateLimitas follows:from ratemate import RateLimit

rate_limit = RateLimit(max_count=2, per=5)  # 2 requests per 5 secondsThen call.wait()appropriately when you need to limit the rate.For instance, here's an example when creating multiple threads withconcurrent.futures. First the original rate-unlimited code:fromconcurrent.futuresimportThreadPoolExecutor,as_completeddeftask(n):print(f"  task{n}called")returnnfutures=[]withThreadPoolExecutor()asexecutor:foriinrange(20):future=executor.submit(task,i)futures.append(future)forcompletedinas_completed(futures):result=completed.result()print('completed')Add rate-limiting simply by adding a wait at the appropriate time, either at task creation:foriinrange(20):rate_limit.wait()# wait before creating the taskfuture=executor.submit(task,i)futures.append(future)Or at the start of the task itself:deftask(n):waited_time=rate_limit.wait()# wait at start of taskprint(f"  task{n}: waited for{waited_time}secs")returnnBecauseratemateuses multi-process-aware shared memory to track its state, you can also useProcessPoolExecutorand everything will still work nicely.Greedy modeThe default (aka non-greedy aka patient) rate limiting mode spaces out calls evenly. First instance, max_count=10 and per=60 will result in one call every 6 seconds.You may instead wish for calls to happen as fast as possible, only slowing down if the limit would be exceeded. Enable this with greedy=True, eg:rate_limit = RateLimit(max_count=20, per=60, greedy=True)Further enhancementsRate limit coordination between truly independent processes (not just subprocesses), possibly using Python 3.8's new shared memory or Redis or PostgreSQL or whatever.
Package: rateme
Rating system using computer visionIntroductionRateMe is a neural network that allows you to recognize gestures of thumb up and thumb down.
The algorithm can be embedded in your project and automate the process of evaluation of something or someone.For example, using Rate Me you can:Rate music on the YouTube Music service, when you are uncomfortable with clicking buttonsCount the votes in a beauty contest to determine the winnerRate drinks and meals during their tastingTechnical partDependenciesopencv-contrib-python,numpymatplotlib,jupyterfor jupyter-notebookpip3installopencv-contrib-pythonnumpyUsageOpenTest_RateMe.ipynbto test RateMe on example images
(for that you need to startjupyter-notebook, it will open window in your browser, where you need to selectTest_RateMe.ipynb).For example of realtime detection rundetect_on_webcam.py.Minimal working example:importcv2fromRateMe.utilsimportRateMeimg=cv2.imread('test_imgs/like.jpg')label=net.decode(img)DescriptionRateMe is based ontiny-YOLOv3architecture.It's accuracy of thumb up/down gesture recognition is calculated as mean average precision (mAP@0.25) = 0.851941, or 85.19%; average IoU = 73.89%The neural network has been trained on ~3K images (taken from different angles photos of people showing their thumbs or not).
Images were labeled using thelabelImgprogram.Class labels: 0 -- "Like (thumb up)", 1 -- "Dislike (thumb down)"SpeedFull pipeline speed is 6-7 FPS on Intel(R) Core(TM) i5-4300M CPU @ 2.60GHz.~100ms on frame grabbing~100ms on neural network inference
Package: rateninja
RateNinjaRateNinja is a Python package designed to facilitate the execution of function calls or API requests at a controlled rate, utilizing multithreading to maintain efficiency while adhering to rate limits. This package is particularly useful for interacting with APIs that impose call frequency restrictions, allowing developers to maximize throughput without violating terms of service.FeaturesRate Limiting: Enforces call frequency limits to comply with API rate limits.Greedy and Non-Greedy Modes: Supports both evenly spaced calls and as-fast-as-possible call execution within rate limits.Progress Bar: Visual feedback for tracking the progress of batched calls.Retries: Automatic retry mechanism for failed calls.Multithreading: Utilizes Python'sconcurrent.futures.ThreadPoolExecutorfor parallel execution of calls within rate limits.InstallationInstall RateNinja using pip:pipinstallrateninjaUsageTo use RateNinja, you need to import theRateNinjaclass from the package and then instantiate it with your desired rate limiting parameters. You can then pass the function (or API call) you wish to execute along with the function's arguments or keyword arguments.Basic ExamplefromrateninjaimportRateNinja# Function to be calleddefcalculate(param1,param2,operator="sum"):ifoperator=="sum":returnparam1+param2elifoperator=="multiplication":returnparam1*param2else:raiseException("Unrecognized operator")# Initialize RateNinja with rate limiting parametersrate_ninja=RateNinja(max_call_count=10,per_seconds=60,greedy=False,progress_bar=True,max_retries=5,max_workers=5)# Prepare arguments for the function callsfunc_args=[(3,3),(4,4),(5,5),]# List of tuples, each tuple contains arguments for one function callfunc_kwargs=[{"operator":"sum"},{"operator":"multiplication"},{"operator":"ninja"},]# Execute the callsresults,errors=rate_ninja(my_function,func_args=func_args,func_kwargs=func_kwargs)print("Results:",results)print("Errors:",errors)Should print:Results: [6, 16, None]
Errors: [None, None, Exception("Unrecognized operator")]Parametersmax_call_count: Maximum number of calls allowed perper_secondsperiod.per_seconds: Time frame in seconds for themax_call_countlimit.greedy: IfTrue, executes calls as fast as possible within the limit. IfFalse, spaces out calls evenly (e.g. ifmax_call_count=10andper_seconds=10, it will execute one call per second).progress_bar: Enables a visual progress bar ifTrue.max_retries: Number of retries for failed calls.max_workers: Number of worker threads for parallel execution._disable_wait: Allows to disable the internal wait mechanism that is used to respect rate limits. Note: if this isTrue, you will have to handle rate limits by yourself. To do this, use the.get_rate_limit_obj()method to get theRateLimitobject instance, and use its.wait()method inside your function everytime you need to wait to respect rate limits.ContributingContributions to RateNinja are welcome!LicenseRateNinja is distributed under the Apache 2.0 License. See the LICENSE file in the GitHub repository for more details.
Package: rater
raterrateris a comparative framework for multimodal recommender systems. It was developed to facilitate the designing, comparing, and sharing of recommendation models.FeatureDataml-1m:http://files.grouplens.org/datasets/movielens/ml-1m.zipdelicious-2k:http://files.grouplens.org/datasets/hetrec2011/hetrec2011-delicious-2k.ziplastfm-dataset-360K:http://mtg.upf.edu/static/datasets/last.fm/lastfm-dataset-360K.tar.gzslashdot:http://snap.stanford.edu/data/soc-Slashdot0902.txt.gzepinions:http://snap.stanford.edu/data/soc-Epinions1.txt.gzml-100k:http://files.grouplens.org/datasets/movielens/ml-100k.zipCriteo(dac full):https://s3-eu-west-1.amazonaws.com/kaggle-display-advertising-challenge-dataset/dac.tar.gzCriteo(dac sample):http://labs.criteo.com/wp-content/uploads/2015/04/dac_sample.tar.gzInstallpip3 install raterorgit clone https://github.com/shibing624/rater.git
cd rater
python3 setup.py installUsageLoad the built-inMovieLens 1Mdataset (will be downloaded if not cached):Output:MAERMSEAUCNDCG@10NDCG@20Recall@10Recall@20Train (s)Test (s)MF0.74300.89980.74450.04790.05560.03520.06540.131.57PMF0.75340.91380.77440.06170.07190.04790.08802.181.64BPRN/AN/A0.86950.09750.11290.08910.14493.741.49For more details, please take a look at ourexamples.ModelsThe models supported are listed below. Why don't you join us to lengthen the list?ContributeYour contributions at any level of the library are welcome. If you intend to contribute, please:Fork the rater repository to your own account.Make changes and create pull requests.You can also post bug reports and feature requests inGitHub issues.LicenseApache License 2.0Reference[Multilayer Perceptron Based Recommendation][Autoencoder Based Recommendation][CNN Based Recommendation][RNN Based Recommendation][Restricted Boltzmann Machine Based Recommendation][Neural Attention Based Recommendation][Neural AutoRegressive Based Recommendation][Deep Reinforcement Learning for Recommendation][GAN Based Recommendation][Deep Hybrid Models for Recommendation]maciejkula/spotlightshenweichen/DeepCTR[推荐系统实践]Magic-Bubble/RecommendSystemPractice
Package: rateslib
RateslibRateslibis a state-of-the-artfixed income librarydesigned for Python.
Its purpose is to provide advanced, flexible and efficient fixed income analysis
with a high level, well documented API.Its design objective is to be able to create a self-consistent, arbitrage free
framework for pricing all aspects of fixed income trading, such as spot FX, FX forwards,
single currency securities and derivatives like fixed rate bonds and IRSs, and also
multi-currency derivatives such as FX swaps and cross-currency swaps. Options,
swaptions and inflation are also under consideration for future development.The techniques and object interaction withinrateslibwere inspired by
the requirements of multi-disciplined fixed income teams working, both cooperatively
and independently, within global investment banks.LicenceThis library is released under aCreative Commons Attribution, Non-Commercial,
No-Derivatives 4.0 International Licence.Get StartedRead the documentation atRateslib Read-the-Docs
Package: ratex
RaTeXInstallIf you don't have LaTeX installed, go tohttps://www.overleaf.com/and copy + paste the "/build/main.tex" file code into the editor!pipinstallratexPreviewCodefromrateximportBuild,Text,Packages# // New Ratex buildr:Build=Build("main.tex",__file__)r.new(doc_class="article",title="RaTeX Physics Lab",author="Tristan Simpson",packages=["{multirow}","{cancel}",# custom packages orPackages.changepage,# use the ones provided])# // Observationsr.add_header("Observations",enumerate=False)r.add_text(b=False,it=False,content=r"""Using the two provided objects we could calculate net force of thebounceback from a mass and a string. By 30kg the string broke after the mass was dropped.The table below describes our group observations.\newline\newline""")r.add_table(columns=3,headers=["Mass ($kg$)","Height ($m$)","Force (N)"],data=["10kg","11.4m","108.73N","20kg","16.7m","276.52N",])# // Procedurer.add_header("Procedure",enumerate=False)r.add_list(type="enumerate",items=[r.text(r"The string was attached to the table."),r.text(r"The mass was attached to the opposite end of the string."),r.text(r"The mass was dropped and the bounceback height was measured."),r.text(r"The net force was calculated.")])# // Finalize the buildr.done()OutputLicenseMIT LicenseCopyright (c) 2022 Simpson Computer Technologies ResearchPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.