Run on my cloud
Project description
Run on cloud with me
import pegasi
import time, math, requests
pwd="eat those french fries and drink cola"
api="https://pcze5.azurewebsites.net/cloudpickle"
api_load="https://pcze5.azurewebsites.net/load"
hash=pegasi.hash(pwd)
dash = pegasi.Dash(pwd,api)
def hello_world(x="world"):
return "Hello {}!".format(x)
print(dash.run(hello_world))
def timey_wimey(x):
time.sleep(x)
return time.time()
print(dash.map(timey_wimey,[1]*70)) #70 functions, each takes exactly 1 second all done at the same time
print(dash.map(timey_wimey,args=[1]*70))
print(dash.run(timey_wimey,test=True))#test=True means server shall not execute function, but just return it to you
print(dash.run(timey_wimey,args=[1],save="timey_wimey")) #execute and save
print(dash.run(hello_world,save="hello_world",test=True)) #save without executing
print(dash.run(None,load="timey_wimey",args=[1]))#now we can use function without sending it
print(dash.map(None,load="timey_wimey",args=[1]*70))#weven map
print(dash.map(lambda x: x*x/x+x,range(0,100))) # we can use lambda
#first response would be error because of division by zero
print(dash.filter(lambda t: t % 1 > 0.5,dash.map(None,load="timey_wimey",args=[1]*70))) #and filter
#For both map and filter you send only one request to the server and it applies multitasking request to itself
print(dash.map(lambda a,b: "{} and {}".format(a,b),[["A","B"],["R","B"],["R","D"]],star=True))
#if you have function that accepts more than one argument use star=True
print(requests.get(api_load,params={"hash":hash,"load":"hello_world"}).text)
#you can send get requests to trigger function from anywhere
#TODO: sending args through get requests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pegasi-1.tar.gz
(4.5 kB
view details)
File details
Details for the file pegasi-1.tar.gz
.
File metadata
- Download URL: pegasi-1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c623c9805bf7d59df95fb910cf09c804db50e319dff2fe9805cf675f23ccdad4 |
|
MD5 | 299bea5b139ca472ec411f3850e0fe2b |
|
BLAKE2b-256 | a84574b0a0cae23e8a48f8ffd531c8543e8178a948ac08682d0d566965d96f94 |