Skip to main content

Run lightweight local workflows

Project description

Dyngle

Run lightweight local workflows

Dyngle is a simple workflow runner that executes sequences of commands defined in configuration files. It's like a lightweight combination of Make and a task runner, designed for automating common development and operational tasks.

Basic usage

Create a configuration file (e.g., .dyngle.yml) with your workflows:

dyngle:
  operations:
    build:
      - python -m pip install -e .
      - python -m pytest
    deploy:
      - docker build -t myapp .
      - docker push myapp
    clean:
      - rm -rf __pycache__
      - rm -rf .pytest_cache

Run an operation:

dyngle run build

Configuration

Dyngle reads configuration from YAML files. You can specify the config file location using:

  • --config command line option
  • DYNGLE_CONFIG environment variable
  • .dyngle.yml in current directory
  • ~/.dyngle.yml in home directory

The configuration has 2 parts: operations: and expressions.

Configuration files can import other configuration files, by providing an entry imports: with an array of filepaths. The most obvious example is a Dyngle config in a local directory which imports the user-level configuration.

dyngle:
  imports:
    - ~/.dyngle.yml
  expressions:
  operations:

In the event of item name conflicts, expressions and operations are loaded from imports in the order specified, so imports lower in the array will override those higher up. The expressions and operations defined in the main file override the imports. Imports are not recursive.

Data

Dyngle maintains a block of data throughout operations, which is parsed from YAML in stdin.

Operations

Operations contain steps as a YAML array. The lifecycle of an operation is:

  1. Load input data if it exists from YAML on stdin (if no tty)
  2. Perform template rendering on a step, using data and expressions (see below)
  3. Execute the step in a subprocess
  4. Continue with the next step

Note that operations in the config are not full shell lines. They are passed directly to the system.

Templates

Prior to running commands, the line containing that command is processed as a template. Entries from the data set can be substituted into the command line using Jinja-like expressions in double-curly brackets ({{ and }}).

For example, if stdin contains the following data:

name: Francis

And the command looks like:

- echo "Hello {{name}}!"

Then the command will output "Hello Francis!".

Expressions

Configs can also contain expressions, written in Python, that can also be referenced in operation steps.

dyngle:
  expressions:
    say-hello: >-
        'Hello ' + name + '!'
  operations:
    say-hello: echo {{say-hello}}

Expressions can use a controlled subset of the Python standard library, including:

  • Built-in data types such as str()
  • Essential built-in functions such as len()
  • The core modules from the datetime package (but some methods such as strftime() will fail)
  • A specialized function called formatted() to perform string formatting operations on a datetime object
  • A restricted version of Path() that only operates within the current working directory
  • Various other useful utilities, mostly read-only, such as the math module
  • A special function called resolve which resolves data expressions using the same logic as in templates

Data keys containing hyphens are converted to valid Python names by replacing hyphens with underscores.

Expressions can reference data directly as local names in Python (using the underscore replacements)...

dyngle:
  expressions:
    say-hello: >-
        'Hello ' + full_name + '!'

... or using the resolve() function, which also allows expressions to essentially call other expressions, using the same underlying data set.

dyngle:
  expressions:
    hello: >-
        'Hello ' + resolve('formal-name') + '!'
    formal-name: >-
        'Ms. ' + full_name

Note it's also possible to call other expressions by name as functions, if they only return hard-coded values (i.e. constants).

dyngle:
  expressions:
    author-name: Francis Potter
    author-hello: >-
        'Hello ' + author_name()

Local Expressions

Expressions can also be defined in a way that applies only to one operation - especially useful for command-line arguments.

In this case, the operation definition has a different structure. See the example below.

dyngle:
  operations:
    name_from_arg:
      expressions:
        local_name: "args[0]"
      steps:
        - echo "Hello {{local_name}}"

Security

Commands are executed using Python's subprocess.run() with arguments split in a shell-like fashion. The shell is not used, which reduces the likelihood of shell injection attacks. However, note that Dyngle is not robust to malicious configuration. Use with caution.

Quick installation (MacOS)

brew install python@3.11
python3.11 -m pip install pipx
pipx install dyngle

Project details


Download files

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

Source Distribution

dyngle-0.6.0.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

dyngle-0.6.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file dyngle-0.6.0.tar.gz.

File metadata

  • Download URL: dyngle-0.6.0.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for dyngle-0.6.0.tar.gz
Algorithm Hash digest
SHA256 236ce7c2b49c0812ddbae4af9e53517c1509399a35094da96344704aaa8ed4e0
MD5 f4361e5753372173ebdb8bd76bbf4a68
BLAKE2b-256 0bc4d4a6c03f10e5b33ddfb2b5e4de4d61a3f30dc5bb5d255fad602afa160a7b

See more details on using hashes here.

File details

Details for the file dyngle-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: dyngle-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for dyngle-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 462b5bbd05134ca6156a80c8720c2e8e2d4722147d8051af2d959e5ebadff966
MD5 c9701292e85e87dd944d65200c8f312f
BLAKE2b-256 d84f24d964b3d7de544580ff52a5abc7e1933cbb49c41c8b939bfafc7e8cb1ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page