Skip to main content

script-runner

A tool for defining python functions, triggering their execution and displaying results via a user interface.

Used at Sentry to allow specific users to run predefined Python scripts on production data.

Deployment modes

Multi-region deployments enable aggregating results across multiple "regions" or "silos", whilst still enabling script execution to be performed in a single region.

  • set mode: main for the central region
  • set mode: region for each instance of the application deployed in each regions

For a single deployment in one region use mode:combined. Currently we only use this for dev and testing.

Writing custom scripts

Scripts are standard python functions organized into groups.

All of the arguments to a function must be annotated with one of the supported parameter types. The currently supported ones are:

  • Text
  • Textarea
  • Integer
  • Number
  • Autocomplete
  • DynamicAutocomplete

Example:

def print_value(input: Text) -> None:
    """
    for short text, renders <input type="text" /> in the ui
    """
    print(input.value)

def print_long_value(input: TextArea) -> None:
    """
    multiline text, renders <textarea /> in the ui
    """
    print(input.value)

The annotation controls how the element is displayed in the UI, and the Python type of the value (str, int or float)

The return value of the function can be anything, as long as it is json serializable

Any functions exported by a module via __all__ will be picked up automatically and displayed in the UI.

Writing tests

Use the execute_with_context helper from the testutils module to call your function with mock values.

Authentication

currently google iap (and no auth) are supported

for google iap, set the audience_code as well as iap_principals (group -> iap principal mapping) in the config

Example data:

  • These are in the examples/scripts directory

Configuration

check config.schema.json for configuration format and required fields. there is also an example of each mode in this repository: example_config_combined.yaml, example_config_main.yaml, example_config_local.yaml

Development

  • Run make devserver. The application will run on combined mode on http://127.0.0.1:5000

  • If you want UI hot reloading, you have to run the vite server separately.

  • Navigate to the frontend directory:

    cd script_runner/frontend
    
  • Install dependencies if you haven't already:

    npm install
    
  • Run the Vite development server:

    npm run dev
    
  • The frontend should now be running on http://localhost:5173 and will automatically proxy API requests to the backend thanks to the proxy configured in vite.config.ts.

Download files

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

Source Distribution

sentry_script_runner-1.0.3.tar.gz (73.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentry_script_runner-1.0.3-py3-none-any.whl (1.8 MB view details)

Uploaded Python 3

File details

Details for the file sentry_script_runner-1.0.3.tar.gz.

File metadata

  • Download URL: sentry_script_runner-1.0.3.tar.gz
  • Upload date:
  • Size: 73.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for sentry_script_runner-1.0.3.tar.gz
Algorithm Hash digest
SHA256 cb33a51f4bd05962536d25446b2abcae071a09469c6a0a118e7dd9ea39683a6a
MD5 a178361a953588c8a1209659e92aca39
BLAKE2b-256 9e9692547c0fef61683ce3dd73c8cbfaf431021ba16ca067fbd29fbbdad2b88b

See more details on using hashes here.

File details

Details for the file sentry_script_runner-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for sentry_script_runner-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f4dbf35c65c63f0d544fa61d31dbc8a48667b41c8d299cf3bdeaad34282547f5
MD5 55dcf5092ee5bee2c79267580f75040e
BLAKE2b-256 cd7359c48f8b18cdba0bf8220a8dbdb150c94ca7f9ab33f1ac0be1088651895b

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.4

2 files

This release

1.0.3 This release

2 files

1.0.2

2 files

1.0.1

2 files

1.0.0

2 files

0.2.9

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

0.2.4

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

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