========== Aiviro CLI ========== Aiviro comes with few CLI commands for creating, managing and inspecting your Aiviro scripts. For detailed information about available commands and theirs arguments, see: .. code-block:: console $ aiviro-cli --help Create Project & Scenarios -------------------------- To create a new Aiviro project, we predefined a repository structure how such a project should look like. This can be initialize by ``aiviro-cli create project``. To add new scenario into already existing project, use ``aiviro-cli create scenario`` command: .. code-block:: console $ aiviro-cli create project --help $ aiviro-cli create project --context path/to/project/folder .. code-block:: console $ aiviro-cli create scenario --help $ aiviro-cli create scenario --prefect-project Aiviro --prefect-flow "Invoice Processing" --prefect-env rdp Logs Management --------------- See :ref:`Explorer` section for web application to explore logs and metadata. Process Metadata Logs ~~~~~~~~~~~~~~~~~~~~~ As mentioned in the section :ref:`Generate Images`, you can generate images from Aiviro metadata. This is done by ``aiviro-cli log generate`` command, see the example of it's usage: .. code-block:: console $ aiviro-cli log generate --help $ aiviro-cli log generate --input logs/runs/run-demo_test/images_metadata/ \\ --output logs/run-demo_test/log_img/ \\ --number 20 $ aiviro-cli log generate --input logs/runs/run-demo_test/images_metadata/ \\ --output logs/run-demo_test/log_img/ \\ --since 1955.11.12-6:38 $ aiviro-cli log generate --input logs/runs/run-demo_test/images_metadata/ \\ --output logs/run-demo_test/log_img/ \\ --before 2015.10.21-7:28 $ aiviro-cli log generate --input logs/runs/run-demo_test/images_metadata/ \\ --output logs/run-demo_test/log_img/ \\ --since 1955.11.12-6:38 \\ --before 2015.10.21-7:28 \\ --number 100 Analyze Errors ~~~~~~~~~~~~~~ Sometimes your scripts may encounter some errors, to find the exact error-message and corresponding images, in long running scripts may be time demanding. Therefore we created a helpful script, which automatically detects errors in the text logs and selects appropriate metadata based on the time the error occurred, which are then copied into separate sub-folders. This is done by ``aiviro-cli log analyze`` command, see the example of it's usage: .. code-block:: console $ aiviro-cli log analyze --help $ aiviro-cli log analyze --run logs/runs/run-2021-02-10_10-25-456-main/ --window 0:30:00 $ aiviro-cli log analyze --logs logs/ --video Generating Video ~~~~~~~~~~~~~~~~ To generate a video from the metadata logs, use ``aiviro-cli log video`` command. .. code-block:: console $ aiviro-cli log video --help $ aiviro-cli log video --input logs/runs/run-demo_test/images_metadata/ --output logs/runs/run-demo_test/videos/ Connectivity Testing -------------------- Using ``aiviro-cli test-connection --help`` command, you can run tests for various Aiviro components. For example to test and select the best configuration for Aiviro email module, use a following command: .. code-block:: console # Test IMAP email module $ aiviro-cli test-connection imap --host --username --password # Test SMTP email module $ aiviro-cli test-connection smtp --host --username --password # Test RDP module $ aiviro-cli test-connection rdp --host --username --password Statistics Calculation ---------------------- To facilitate performance monitoring and gain insights into your automation scenarios, Aiviro CLI offers several commands for calculating statistics based on different sources, including local logs and Prefect logs. This allows users to assess key metrics such as success rates, execution times, error frequencies, and more. Local Logs ~~~~~~~~~~ Use ``aiviro-cli log stats local --help`` command to calculate statistics based on local stats. Check the section :ref:`Log Structure` for more information about where to find local logs and stats. .. code-block:: console # Calculate statistics based on all local stats and save it to the specified folder $ aiviro-cli log stats local --input path/to/logs/stats/ --output path/to/folder/ # Split statistics into months and select only 'main_story01' scenario (referring to the main_story01.py file) $ aiviro-cli log stats local --input path/to/logs/stats/ --output path/to/folder --name main_story01 --monthly .. warning:: The ``--name`` parameter must match the name of the Python script under which logs are stored, not the name of the Scenario class or Prefect flow. Using incorrect name may result in a warning that no data was found after filtering. Prefect Logs ~~~~~~~~~~~~ To retrieve data from Prefect GraphQL API, you can use ``aiviro-cli log stats prefect --help`` command. .. code-block:: console # Calculate statistics based on all Prefect logs in the specified time range and save raw data into excel file $ aiviro-cli log stats prefect --endpoint --start-date 01-01-2024 --end-date 01-03-2024 --output path/to/folder/ # Split the statistics into months and save raw data into excel file $ aiviro-cli log stats prefect --endpoint --start-date 01-01-2024 --end-date 01-03-2024 --output path/to/folder/ --monthly Deployment as Web App --------------------- .. note:: It's required to install ``deploy`` from :ref:`Optional dependencies` section. To test certain Aiviro functionality you can deploy it as a web application. .. code-block:: console $ aiviro-cli deploy --help Explorer ~~~~~~~~ Explorer allows you to list all available logs and metadata. You can easily download text, image or video logs. It can also analyze these logs and detect errors. .. code-block:: console # to deploy explorer locally as a web-app without docker container $ aiviro-cli deploy explorer local --logs path/to/logs/ # to deploy explorer as a docker container $ aiviro-cli deploy explorer start --logs path/to/logs/ --detach # to stop docker deployment $ aiviro-cli deploy explorer stop .. figure:: ../../images/deploy_explorer_logs.png :width: 100% List of available logs in Aiviro Explorer. .. figure:: ../../images/deploy_explorer_overview.png :width: 100% Overview of selected log in Aiviro Explorer. .. figure:: ../../images/deploy_explorer_errors.png :width: 100% Errors detection in Aiviro Explorer. Reader ~~~~~~ Reader allows you to extract data from PDF files and calculate the accuracy of the extracted data. .. code-block:: console $ aiviro-cli deploy reader .. figure:: ../../images/deploy_reader.png :width: 100% Deployed Aiviro Reader as an interactive web application. Recognition ~~~~~~~~~~~ Recognition allows you to recognize text and elements in images, it shows you how Aiviro sees your application. .. code-block:: console $ aiviro-cli deploy recognition .. figure:: ../../images/deploy_recognition.png :width: 100% Deployed Aiviro Recognition as an interactive web application. .. _aiviro reader cli: Reader Scripts -------------- .. note:: It's required to install ``reader`` and ``pdf`` from :ref:`Optional dependencies` section. See section :ref:`Reader` below for web application to extract data from PDF files. There are several scripts under ``aiviro-cli reader --help`` command, which can be used to extract data from the provided PDF files. Other example is to calculate an accuracy of Aiviro Reader based on your ground-truth data export. For extraction and additional information about supported items, see :ref:`Invoice Processing` section. To extract all supported items from pdf files, use a following command: .. code-block:: console $ aiviro-cli reader extract --help $ aiviro-cli reader extract --input folder/pdfs/ --output output/folder/ To calculate reader's accuracy, see its example below. This calculation can be configured (*this is optional*) by providing a configuration file, see example of it below. Download :download:`reader_config.yaml <../../configs/reader_config.yaml>` .. literalinclude:: ../../configs/reader_config.yaml :language: yaml * ``required_column`` - columns which must be contained in both input csv files * ``map_column`` - used for renaming ground-truth csv file columns to standard name format * ``export_value`` - [optional] values to export from pdf-files, if not specified all values are exported .. code-block:: console $ aiviro-cli reader stats --help $ aiviro-cli reader stats --input export_data.csv --ground-truth gt_data.csv --output folder/ --config path/reader_config.yaml To check whether the exported data is also present in corresponding pdf files, use ``reader find``. .. code-block:: console $ aiviro-cli reader find --help $ aiviro-cli reader find --input pdf-folder/ --ground-truth gt_data.csv --output folder/ --config path/reader_config.yaml