Skip to main content

Task Object Storage: Transaction management for Robot Framework RPA using MongoDB.

Project description

Transaction management for Robot Framework RPA using MongoDB.

Included are two packages: tos and TOSLibrary. The former is the actual task object storage implementation written in pure Python, without any Robot Framework dependencies. TOSLibrary is a Robot Framework keyword library built on top of tos. It is built as a lightweight dynamic proxy library, so all the changes in tos are immediately available in TOSLibrary keywords.

Quickstart guide

Requirements

  • MongoDB (version >4)

  • Python (version >= 3.9)

Installation

Latest stable version from PyPi with pip:

pip install task-object-storage

Latest development version from PyPi:

pip install task-object-storage --pre

Usage

You can import TOSLibrary into your Robot Framework suite with

*** Settings ***
Library    TOSLibrary    ${db_server}:${db_port}    ${db_name}

If you are using authentication in MongoDB, you can pass credentials:

*** Settings ***
Library    TOSLibrary    ${db_server}:${db_port}    ${db_name}    ${db_user}    ${db_passw}

By default, task data is written to task_objects collection in the specified database. You can also add prefix or suffix to the collection name: pass valid collection_suffix or collection_prefix arguments to TOSLibrary, to access collection with a name your_prefix.task_objects.your_suffix.

It is also possible to separate payloads of task objects to their own payloads collection, and also optionally set a lifetime for them. The user should have full access to the specified collections and ListCollections access to the database. For example, the following role can be created in MongoDB:

db.createRole( {
    role: "rpa_role",
    privileges: [
        { resource: { db: "rpa_data", collection: "my_robot.payloads" }, actions: [ "find", "update", "insert", "remove", "createIndex"] },
        { resource: { db: "rpa_data", collection: "my_robot.task_objects" }, actions: [ "find", "update", "insert", "remove", "createIndex"] },
        { resource: { db: "rpa_data", collection: ""}, actions:  ["listCollections"] }
    ],
    roles: []
})
*** Settings ***
Library    TOSLibrary    ${db_server}:${db_port}    ${db_name}    ${db_user}    ${db_passw}
...    ${collection_suffix}    ${collection_prefix}    db_auth_source=my_auth_source
...    separate_payloads=${TRUE}    payloads_ttl=30 days

Additional MongoClient options can be passed to the library as a dictionary mongo_client_options=. For further details, see the PyMongo documentation: https://pymongo.readthedocs.io/en/4.11.2/api/pymongo/mongo_client.html

After initialization, the keywords are callable from Robot Framework.

This library instance can also be accessed inside Python keywords with

from robot.libraries.BuiltIn import BuiltIn

toslib = BuiltIn().get_library_instance("TOSLibrary")
toslib.keyword_name

The keywords can be also called with:

BuiltIn().run_keyword("<keyword name>")

To use task object storage in Python without any Robot Framework dependencies you should use tos package directly:

from tos.task_object_storage import TaskObjectStorage

tos = TaskObjectStorage(
        db_server=server,
        db_name=db_name,
        db_user=db_user,
        db_passw=db_passw,
        mongo_client_options=mongo_client_options,
)

If db_user and db_passw are empty strings, TaskObjectStorage will default to using no authentication.

Available keywords

See the full API documentation.

For developers

Release a new version by running:

scripts/build.sh release

You can also install the whl package found in the dist directory with

pip install <package-name>.whl

or put inside requirements.txt:

file:C:/path/to/<package-name>.whl  # on windows
file:/path/to/<package-name>.whl  # on linux

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

task_object_storage-1.4.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file task_object_storage-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for task_object_storage-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99a5e9da99b9479e31200a3c0321b928f3d6c3991c3224e1561532bd1f094b20
MD5 b685a3afa527169aa3e9700499872796
BLAKE2b-256 abffd7670f8dd9e6147f5b37b3be6d1cf52cdb791fba12342bfc8549858ad081

See more details on using hashes here.

Supported by

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