Skip to main content

A pipe-first language for data and ML work, running on top of Python

Project description

Peppermint

A pipe-first language for data and ML work, running on top of Python. Every operation is a pipeline step and errors propagate automatically. The Python ecosystem (pandas, scikit-learn, or your own code) is accessible from within the language.

Install

pip install peppermint-lang
pip install peppermint-lang[ml]    # + scikit-learn, umap, openai
pip install peppermint-lang[lsp]   # + language server
pip install peppermint-lang[all]   # everything

Or from source:

git clone https://github.com/chayapatr/peppermint
cd peppermint
pip install -e ".[all]"

Run

pep file.pep  # run a file
pep           # interactive REPL
pep lsp       # start language server (stdio)

Examples

load("employees.csv")
  |> filter(it.age > 18)
  |> add(tax: it.salary * 0.2)
  |> sort(by: "salary", dir: "desc")
  |> print()

Each step prints a live summary:

|> filter    → List  843 rows × 5 cols  (157 dropped)
|> add       → List  843 rows × 6 cols  (+tax)
|> sort      → List  843 rows × 6 cols
use ml
use viz
use env

load("data.csv")
  |> add(embedding: ml.embed(it.text,
      source: "deepinfra", model: "Qwen/Qwen3-Embedding-4B",
      apikey: env.DEEPINFRA_TOKEN))
      @concurrent(10)
  |> ml.kmeans(k: 2..8, on: "embedding", out: "cluster")
  |> ml.umap(dims: 2, on: "embedding", out: "umap")
  |> viz.scatter(x: "umap_1", y: "umap_2", color: "cluster", display: { label: "text", legend })
Aggregate
load("sales.csv")
  |> collapse(by: "region",
      avg: mean(col.revenue),
      n:   count()
  )
  |> sort(by: "avg", dir: "desc")
  |> print()
Top N per group
load("sales.csv")
  |> each(by: "region",
      |> add(rank: rank(col.revenue, dir: "desc"))
      |> filter(it.rank <= 3)
      |> drop("rank")
  )
  |> print()
LLM enrichment with retry and caching
use ml
use env

load("posts.csv")
  |> add(label: ml.llm(it.text,
      source: "openai", model: "gpt-4o",
      apikey: env.OPENAI_API_KEY, format: "json"))
      @concurrent(10)
      @retry(3)
      @until(it.label != none, max: 5)
      @cache

match(len(result.errors),
  == 0: result.data |> save("output.csv"),
  _:    halt("rerun to retry {len(result.errors)} failed rows")
)

@cache on ml.llm caches each row by content hash. Failed rows are never cached, so rerunning retries them automatically.

Error handling
result = load("data.csv")
  |> filter(it.score > 0.5)

match(result,
  Ok(data): data |> print(),
  Err(msg):  print(msg)
)
Python bridge
use "./transforms.py" as t

load("data.csv")
  |> t.clean()
  |> print()

Python functions receive and return plain Python types. Conversion is automatic.


Editor support

The LSP server (pep lsp) provides diagnostics, hover docs, completions, and go-to-definition for any LSP-capable editor.

VSCode — install the extension from ecosystem/vscode-peppermint/. It auto-discovers pep via mise, pyenv, or Homebrew — no PATH setup needed.

Neovim:

vim.lsp.start({ name = "peppermint", cmd = { "pep", "lsp" }, root_dir = vim.fn.getcwd() })

Helix (~/.config/helix/languages.toml):

[language-server.peppermint-lsp]
command = "pep"
args = ["lsp"]

See docs/language.md for the language reference, docs/stdlib.md for all stdlib functions, and docs/ecosystem.md for full editor setup.

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

peppermint_lang-0.4.0a2.tar.gz (58.5 kB view details)

Uploaded Source

Built Distribution

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

peppermint_lang-0.4.0a2-py3-none-any.whl (50.3 kB view details)

Uploaded Python 3

File details

Details for the file peppermint_lang-0.4.0a2.tar.gz.

File metadata

  • Download URL: peppermint_lang-0.4.0a2.tar.gz
  • Upload date:
  • Size: 58.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for peppermint_lang-0.4.0a2.tar.gz
Algorithm Hash digest
SHA256 a465432345c0889b2b12da3266a7c28388d8787068e2e04922ad5222d37eaee0
MD5 1b44547df59ae1e712af4d6a46731de8
BLAKE2b-256 f570d5ad8260a7ff4cda8d23441cafa6e8116f249cdf86a6945437f150e1f819

See more details on using hashes here.

Provenance

The following attestation bundles were made for peppermint_lang-0.4.0a2.tar.gz:

Publisher: workflow.yml on chayapatr/peppermint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file peppermint_lang-0.4.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for peppermint_lang-0.4.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 400bea5717baccb482aad63444754b2ce3bcc74b36069917225d801f20549957
MD5 ab5415d0f176ca88982439e5ab7d38ef
BLAKE2b-256 1417a6223c38a0e73fca2cc074a9935c402a2efbac095b09d7d0d35851b46dda

See more details on using hashes here.

Provenance

The following attestation bundles were made for peppermint_lang-0.4.0a2-py3-none-any.whl:

Publisher: workflow.yml on chayapatr/peppermint

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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