Skip to main content

rallf.com Software Development Kit (SDK)

Project description

RALF Python SDK

Website GitHub license GitHub issues PyPI Python Versions Requirements Status

RALLF SDK provides the tools to create tasks for rallf robots (rallf.com) using python3.

Disclaimer! This package is in development stage (unstable), it may be potentially buggy

Installation

Using Python Package Index (PyPI)

pip3 install rallf

From source

git clone https://github.com/RobotUnion/rallf-python-sdk
cd rallf-python-sdk
pip3 install -r requirements.txt
python3 setup.py install

Getting started (hello bot-task)

In order to get started with robot task development, just run rallf-py create-project "hello" and it will create a basic project with the files explained below.

hello.py

# File: src/hello.py

from rallf.sdk import Task

'''
  Hello task opens github and returns the title of the page upon it is loaded.
  To learn more about python selenium api, see https://selenium-python.readthedocs.io/
'''
class Hello(Task):

    # implementing self.run is required for tasks, not for skills
    def run(self, input):
        # Log stuff via the available logger
        self.logger.debug('Hello Bot')

        # get a firefox instance
        browser = self.robot.devices['firefox']
        browser.get('https://github.com')
        return browser.getTitle()

Try it (rallf cli)

To use the cli you can use either the binary included in the package

rallf-py <args>

or executing directly from python

python3 -m rallf.cli <args>

Run run method using the CLI

rallf-py run . -f run

Run run method using the jsonrpc api

echo '{"jsonrpc": "2.0", "id": 1, "method": "delegate", "params": {"routine": "run", "args": {}}}' | rallf-py run .

Get help

rallf-py -h

Extended usage

Task Manifest

Task manifest is mandatory for rallf.com tasks, but not necessary for developing, visit manifest reference to learn more in-deep about task manifests.

/* File config/manifest.json */
{
  "title": "Hello Task",
  "description": "This tasks logs hello and returns the <title> of github.com",
  "long-description": "@README.md",
  "fqtn": "com.example.hello",
  "type": "task", /* choices: task, skill */
  "main": "src.hello.Hello",
  "exports": ["run"], /* default: ["run"] */
  "permissions": {
    "uris": ["https://github.com", "https://google.com"],
    "devices": ["firefox", "chrome"],
    "skills": {
      "com.example.facebook": ["likePage", "likePost"],
      "com.example.gmail": ["search", "likePost"]
    },
  }
}

Injected objects

  • self.robot this object is injected in the task creation
  • input this parameter is passed to the run(self, input) function

Inter Task Communication (ITC)

  • Call other tasks from the market (rallf.com)
  • Use robot skills

Task lifecycle callbacks

  • warmup(self) this optional method is executed some time before the task starts to speed-up the rest of calls.
  • run(self, input) this required method handles the work of the task and is triggered at start of the task.
  • cooldown(self) this optional method is called when the task is going to be some time without use.

Task vs Skill

A common question is the difference between Task and Skill inside the RALLF ecosystem, the main difference is that Tasks only have one method called run and the skill can have many, so technically a Task is a subtype of Skill, and also a Skill can implement the run method and can be used as Task too.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rallf-0.4.5.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

rallf-0.4.5-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file rallf-0.4.5.tar.gz.

File metadata

  • Download URL: rallf-0.4.5.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.5.3

File hashes

Hashes for rallf-0.4.5.tar.gz
Algorithm Hash digest
SHA256 c6aeff2f01348552bda3ce088d717352ec00e4814d9ff099e2d346a4d4fae8a5
MD5 7849c182836951be61eb728d327035eb
BLAKE2b-256 136846526b9bf3084accd6f77e7fc43d71fb0fc4b4ae7a80a4222011f01d1aa5

See more details on using hashes here.

File details

Details for the file rallf-0.4.5-py3-none-any.whl.

File metadata

  • Download URL: rallf-0.4.5-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.1.0 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.5.3

File hashes

Hashes for rallf-0.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 be322c1f4e51193c0d9c0c2dd169e3fd31329ce8f4e76c2ae685f12a62e7d2e0
MD5 5e885be38a18a47d4ea9e36046f7b5d1
BLAKE2b-256 f9f6c68a00889377d7ab2b5884ecdc0ad1fe9bf0e5299ab752b1be05622a52a6

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