Sample test data (#10487)

Co-authored-by: bogdan kyryliuk <bogdankyryliuk@dropbox.com>
This commit is contained in:
Bogdan
2020-08-03 09:08:49 -07:00
committed by GitHub
parent 821916a681
commit ab404ea2cf
8 changed files with 46 additions and 19 deletions

View File

@@ -52,9 +52,10 @@ def gen_filter(
}
def load_data(tbl_name: str, database: Database) -> None:
def load_data(tbl_name: str, database: Database, sample: bool = False) -> None:
pdf = pd.read_json(get_example_data("birth_names.json.gz"))
pdf.ds = pd.to_datetime(pdf.ds, unit="ms")
pdf = pdf.head(100) if sample else pdf
pdf.to_sql(
tbl_name,
database.get_sqla_engine(),
@@ -72,7 +73,9 @@ def load_data(tbl_name: str, database: Database) -> None:
print("-" * 80)
def load_birth_names(only_metadata: bool = False, force: bool = False) -> None:
def load_birth_names(
only_metadata: bool = False, force: bool = False, sample: bool = False
) -> None:
"""Loading birth name dataset from a zip file in the repo"""
# pylint: disable=too-many-locals
tbl_name = "birth_names"
@@ -80,7 +83,7 @@ def load_birth_names(only_metadata: bool = False, force: bool = False) -> None:
table_exists = database.has_table_by_name(tbl_name)
if not only_metadata and (not table_exists or force):
load_data(tbl_name, database)
load_data(tbl_name, database, sample=sample)
obj = db.session.query(TBL).filter_by(table_name=tbl_name).first()
if not obj: