Skip to main content

SDK for python serverless functions

Project description

Serverless cloud functions

Contents

  1. Quick Start
  2. Examples
  3. Features
  4. Community
  5. Licensing

Quick Start

  1. Install via pip:
    pip install sels8s
    
  2. Download rc.sh file from Selectel panel
  3. Set environment variables: -OS_USERNAME - your username in panel -OS_PASSWORD - your password -OS_PROJECT_ID - your project id -OS_PROJECT_DOMAIN_NAME - your project domain name -OS_USER_DOMAIN_NAME - your user domain name
  4. Create your own cloud function:
    import sels8s
    
    serverless = sels8s.Serverless()
    
    # upload file
    module = serverless.upload_module('/home/my_file.py')
    
    # create function
    serverless.create_function('my_function')
    
    # add your code and params
    module_id = module.json()["function_id"]
    
    serverless.edit_function('my_function', function_id=module_id,
                             function_name='name_of_function_in_code',
                             module_name='my_file.py', env_vars={'key':'value'},
                             runtime='python', version='3.7')
    
    # invoke your function
    import time
    ex = True
    while ex:
        try:
            activation = serverless.invoke_function('my_function')
            ex = False
        except Exception:
            time.sleep(10)
    
    # get logs and results
    while ex:
        try:
            logs = serverless.get_activation_logs(activation.json()['activation_id'])
            result = serverless.get_activation_result(activation.json()['activation_id'])
            ex = False
        except Exception:
            time.sleep(10)
    

Examples

You can see examples of using cloud functions here

Features

Cloud functions

Docs

Community

GitHub

For all questions - Our Telegram

Licensing

Serverless is licensed under the Apache 2.0.

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

sels8s-1.0.7.tar.gz (4.0 kB view hashes)

Uploaded Source

Built Distribution

sels8s-1.0.7-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

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