Skip to main content

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


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.1.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file pegasi-1.1.tar.gz.

File metadata

  • Download URL: pegasi-1.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

Hashes for pegasi-1.1.tar.gz
Algorithm Hash digest
SHA256 35ecf5b59fc996fdefdf6f5bfee7db72c0898069ce1c9772d6da758171cfc6f7
MD5 72f15fef85e213c79852cb249035d8fa
BLAKE2b-256 e66b0149746d627030e2aa593f5e4147908249087972e38aba3a3d7fa69f64f4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page