Factoreally
Generate realistic test data from real data patterns.
Factoreally involves two steps:
- Analyze sample data → create a factory spec based on input data
- 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
Metadata
Release files for factoreally 0.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| factoreally-0.6.1.tar.gz | 87.9 kB | Without provenance | Details for factoreally-0.6.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| factoreally-0.6.1-py3-none-any.whl | Python 3 | none | any | Details for factoreally-0.6.1-py3-none-any.whl |
Total release size: 134.9 kB
Release files / factoreally-0.6.1.tar.gz
| Download URL | factoreally-0.6.1.tar.gz |
|---|---|
| Size | 87.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e910161496d802429f33dbe091a71f17458df8c63010b477ab4e5a6debb8244a
|
|
BLAKE2b-256 checksum How to use checksums |
8cf799406b5e671555b11c2f98d7d8402058bb7bf72cc62b7adaed567a12c8d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.6.5
|
Release files / factoreally-0.6.1-py3-none-any.whl
| Download URL | factoreally-0.6.1-py3-none-any.whl |
|---|---|
| Size | 47.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3bd443cc69993b0f06bcb0a679df46795d30487b201296aa6c07f961ff186f0e
|
|
BLAKE2b-256 checksum How to use checksums |
34e4bdad3ff45a598cc5eeb56f287edb162c3bc2c2d534eee1c0b1d6d3ce8941
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.6.5
|
Security for factoreally 0.6.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.