Skip to main content

Introduction

This project is a library that can be used to interact with RS3 through python.

Goal

Each function exposed corresponds to an equivalent operation you could have done through the UI.
Using this idea, the user should be able to edit models and get results without having to go through the UI at all. Although only a limited set of functionality is exposed for now, some basic workflows should still be possible. For a list of the functionality we have so far, see Exposed Functionality.

Python UI equivalents

Events and workflows done in the UI will have equivalents in the python library.
Wherever a dialog is shown in the UI, there will be an equivalent class with methods that mimick the dialog's behavior.
Wherever a warning or error dialog is displayed, an exception will be thrown, or a warning will be displayed in python instead.
Wherever you can select and manipulate an entity, identifiers can be used in the library to get references to those entities in python and objects will be constructed to help you interface with them.

How it works

Each function in the library is a wrapper to make an api call to the Application.
Objects retrieved through function calls will often not contain any data themselves, but will instead be proxies, allowing you to get information from the objects in the application.
For this reason, debugging will sometimes be tricky, as not all data will always be available for you to inspect unless you get it and assign it to a variable yourself.

Warnings

References can be invalidated whenever the corresponding object in the application is destroyed or reloaded. You will need to watch out for expired referenecs and renew them when needed as it can cause crashes or incorrect results if not managed properly. Functions that invalidate objects will always be marked with a warning and will indicate which objects should be re-loaded.

Exposed Functionality

Getting Started

Getting started guide

First Tutorial

For Contributors:

Build

First, make sure you have python installed on your computer. Then follow the steps to build:

  1. Run the command below to install the python build module.
    python -m pip install --upgrade build
  2. Run the script to build and reinstall: ./buildAndReinstall.bat

The next time you update the library, it can be re-built and re-installed using: ./buildAndReinstall.bat

Unit Testing

To ensure the project's functionality and maintain code quality, a test suite using the unittest framework has been implemented. The documentation for unittest can be found at the following link: https://docs.python.org/3/library/unittest.html

Creating Unit Tests

Directory Structure:

  • Place new .py files for unit testing in the tests directory.
  • Save any RS3 files required for testing in the tests/resources directory.

Handling Test Resources:
Instead of directly modifying the base files in tests/resources, create copies of these files in each test file's setup and delete them in the teardown phase. This ensures that the original resources remain intact and unmodified after running the tests.

Running Unit Test Cases

Before running the tests, make sure you have:

  1. Built the RS3 library as explained in the Build section.
  2. Started the RS3 Modeler.
  3. Started the RS3 Interpreter.
  4. Started the Server on both the RS3 Modeler and RS3 Interpreter.

To run a test, vscode has a 'Testing' section, where you can run inidividual tests:
alt text

To run all the tests, navigate to the root directory of the project and execute the following command:
python -m unittest discover -s tests

To run an individual test file from the command line, navigate to the root directory of the project and execute the following command with the correct filename:
python -m unittest discover -s tests -p "<sampleTestFile>.py"

To run a sub-folder of tests, navigate to the 'tests' folder, and run:
python -m unittest discover -v -s Path/To/Folder

NOTE: To display additional information on the results of the unit tests, pass the -v option into the testing command:
python -m unittest discover -v -s tests

Documentation

The following steps can be taken to regenerate the RS3 Scripting Documentation:

  1. Create python a virtual environment. Navigate to the root directory of your workspace and run the commands below:
    python -m venv venv venv/Scripts/activate
  2. Rebuild the RS3 library in your virtual environment by following the Build section.
  3. Install the documentation requirement packages. pip install -r docs/requirements.txt
  4. To rerun all examples with the command below: python docs/example_code/runAll.py
  5. To generate the documentation run the following: python generateAndBuildDocumentation.py
  6. The Documentation in html format will be located here: RS3 Python Client Library/docs/_build/index.html

Adding To Documentation

The following steps can be taken to add a new proxy object to the autogenerated documentation:

  1. Ensure automatic generation of the proxy object python files has been completed for the new proxy object.
  2. To include an example code snippet, ensure a docstring is being generated at the top of the base proxy object .py file, which will link to the example.
    See Below:
     """
     :ref:`Bolt Example`
     """
    
  3. Add your example code snippet to docs\example_code
  4. Open examples.rst and following the format of the existing example links, add a link to your code example. Ensure that your link label matches the link label being generated in Step 2.
    See Below:
    .. _Bolt Example:
    
  5. Follow the steps in Documentation to regenerate the new documentaiton.

Contribution Guidelines

Contributions are welcomed to improve RS3's Scripting Features. To make a contribution, follow the guidelines below:

  1. Make Changes: Start by making the necessary changes to the relevant .py file(s) to address the task or implement new features.
  2. Install Dependencies: Install the required dependencies specified in the requirements.txt file, as explained in the Build section. It is recommended that these dependencies be installed within a virtual environment.
  3. Python Interpreter: Select the same Python interpreter used to install the package. You can specify the interpreter in your virtual environment or project settings.
  4. Testing: Thoroughly test your changes to ensure they meet the project's requirements and do not introduce regressions. Consult the Unit Testing section for more information. Include additional test cases to cover modifications to the project.
  5. Pull Request: After thorough testing and review, submit a pull request which describes the purpose of your changes. After review and approval, merge your changes into the main branch.

Metadata

Release files for RS3Scripting 4.44.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RS3Scripting 4.44.0
File Size Uploaded Provenance
rs3scripting-4.44.0.tar.gz 259.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for RS3Scripting 4.44.0
File Interpreter ABI Platform
rs3scripting-4.44.0-py3-none-any.whl Python 3 none any Details

Total release size: 765.5 kB

Release files / rs3scripting-4.44.0.tar.gz

Download URL rs3scripting-4.44.0.tar.gz
Size 259.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7db5589abd9160c74beaee32e381fe6da2082d58433fedbf3eb8f7fa9a3fda9d
BLAKE2b-256 checksum
How to use checksums
c4aad41fc7c8d16c4b88e960641e0747770798a0c21bacbbfa49094e9a837344
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Release files / rs3scripting-4.44.0-py3-none-any.whl

Download URL rs3scripting-4.44.0-py3-none-any.whl
Size 505.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b7564fe58c70c86173c27107d4ca8fc182eddafed2fc2243b3e9730ca66a5b4
BLAKE2b-256 checksum
How to use checksums
313165282f705f840993970bed0d9cf6ed456d65d8e355cd16752e9d8cd8882a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.11

Security for RS3Scripting 4.44.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page