GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - importt-ant/ki-gen: Zero-dependency seeded key generation framework for Python — define parameter spaces, generate unique keys, and persist results.

BranchesTags
Open more actions menu

Latest commit

 

History

50 Commits
50 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
src/kigen
src/kigen
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

ki šŸ§¬ā—: ki-gen

Generic seeded generator framework with dedup and SQLite persistence.

Install

pip install ki-gen

# With Sobol quasi-random engine (optional)
pip install ki-gen[sobol]

Requires Python 3.12+.

Quick start

from kigen import Blueprint, Enum, Generator, Key, Param

# 1. Define a Key with typed fields
class SoundKey(Key):
    pitch       = Param(min=20, max=20_000)
    sample_rate = Param(min=8000, max=96_000)
    osc         = Enum("sine", "square", "sawtooth", "triangle")

# 2. Create a Blueprint — configure overrides or pin static values
bp = (
    Blueprint(SoundKey)
    .configure("sample_rate", 44_100)                   # always 44100
    .configure("pitch", Param(min=1000, max=2000))      # narrow range
)

# 3. Run the generator
gen = Generator(bp, seed=42)
key = gen.generate()
# SoundKey(id='...', pitch=1427, sample_rate=44100, osc='sine')

Core concepts

Key

A Key subclass is a structured parameter container. Declare fields using descriptors:

Field Description
Param Numeric with optional min, max, step. Validated on assignment.
Enum Categorical — options fixed at class definition.
Pool Categorical — options populated once at runtime, then frozen.
Field Abstract base — subclass for custom field types.
class ToneKey(Key):
    pitch     = Param(min=40, max=20_000)
    amplitude = Param(min=0.0, max=1.0, step=0.01)
    osc       = Enum("sine", "square", "sawtooth")

key = ToneKey(pitch=440, amplitude=0.8, osc="sine")
key.pitch = 99_999  # ValueError: above maximum

Blueprint

A Blueprint describes how each field should be produced — narrowed bounds, restricted choices, or pinned to a static value. It's engine-agnostic and reusable.

bp = Blueprint(ToneKey).configure("pitch", Param(min=200, max=800))

Recorder

Recorder handles dedup and persistence. It can be used directly as a recorder:

from kigen import Recorder, Store

with Store("my.db") as store:
    recorder = Recorder(name="api-ingest", store=store)

    key = ToneKey(pitch=440, amplitude=0.8, osc="sine")
    is_new = recorder.record(key)   # True (first time)
    is_dup = recorder.record(key)   # False (duplicate)
    recorder.flush()

Generator

Generator combines a Blueprint with a pluggable Rengine (RNG engine) and adds the generate/dedup loop:

from kigen import Generator, Store

with Store("my.db") as store:
    gen = Generator(bp, seed=42, store=store)
    keys = gen.generate_many(100)
    gen.flush()

Rengine

The RNG engine protocol. Two built-in implementations:

Engine Description
RandomRengine stdlib random.Random — default when no engine is specified.
SobolRengine Quasi-random Sobol sequence (requires scipy). O(1) fast-forward on resume.
from kigen import SobolRengine

gen = Generator(bp, seed=42, rengine=SobolRengine(seed=42, dimensions=8))

Persistence

Store is a SQLite-backed store. Generators auto-resume from where they left off:

with Store("my.db") as store:
    gen = Generator(bp, seed=42, store=store)
    keys = gen.generate_many(50)
    gen.flush()

# Later — resumes at key 51
with Store("my.db") as store:
    gen = Generator(bp, seed=42, store=store)
    more = gen.generate_many(50)
    gen.flush()

Project structure

src/kigen/
ā”œā”€ā”€ __init__.py
ā”œā”€ā”€ blueprint.py          # Blueprint — field randomization plan
ā”œā”€ā”€ key.py                # Key — structured parameter container
ā”œā”€ā”€ store.py              # Store — SQLite persistence
ā”œā”€ā”€ fields/
│   ā”œā”€ā”€ field.py          # Field (base descriptor)
│   ā”œā”€ā”€ param.py          # Param (numeric min/max/step)
│   ā”œā”€ā”€ enum.py           # Enum (categorical, class-time)
│   └── pool.py           # Pool (categorical, runtime-populated)
ā”œā”€ā”€ recorders/
│   ā”œā”€ā”€ recorder.py       # Recorder (dedup + persistence)
│   └── generator.py      # Generator (generation loop)
└── rengines/
    ā”œā”€ā”€ protocol.py       # Rengine protocol + FastForwardNotSupported
    ā”œā”€ā”€ random.py          # RandomRengine (stdlib)
    └── sobol.py           # SobolRengine (scipy)

API reference

See docs/index.md.

About

Zero-dependency seeded key generation framework for Python — define parameter spaces, generate unique keys, and persist results.

Topics

deduplicationgeneratorkey-generationparameter-generationrandomizationseededsobolsqlite

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Ɨ600. No cookies required.