项目作者: aegisblade

项目描述 :
AegisBlade.com Python 2 & 3 client. Deploy & run any of your code in one function call.
高级语言: Python
项目地址: git://github.com/aegisblade/aegis-python.git
创建时间: 2019-09-26T23:39:36Z
项目社区:https://github.com/aegisblade/aegis-python

开源协议:GNU Lesser General Public License v2.1

下载




Logo


AegisBlade Python Client




pypi version
supported python versions
license


Deploy & run your code in a single function call.


Read the docs »




Examples
·
Sign Up for an API Key
·
Report Bug


Installation

We recommend using virtualenv to create an isolated environment for your python application.

Install the python package as a dependency of your application.

  1. $ pip install aegisblade

Or for python3:

  1. pip3 install aegisblade

Hello World Example

  1. import socket
  2. from aegisblade import aegisblade
  3. def helloworld():
  4. """
  5. In this example we will deploy & run this function
  6. inside of AegisBlade.
  7. """
  8. hostname = socket.gethostname()
  9. print("The server's hostname is {0}".format(hostname))
  10. return "Hello World from {0}".format(hostname)
  11. def main():
  12. """
  13. The main() function will run on your local machine
  14. and start a job on AegisBlade running the helloworld() function.
  15. """
  16. # Calling aegisblade.run() will start the job on a server managed by AegisBlade.
  17. # AegisBlade will handle provisioning hosts, deploying your code, and running it.
  18. print("Creating Aegisblade job...")
  19. job = aegisblade.run(lambda: helloworld())
  20. # Return values are serialized and can be fetched when the job is finished.
  21. #
  22. # Calling .get_return_value() will wait for the job to finish,
  23. # then get the return value.
  24. print("Waiting for job to finish...")
  25. job_return_value = job.get_return_value()
  26. print("RETURN VALUE")
  27. print(job_return_value)
  28. # Logs are stored and can also be fetched after the job is finished.
  29. job_logs = job.get_logs()
  30. print("LOGS:")
  31. print(job_logs)
  32. # Using the __name__ == "__main__" idiom to only run main when this script
  33. # is called directly is especially important when using AegisBlade.
  34. #
  35. # This script may be imported by the AegisBlade runtime, and without the
  36. # protective check of __name__, main() would be called inside the job
  37. # potentially causing an infinite loop of jobs starting more jobs.
  38. if __name__ == "__main__":
  39. main()

Note on Python 2

The official python organization will no longer support Python 2 following January 2020.

Due to it’s popular usage though, we will likely continue to support a Python 2.7 client for the forseeable future.

Reference

Python Client Reference Docs

Contact

AegisBlade - @aegisbladehq - welovedevs@aegisblade.com

Project Link: https://github.com/aegisblade/aegis-python