Skip to main content

Add your description here

Project description

Factoreally

Generate realistic test data from real data patterns.

Factoreally involves two steps:

  1. Analyze sample data → create a factory spec based on input data
  2. Use the factory spec → generate realistic data based on the factory spec

It automatically detects patterns (UUIDs, timestamps, email formats, numeric distributions) and generates statistically accurate test data that matches your real data.

Features

  • Pattern detection: UUIDs, timestamps, emails, phone numbers, custom formats
  • Statistical accuracy: Maintains distributions and value frequencies
  • Dynamic objects: Detects and generates varying dictionary keys
  • Null handling: Preserves optional field probabilities
  • Batch generation: Efficiently generate thousands of records

Quick Start

1. Analyze sample data to create a factory spec

# Basic spec generation
factoreally create --in real_user_payloads.json --out user.spec.json

# With Pydantic model to identify dynamic dictionary fields
factoreally create \
  --in user_payloads.json \
  --out user.spec.json \
  --model myapp.models.UserModel

2. Use the factory spec to generate data

from factoreally import Factory

# Create factory from spec
user_factory = Factory("user.spec.json")

# Generate single object
user_data = user_factory.build()

# Generate batch
users = user_factory[:1000]

# Integrate with Pydantic models
user = UserModel.model_validate(user_factory.build())

Customization

# Create factory with built-in overrides
admin_factory = Factory(spec, role="admin", permissions__level="high")

# Per-generation overrides
user = user_factory.build(email="specific@example.com")

# Nested field overrides
user = user_factory.build(address__country="US", profile__verified=True)

# Array element overrides
user = user_factory.build(items__name="default", items__value=None)  # override all array elements
user = user_factory.build(items__0__name="first", items__0_value=1) # override specific array index

# Dynamic overrides with callables
user = user_factory.build(
    id=lambda: str(uuid.uuid4()),  # Generate new value
    name=lambda value: value.upper(),  # Transform generated value
    display_name=lambda value, obj: f"{value} ({obj['role']})"  # Use context of entire generated object
)

Pydantic Integration

Provide a Pydantic model to help identify dynamic dictionary fields:

class UserEvent(BaseModel):
    user_id: str
    metadata: dict[str, str]  # Factoreally treats this as dynamic dict
factoreally create --in events.json --out events.spec.json --model myapp.models.UserEvent

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

factoreally-0.5.0.tar.gz (84.6 kB view details)

Uploaded Source

Built Distribution

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

factoreally-0.5.0-py3-none-any.whl (46.3 kB view details)

Uploaded Python 3

File details

Details for the file factoreally-0.5.0.tar.gz.

File metadata

  • Download URL: factoreally-0.5.0.tar.gz
  • Upload date:
  • Size: 84.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.5

File hashes

Hashes for factoreally-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b65df6f1897eab86136fbf1dacac469b06ebd321bfce6a8d65fda68bd4dc3302
MD5 12e8ec97423b4209505e6131e35d1e92
BLAKE2b-256 fb03008afa0b7fee9c3ea1e7c16d0319aa8bbd36fd12ded5eee5b7a15af1a237

See more details on using hashes here.

File details

Details for the file factoreally-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for factoreally-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9ca9fd81a9be9d7561a50b7b02662f0f045a7b27c1db8b423509c230bf93459
MD5 ba7b03d690d30df4b6a689f99004ca13
BLAKE2b-256 d6dc7eca9d1918d7cab78d7ad59d24220e537c624417bf1b5cb15bd1b72dbb1a

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