Skip to main content

Fake data generator

This package generates fake sql-like format data from predefined schema. Data schema is defined using dataclasses.

Installation

python -m pip install no_spark_in_my_home

Usage

from datetime import datetime
from dataclasses import dataclass
from no_spark_in_my_home.src.generator import FakeDataGenerator


@dataclass
class Dataclass:
    item_id: int
    title: str
    date: datetime
    number: int
    
gen = FakeDataGenerator(
    Dataclass,
    limit=5,
)
spark_dataframe = gen.load()
spark_dataframe.show()

FakeDataGenerator params:

  • model - dataclass
  • limit - number of records
  • mask_per_field - dict with masks per field. Example: FakeDataGenerator(..., mask_per_field={"title": "A#### ###."})
  • range_per_field - dict with ranges per field. Example: FakeDataGenerator(..., range_per_field={"number": {"range": range(1, 10)}})
  • maxlength_per_field - dict with maxlengths for strings per field. Example: FakeDataGenerator(..., maxlength_per_field={"field_name": "title", "maxlength": 100, "fixed": True}). fixed=True will generate strings with fixed length. fixed=False will generate strings with non-fixed, but limited lengths.
  • config - path to config. Config should be yaml-formatted.
  • lang - locale. Default - "en"
  • foreign_keys - list of dicts that describes relations. Example: FakeDataGenerator(..., foreign_keys=[{"self_field": "item_id", "other_field": "another_item_id", "other_model": OtherDataclass, "other_data": other_dataclass_gen.load(as_dicts=True)}])

load params:

  • where_clause - string with where-clause for post-filtering. Example: load(..., where_clause="item_id > 5 and number = 10")
  • as_json - if True returns generated data as json
  • as_dicts - if True returns generated data as list of dicts

Building your own package version

In case you want to build your own package version you should follow this guide.

And then just build a wheel and install it.

Making and publishing a new release

  1. Update release version in pyproject.toml and setup.py
  2. Build package with python -m build
  3. Publish package with twine upload dist/*

Metadata

Release files for no-spark-in-my-home 1.0.4

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

Source distribution (sdist)

Source distribution for no-spark-in-my-home 1.0.4
File Size Uploaded Provenance Actions
no_spark_in_my_home-1.0.4.tar.gz 7.1 kB Without provenance Details for no_spark_in_my_home-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for no-spark-in-my-home 1.0.4
File Interpreter ABI Platform Actions
no_spark_in_my_home-1.0.4-py3-none-any.whl Python 3 none any Details for no_spark_in_my_home-1.0.4-py3-none-any.whl

Total release size: 14.4 kB

Release files / no_spark_in_my_home-1.0.4.tar.gz

Download URL no_spark_in_my_home-1.0.4.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1e22d1a613b973a69f36b4940737cfc3e8ac75aafa757698f8bc1d1b7c8d43a1
BLAKE2b-256 checksum
How to use checksums
c91e2c6ee029dde2da6dd3f7798610997c696395c487ec5887518c555b8112d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / no_spark_in_my_home-1.0.4-py3-none-any.whl

Download URL no_spark_in_my_home-1.0.4-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4848eb67c6c21b173d7a302867d5c3a289f394f3269621609ede62ce9f5b3f2
BLAKE2b-256 checksum
How to use checksums
cb5ee2e51fbede7ea2f0b3a5e6e47acc99b8327a5ea27c040e451e0af03c2ea1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for no-spark-in-my-home 1.0.4

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.

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