Skip to main content

Yet another Python package for data generation

Project description

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/*

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

no_spark_in_my_home-1.0.4.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

no_spark_in_my_home-1.0.4-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file no_spark_in_my_home-1.0.4.tar.gz.

File metadata

  • Download URL: no_spark_in_my_home-1.0.4.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for no_spark_in_my_home-1.0.4.tar.gz
Algorithm Hash digest
SHA256 1e22d1a613b973a69f36b4940737cfc3e8ac75aafa757698f8bc1d1b7c8d43a1
MD5 980fd7b6b7fafe32753f372410a7fb1c
BLAKE2b-256 c91e2c6ee029dde2da6dd3f7798610997c696395c487ec5887518c555b8112d0

See more details on using hashes here.

File details

Details for the file no_spark_in_my_home-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for no_spark_in_my_home-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c4848eb67c6c21b173d7a302867d5c3a289f394f3269621609ede62ce9f5b3f2
MD5 24ffc13a2ba0acbb9cf0a33c74212d76
BLAKE2b-256 cb5ee2e51fbede7ea2f0b3a5e6e47acc99b8327a5ea27c040e451e0af03c2ea1

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