Skip to main content

The SDK used for Shuffle

Project description

Shuffle SDK

This is the SDK used for app development, testing and production of ALL apps in Shuffle. Works with manual runs, Docker, k8s, cloud serverless.

Released under Python pip for usage outside of Shuffle

Python apps: https://github.com/shuffle/python-apps All apps: https://shuffler.io/search

Usage with Shuffle

Refer to the Shuffle App Creation docs

Build

docker build . -t shuffle/shuffle:app_sdk

Download

pip install shuffle_sdk

Usage

from shuffle_sdk import AppBase

class Example(AppBase):
    def sample_function(self, paramname):
        return f"Hello {paramname}"

if __name__ == "__main__":
    Example.run()

Testing Shuffle Apps

With the above function as an example

python3 app.py --standalone --action=sample_function paramname=World

Example wit Shuffle Tools+Liquid and the Shuffle Tools app and the "repeat back to me" function

python3 app.py --standalone --action=repeat_back_to_me '--call={{ "hello" | replace: "o", "lol" }}'

Example using Shuffle Tools Shuffle actions within the "execute_python" function to get emails from Outlook (app.py)

python3 app.py --standalone --action=execute_python 'code=print(shuffle.run_app(app_id="accdaaf2eeba6a6ed43b2efc0112032d", action="get_emails"))'

Example LLM inference with the Shuffle-AI app. Supports GPU and requires ollama installed and serving.

python3 app.py --standalone --action=run_llm 'input=convert the following data into a python list of valid ips: 12.3.4.4'

If successful, the output of the function will show in your CLI.

Testing functions inside Shuffle App images manually

This is mostly the same, but paths and docker is a part of the command.

docker run frikky/shuffle:shuffle-ai_1.0.0 python3 /app/app.py standalone --action=run_llm '--input=llm, please answer this question thanks'

With GPU's active in Docker for the LLM (requires Nvidia Container Toolkit):

docker run --gpus all GPU_LAYERS=8 frikky/shuffle:shuffle-ai_1.0.0 python3 /app/app.py standalone --action=run_llm '--input=llm, please answer this question thanks'

Building a fully functional Shuffle App

Look at the documentation on our website

Adding new Liquid filters

Add a function along these lines:

@shuffle_filters.register
def md5(a):
    a = str(a)
    return hashlib.md5(a.encode('utf-8')).hexdigest()

This can be used as {{ "string" | md5 }}, where "string" -> the a parameter of the function

(Scale testing) Running the Shuffle Tools within the Shuffle Tools app locally

  1. Set your env SHUFFLE_APP_EXPOSED_PORT=8080 and SHUFFLE_SWARM_CONFIG=run
  2. Run the Shuffle Tools app as a webserver: python3 app.py
  3. Send a local request to the Shuffle Tools app to run an action within an action. Make sure to add an authorization & execution_id that exists
curl -XPOST http://localhost:8080/api/v1/run -H "Content-Type: application/json" -d '{
    "action": {"app_name": "shuffle tools", "name": "execute_python", "parameters": [{
        "name": "code", 
        "value": "singul.config[\"url\"] = \"https://shuffler.io\";print(singul.run_app(app_id=\"3e2bdf9d5069fe3f4746c29d68785a6a\", action=\"repeat_back_to_me\", parameters=[{\"name\": \"call\", \"value\": \"testing\"}]))"}]
    }, 
    "authorization": "",
    "execution_id": ""
}
'

You can replace the singul.config URL with a local instance for local testing as well.

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

shuffle_sdk-0.0.23.tar.gz (45.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shuffle_sdk-0.0.23-py3-none-any.whl (45.4 kB view details)

Uploaded Python 3

File details

Details for the file shuffle_sdk-0.0.23.tar.gz.

File metadata

  • Download URL: shuffle_sdk-0.0.23.tar.gz
  • Upload date:
  • Size: 45.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for shuffle_sdk-0.0.23.tar.gz
Algorithm Hash digest
SHA256 809a35ab2e26e996e3fc124564c53f1eb7295e4bb6786d3c62357992a724455f
MD5 82d182844ea91f0f0beebff5778e167c
BLAKE2b-256 489b06bf403cd325a3f4e9f4f80a8e0bf956b2fe272c6cb9e540fb8f71879173

See more details on using hashes here.

File details

Details for the file shuffle_sdk-0.0.23-py3-none-any.whl.

File metadata

  • Download URL: shuffle_sdk-0.0.23-py3-none-any.whl
  • Upload date:
  • Size: 45.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for shuffle_sdk-0.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 2472893c988fb2cc691b207877e4a4535f8669945d4c97741904cfe5d587dc1d
MD5 eb17d7aef595cc7ccccd1d03bb32be23
BLAKE2b-256 b0b73ce3fd57405c30ae84678f4cd9d6eb2ce966c5fb8176c87a093a93e411d7

See more details on using hashes here.

Supported by

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