Skip to main content

Faker Events

CI PyPI Python Quality Gate Coverage License

Generate realistic, stateful event streams for development, demos, load tests, and data-pipeline validation—without copying production data.

Version 2 is a ground-up rewrite for Python 3.11+. It provides isolated generator state, deterministic runs, validated configuration, async delivery, virtual-time batches, cron schedules, and fast JSON serialization.

Core concepts

  • Profiles are people or entities that act independently.
  • State is persistent data belonging to one profile, such as an account balance or status.
  • Activity events simulate actions performed by people or external actors.
  • Scheduled operations simulate recurring system work against current profile state.
  • Outputs deliver immutable event snapshots to JSON Lines, Kafka, Kinesis, or custom destinations.

See the v1→v2 regression assessment for the complete preserved, improved, intentionally changed, and removed behavior matrix.

Install

pip install faker-events

Install only the stream adapters you need:

pip install "faker-events[kafka]"
pip install "faker-events[kinesis]"

Try it

The built-in example writes JSON Lines to stdout and progress to stderr:

faker-events run --profiles 10 --max-events 100 --seed 42

Persist generated entities across runs:

faker-events run --profiles 100 --profile-file profiles.json

Persist profile mutations made by event transforms:

faker-events run account_flow.py --profile-file profiles.json --update-profiles

Generate a historical batch without sleeping:

faker-events run \
  --start 2026-01-01T00:00:00+00:00 \
  --end 2026-01-02T00:00:00+00:00

Define a stateful flow

Activity and scheduled events can share explicit state for each profile:

from faker_events import SKIP, Event, EventGenerator, ProfileGenerator, State

profiles = ProfileGenerator(seed=42).create(10)
account = State({"total": 0})


def save(context, _profile):
    context.state["total"] += 110
    return {
        "type": "money.saved",
        "change": 110,
        "total": context.state["total"],
    }


def hourly_fee(context, _profile):
    if context.state["total"] < 10:
        return SKIP
    context.state["total"] -= 10
    return {
        "type": "account.fee",
        "change": -10,
        "total": context.state["total"],
    }


saved = Event({"type": "money.saved"}, save, state=account, limit=0)
fee = Event(
    {"type": "account.fee"},
    hourly_fee,
    state=account,
    schedule="0 * * * *",
    limit=0,
)

generator = EventGenerator(profiles, [saved, fee])
generator.start()

State is cloned for every profile and generator. Reusing one State instance lets human activity and system operations inspect and mutate the same entity without leaking state globally.

See Stateful activity and scheduled operations for detailed semantics, conditional operations, expected output, and a runnable savings example.

For a v1-style shared event structure, use State directly as the template:

account = State({"type": "account", "total": 0})
saved = Event(account, save)
fee = Event(account, hourly_fee, schedule="0 * * * *")

Transforms may update context.data or context.state, return a mapping to merge into the emitted event, or return SKIP to suppress delivery. State mutations persist even when output is skipped.

Use event >> next_event for a sequence and event >> [a, b] to branch. limit=0 repeats indefinitely. max_events bounds processing attempts, including skipped events, so conditional infinite flows can still terminate.

Live and batch execution

The synchronous interface is suitable for scripts:

generator.start()
generator.batch(start, end)

Async applications can use await generator.run_live() and await generator.run_batch(start, end).

Virtual-time batches do not sleep. Activity and scheduled operations are processed strictly in timestamp order, so later activity cannot affect an earlier scheduled operation.

CLI scripts

The CLI accepts a Python file exposing build(profiles, output, *, seed, max_events) -> EventGenerator:

faker-events run account_flow.py --profiles 10

Runnable examples:

Outputs

from faker_events import KafkaOutput, KinesisOutput

kafka = KafkaOutput("events", "localhost:9092")
kinesis = KinesisOutput("events", partition_key=lambda event: event["customer_id"])

Custom outputs implement three async methods:

class Output:
    async def open(self) -> None: ...
    async def send(self, event: dict) -> None: ...
    async def close(self) -> None: ...

The included Kinesis adapter batches records. The Kafka adapter uses confluent-kafka/librdkafka and verifies delivery.

Migration from 1.x

Version 2 intentionally removes global configuration:

  • Pass profiles, first events, output, and config to EventGenerator.
  • Use start() and batch() from synchronous scripts, or await their run_live() and run_batch() counterparts.
  • Wrap a shared structure in State, or pass it with state=, when activity and scheduled events must share persistent per-profile data.
  • Use rate instead of epm; variance is a fraction from 0 to 1.
  • Use schedule instead of cron.
  • Use ConsoleOutput, KafkaOutput, or KinesisOutput instead of Stream.
  • Return SKIP instead of the string "skip".
  • context.id is an integer rather than a string.
  • context.time is an aware datetime; call .isoformat() when the event schema requires a string.
  • profile.birthdate is a date; JSON profile files still use ISO strings.
  • Event timestamps default to UTC; set an IANA timezone such as Europe/Copenhagen in GeneratorConfig when needed.
  • User scripts expose a build(...) function instead of mutating class state.

These changes allow multiple independent generators to run safely in one process.

Metadata

Release files for faker-events 2.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for faker-events 2.0.1
File Size Uploaded Provenance Actions
faker_events-2.0.1.tar.gz 29.6 kB With provenance Details for faker_events-2.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for faker-events 2.0.1
File Interpreter ABI Platform Actions
faker_events-2.0.1-py3-none-any.whl Python 3 none any Details for faker_events-2.0.1-py3-none-any.whl

Total release size: 49.0 kB

Release files / faker_events-2.0.1.tar.gz

Download URL faker_events-2.0.1.tar.gz
Size 29.6 kB
Tags Source
SHA-256 checksum
How to use checksums
533142e64e50732548145aea0c97c2025fdd6be319cd5f62b5ad5f97915a37e6
BLAKE2b-256 checksum
How to use checksums
a648e0d842f9edadaf3fed4c6d7fb8b53a32e329e30e7e10798b6a37f3811d8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / faker_events-2.0.1-py3-none-any.whl

Download URL faker_events-2.0.1-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19ea0819e489d424e397e79d878663467fd3c17eb310934e54be9bc50da0edad
BLAKE2b-256 checksum
How to use checksums
4753d1402246137a2af7053e099c2e09d00be6c58f967852c11baba67c04cd52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for faker-events 2.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for faker_events-2.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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