• Facebook
  • LinkedIn
  • Youtube
  • Download
  • FAQ
ARGOS LABS
  • Home
  • Product
    • News! Product and Service Updates
    • ARGOS Low-code
    • ARGOS POT SDK
    • H/W & S/W Requirements
  • Resources
    • 90 min training “Rocket Start”
    • Sample Bot Warehouse
    • Assist-o-mation
      • Commercial
      • Non-Commercial
    • More Videos
  • Use Cases
  • About us
  • Partners
    • Implementation Partners
    • Technology Partners
  • Contact
  • Free Trial
  • Menu Menu

ARGOS POT SDK

Download and install Python SDK

Detailed step-by-step guide for how to build Plugins(PDF) Download Plugin Template Detailed step-by-step guide for input/output design(PDF)

13 useful rules to keep in mind

___to avoid errors that we see frequently___

Related to the Python package name

  1. Always start with “argoslabs” like argoslabs.anyname1.anyname2.
  2. Package name must have three levels like argoslabs.anyname1.anyname2.
  3. You can only use lowercase of a ~ z and underscore (_) for the package name.
  4. Package name must be unique (Don’t worry – there is a checking mechanism when packaging).
  5. Display name must be unique (Don’t worry – there is a checking mechanism when packaging).

Related to configuring setup.yaml file

  1. You must declare platforms like [‘windows’, ‘darwin’, ‘linux’].
  2. Set proper keywords.
  3. Set proper platform.
  4. Set version like 1.2.3.4 (Do not start the section with 0, i.e., 1.505.0935 is not allowed.
  5. Do not forget to enter the proper package name at package_data.

Related to plugin coding

  1. Design input and output to be user friendly.
  2. Print out to STDOUT with a good result. The Return Value can be used as String, CSV or File at STU.
  3. Design with good exception handling and Return Code. The Return Code can be handled at STU.

ARGOS Low-code Python Plugin Developers

This document explains how to build ARGOS Low-code Python plugins by using the STU POT (Python-to-Operations Tools) SDK.

Prerequisites


Prepare Windows 10 or Linux or Mac

Most examples in this document are based on the testing on Windows 10

Install Python 3.7

Prepare a virtual environment for ARGOS Low-code Python Plugin

Run command below in CMD.EXE in Windows 10.


To make a virtualenv

python -m venv C:\work\py3

Example directory is C:\work\py3. (You may pick a directory name of your choice)


To activate the virtualenv

C:\work\py3\Scripts\activate

After activating it, the prompts will start with the name of virtual environment.

|(py3) C:\ >

Installing the ARGOS POT SDK


Run next command in the virtual environment.

pip install -U alabs.ppm alabs.icon --index https://pypi-official.argos-labs.com/pypi

You can upgrade as well as install with -U option

Check the version number

pip list

To check versions for SDK, use above command.

Package             Version
------------------- ----------
alabs.common        2.1021.1637 or more recent
alabs.icon          1.711.2351 or more recent
alabs.ppm           3.125.1430 or more recent

ARGOS POT SDK consists of three parts as follows:

ItemMinimum versionRoleDescription
alabs.common2.1021.1637SDK libraryLibrary for SDK
alabs.icon1.711.2351Icon UtilityThis utility makes plugin icon
alabs.ppm3.125.1430POT utilityPOT main utility

How to build an ARGOS Low-code Python Plugin


Prepare Python IDE

One of these IDEs (Integrated Development Environment) can be used

  • PyCharm

  • Visual Studio Code for Python

Download Plugin Template

Plugin Template

Unzip and open the files in IDE

  • Unzip above zip file

  • Open directory plugin-demo at your IDE

Change Python Package name

  • Above template has the Python package name your.demo.helloworld

  • Change this package as you desire such as my.api.crm

  • Three parts changed with the new package name like below

    • __main__.py : change ‘from your.demo.helloworld import main’ into ‘from my.api.crm import main’

    • setup.yaml : change ‘your.demo.helloworld: [‘icon.*’] into ‘my.api.crm: [‘icon.*’]’

    • test_me.py : change ‘from your.demo.helloworld import _main as main’ into ‘from my.api.crm import _main as main’

Design user arguments and result

ARGOS Low-code/RPA Python plugin is regarded as a CLI (Command line interface) program. User run CLI program with arguments as user input and the output is the result.

Plugin developers must design the user arguments (which becomes the parameter/property box in STU) and result (the output).

How to design user arguments

You can specify user arguments at function _main() in __init__.py file.

When an original Python code looks like below,

################################################################################
def _main(*args):
    """
    Build user argument and options and call plugin job function
    :param args: user arguments
    :return: return value from plugin job function
    """
    with ModuleContext(
        owner='YOUR-LABS',
        group='demo',
        version='1.0',
        platform=['windows', 'darwin', 'linux'],
        output_type='text',
        display_name='My World',
        icon_path=get_icon_path(__file__),
        description='Hello World friends',
    ) as mcxt:
        # ##################################### for app dependent parameters
        mcxt.add_argument('name', nargs='+', help='name to say hello')
        argspec = mcxt.parse_args(args)
        return helloworld(mcxt, argspec)

you need to change it to,

################################################################################
def _main(*args):
    """
    Build user argument and options and call plugin job function
    :param args: user arguments
    :return: return value from plugin job function
    """
    with ModuleContext(
        owner='MyCompany',
        group='api',
        version='1.0',
        platform=['windows', 'darwin', 'linux'],
        output_type='text',
        display_name='CRM Op',
        icon_path=get_icon_path(__file__),
        description='Our Company CRM API',
    ) as mcxt:
        # ######################################## for app dependent options
        mcxt.add_argument('--type', '-t',
                          display_name='Value Type', show_default=True,
                          choices=["auto", "string", "int", "float", "date", "datetime"],
                          default='auto',
                          help='Set Value type, one of {"auto", "int", "float", "date", "datetime"}.'
                               ' Default is auto which means try to guess the best type of value')
        mcxt.add_argument('--date-format',
                          display_name='Date Format',
                          choices=list(BinOp.DATE_FORMAT.keys()),
                          default='YYYYMMDD',
                          help='Set the format of Date')
        mcxt.add_argument('--datetime-format',
                          display_name='DateTime Format',
                          choices=list(BinOp.DATETIME_FORMAT.keys()),
                          default='YYYYMMDD-HHMMSS',
                          help='Set the format of DateTime')
​
        # ##################################### for app dependent parameters
        mcxt.add_argument('left',
                          display_name='Left Val',
                          help='Left operand for binary operation')
        mcxt.add_argument('operation',
                          display_name='Operator',
                          choices=['+', '-', '*', '/', '%'],
                          help='Binary operation, one of "+(add),-(subtract),*(multiply),/(divide),%%(modular)"')
        mcxt.add_argument('right',
                          display_name='Right Val',
                          help='Right operand for binary operation')
        argspec = mcxt.parse_args(args)
        return do_binop(mcxt, argspec)

Whereas,

  • ModuleContext instance defines plugin and attributes. User arguments are defined using mcxt.add_argument method (mcxt is the ModuleContext instance variable).

  • mcxt.add_argument is the superset of Python argparse standard library

  • In addition to add_argument of standard argparse library next arguments can be added.

    • display_name is the label in STU

    • Options are usually not shown in default in STU but in advanced group. If show_default is true then this option is shown default in STU

    • input_method specifies how to input from user in STU

      • password shows password using ‘*’ characters.

      • fileread shows file dialog to read a file

      • fileread;xlsx shows file dialog to read a file which has the extension of xlsx

      • filewrite shows file dialog to write a file

      • filewrite;txt,pdf shows file dialog to write a file which has the extension of either txt or pdf

      • folderread shows folder dialog to read

      • folderwrite shows folder dialog to write

      • dateselect shows date picker dialog

      • textarea shows multiple text input control

      • radio shows radio button according to group (refer to input_group)

      • combobox shows combo-box for choice

      • imagebox shows image

    • input_group is used for grouping in STU

      • “groupname” is the grouping name which is used for the group of arguments

      • “groupname;groupbox” shows group box named “groupname”

      • “radio=a” shows group of radio buttons named “a”

      • “radio=a;default” shows group of radio button as a default

    • min_value or greater_eq check if the user input value is greater than or equal to given value

    • max_value or less_eq check if the user input value is less than or equal to given value

    • greater or min_value_ni check if the user input value is greater than given value

    • less or max_value_ni check if the user input value is less than given value

    • equal check if the user input value is equal to given value

    • not_equal check if the user input value is not equal to given value

    • re_match check if the user input value is RE matched for given value

How to design result

You can change user function body helloworld() into do_binop() in __init__.py file.

When an original Python code looks like below,

################################################################################
@func_log
def helloworld(mcxt, argspec):
    """
    plugin job function
    :param mcxt: module context
    :param argspec: argument spec
    :return: True
    """
    mcxt.logger.info('>>>starting...')
    print('Hello world %s' % argspec.name)
    mcxt.logger.info('>>>end...')
    return 0

You can change it to a code below.

################################################################################
@func_log
def do_binop(mcxt, argspec):
    mcxt.logger.info('>>>starting...')
    try:
      if not argspec.message:
         raise ValueError(f'Invalid Message')
      direction = argspec.direction
      justify = argspec.justify
      width = int(argspec.width)
      f = Figlet(font=argspec.font, direction=direction,
         justify=justify, width=width)
      print(f.renderText(argspec.message), end='')
      return 0
   except ZeroDivisionError as err:
      msg = str(err)
      mcxt.logger.error(msg)
      sys.stderr.write('%s%s' % (msg, os.linesep))
      return 1
   except IOError as err:
      msg = str(err)
      mcxt.logger.error(msg)
      sys.stderr.write('%s%s' % (msg, os.linesep))
      return 2
   except RuntimeError as err:
      msg = str(err)
      mcxt.logger.error(msg)
      sys.stderr.write('%s%s' % (msg, os.linesep))
      return 3
   except Exception as err:
      msg = str(err)
      mcxt.logger.error(msg)
      sys.stderr.write('%s%s' % (msg, os.linesep))
      return 99
   finally:
      mcxt.logger.info('>>>end...')

Whereas,

  • Plugin result is the Python’s standard output (like sys.stdout or print)

  • mcxt is the ModuleContext instance

    • mcxt.logger is the logger object

  • This function return 0 on success otherwise failure

How to test your Python code

You can add each unit-test method in TU class in test_me.py. POT will execute the unit-test during the building time at the end.

Set version

Set version: 1.22.333 at setup.yaml file.

How to build an icon

  • Change my-icon.png image file with you own image file.

  • Open CMD.EXE (or terminal in Linux or Mac)

  • Activate virtual env (like C:\work\py3\Script\activate)

  • Run command alabs.icon

  • Make sure icon.png image file which will be used as STU icon is well created.

Before building plugin (for the Private Plugin Repository)

  • Make your own python private repository by choosing one of the following deployment platforms.

    • How to Create a Private Python Package Repository

    • How To Install A Private Pypi Server On AWS

    • Pypiserver – minimal PyPI server for use in docker container

  • Sign-up or Sign-in at rpa.argos-labs.com

  • Go to the Plugins page and click on the Private tab in menu

  • Add your private repository

    • name: plugin name

    • url: set as pypi url (like http://my.pypi.com/simple or https://my.pypi.com/pypi)

    • user: user for private plugin

    • password: password for the user

How to build plugin and upload it to your Private Plugin Repository

  • Open CMD.EXE (or terminal in Linux or Mac)

  • Activate virtual env (like C:\work\py3\Script\activate)

  • Run command build.bat (or build.sh in Linux or Mac). This batch file will run next commands using the POT utility, alabs.ppm

    • alabs.ppm --venv test: Test your plugin and response to any exceptions in the test process

    • alabs.ppm --venv build: Build your plugin and response to any exceptions in the process

    • alabs.ppm --venv upload: Try to upload to the first Private Plugin Repository list in Chief page (refer above site, rpa.argos-labs.com)

      • This command will ask for user id and password of Supervisor account for uploading your package to the Private Plugin Repository

How to show your Plugins on STU


  • Login to STU (if already logged in STU then logout and login again)

  • Got to Supervisor (Chief) and go to Plugin menu and then to Private tab.

  • Decide which Plugins to use on your STU (you can select by on/off button)

  • Restart STU

  • Make sure new plugins appear on STU’s Operations box

  • Use the plugin and build your bot

Share Share on Facebook
Facebook
Pin on Pinterest
Pinterest
Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

US OFFICE

3003 N.1ST ST. STE309
SAN JOSE, CA 95134

UK OFFICE

258-262 Romford Road
London, E7 9HZ

info@argos-labs.com

SUPPORT

Documents

FAQ

SITEMAP

  • Home
  • News! Product and Service Updates
  • ARGOS Low-code
  • ARGOS POT SDK
  • H/W & S/W Requirements
  • 90 min training “Rocket Start”
  • Sample Bot Warehouse
  • Assist-o-mation : Commercial
  • Assist-o-mation : Non-Commercial
  • More Videos
  • Use Cases
  • About us
  • Implementation Partners
  • Technology Partners
  • Contact

 

Copyright 2020 ARGOS LABS All Rights Reserved.
  • Facebook
  • LinkedIn
  • Youtube
  • Terms and Condition
  • Privacy policy
Scroll to top
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkNoPrivacy policy