Skip to main content

locust

"It's git diff --stat on steroids!" - @scottmilliken

What is Locust?

Locust helps you reason about your code base as it evolves over time.

Locust provides a semantic layer on top of git diff. It emits metadata describing AST-level changes to your code base between git revisions.

This metadata is useful to both humans and computers. For example:

  1. (Humans) Locust can generate much more humane summaries of changes than the standard git diff.

  2. (Computers) Bugout.dev uses Locust metadata to learn high level abstractions about code.

Installation

Locust requires Python3 (specifically, it was written in Python3.8).

Install from PyPI

pip install -U setuptools
pip install bugout-locust

Install from source

Clone this repository and run from the project root:

python setup.py install

Docker

You can also use the Locust docker image:

docker pull bugout/locust

Usage

CLI

Locust is a command line tool, and you can invoke it as:

locust 22dd7fd6adf392bb29d13d10f10e7dbb1d97bfce c9813bd5871a9919551ccd917712135c40367c5c --format yaml

This produces the following output:

locust:
  - file: locust/ci_helpers/github.py
    changes:
      - name: generate_argument_parser
        type: function
        line: 11
        changed_lines: 9
        total_lines: 9
        children: []
      - name: helper_push
        type: function
        line: 22
        changed_lines: 13
        total_lines: 13
        children: []
      - name: helper_pr
        type: function
        line: 37
        changed_lines: 14
        total_lines: 14
        children: []
      - name: main
        type: function
        line: 53
        changed_lines: 29
        total_lines: 29
        children: []
refs:
  initial: 22dd7fd
  terminal: c9813bd

Language plugins

To use Locust to process a code base containing Python (>3.5) and Javascript, use the Javascript plugin (written in Node 14).

If you are running Locust from the root of this project, you would do this as follows:

locust -r <path to repo> <initial revision> <terminal revision> --plugins "node js/out/index.js"

A Locust language plugin is simply a program that you can invoke from the shell (like node js/out/index.js) which takes two arguments:

  • -i - an input file containing a locust.git.RunResponse object

  • -o - path to an output file into which it writes a list of tuples consisting of locust.git.PatchInfo objects and their corresponding list of locust.parse.RawDefinition objects.

The Javascript plugin provides a rubric for how to build your own plugin.

You can add custom plugins to a Locust invocation like this:

locust -r <path to repo> <initial revision> <terminal revision> \
  --plugins "node js/out/index.js" "<custom plugin invocation 1>" "<custom plugin invocation 2>"

CI/CD

Locust is easy to use in CI/CD pipelines:

Docker

To run Locust using docker:

docker run -v $ABSOLUTE_PATH_TO_GIT_REPO:/usr/src/app bugout/locust -r /usr/src/app \
    $INITIAL_REVISION \
    $TERMINAL_REVISION \
    --format yaml

Output formats

Locust can produce output in many formats. The currently supported formats are:

  1. JSON (--format json)

  2. YAML (--format yaml)

  3. HTML (--format html)

  4. GitHub-flavored HTML, meant to be used with GitHub styles (--format html-github)

Contributing

Running tests

Make sure to clone simiotics/locust-test-cases repo to your machine.

Run:

git -c <path to locust-test-cases repo> fetch origin

Then, from the root of this repo:

LOCUST_TESTCASES_DIR=<path to locust-test-cases repo> ./test.sh

Similar projects

Kythe

Kythe is a Google open source project. It grew out of the need to semantically link different parts of Google's code base.

The goals of Locust are different from those of Kythe. Locust is specifically about generating metadata describing changes to code.

Kythe on GitHub: https://github.com/kythe/kythe

Download files

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

Source Distribution

bugout-locust-0.2.5.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

bugout_locust-0.2.5-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file bugout-locust-0.2.5.tar.gz.

File metadata

  • Download URL: bugout-locust-0.2.5.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for bugout-locust-0.2.5.tar.gz
Algorithm Hash digest
SHA256 9955aaa31dd734a3be370ccf2391ae186a874a9734c16d7707a973c0317e9fce
MD5 6d742f559d3eef9f36d0ae868f98d077
BLAKE2b-256 243bcfe0ce16e0bdbb55d268f2385b4fc4918353d975308315f785234edad104

See more details on using hashes here.

File details

Details for the file bugout_locust-0.2.5-py3-none-any.whl.

File metadata

  • Download URL: bugout_locust-0.2.5-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for bugout_locust-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 73d1fb6dbc55ba7eb4454dd48efcda3e8b3d9f04d16b393d71c402840dc2e841
MD5 a221f78744707b62bb76740f72567b63
BLAKE2b-256 642e7a5af3d3895651ff089fd2695775fac459bf5b78f511584938c6b833e2d2

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

This release

0.2.5 This release

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.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.0

3 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