battetl.load package

Submodules

battetl.load.Loader module

class battetl.load.Loader.Loader(config: dict, env_path: str = '/home/docs/checkouts/readthedocs.org/user_builds/battetl/checkouts/latest/docs/.env', battdb_version: float = 11.2)

Bases: object

load_cycle_stats(df: DataFrame) int

Loads cycle stats to the target database. Any cycles that already exist in the database that overlap with the new cycle data will be overwritten.

Parameters:

df (pd.DataFrame) – Data Frame containing test data to load to database.

Returns:

num_rows_loaded – The number of rows inserted into the test_data table.

Return type:

int

load_test_data(df: DataFrame, retry_cnt: int = 0) int

Loads test data to the target database. Only loads data past the latest unixtime_s field that already exists in the test_data table.

Parameters:
  • df (pd.DataFrame) – Data Frame containing test data to load to database.

  • retry_cnt (int, optional) – The number of times to retry loading data to the database.

Returns:

num_rows_loaded – The number of rows inserted into the data table.

Return type:

int

battetl.load.batt_db_test_helper module

class battetl.load.batt_db_test_helper.BattDbTestHelper(config: dict)

Bases: Loader

cell_id = None
cell_type_id = None
create_test_db_entries()

Creates various entries into the database that the tests assume exist. Assert to make sure the inserts actually happened. If they fail, then likely there is data in the database that needs to be cleared. Easiest course of action in that case is rebuilding the database from scratch.

customer_id = None
cycle_id = None
cycler_type_id = None
delete_entry(target_table, pk_col_name, pk_id)

Drops an entry from a meta table.

Parameters:
  • target_table (str) – The name of the meta table. E.g. “cells_meta”

  • pk_col_name (str) – The name of the primary key column. E.g. “cell_type_id”

  • pk (int) – The primary key id number. E.g 1

delete_test_data()

Deletes all data from from data tables

delete_test_db_entries()

Deletes the test_db entries created in self.create_test_db_entries

generate_random_string(len=20) str

Generates a random string of length len.

Parameters:

len (int) – The desired length of the random string

Returns:

random_string – A random string of length len.

Return type:

str

load_df_to_db(df: DataFrame, target_table: str) int

Loads the passed data frame to the passed target_table in the database specified in the config.

Parameters:
  • df (pd.DataFrame) – Data frame to load to database.

  • target_table (str) – Table to load the data frame to.

Returns:

num_rows_inserted – The number of rows inserted into the target_table.

Return type:

int

load_sil_data(df: DataFrame) int

Loads the passed sil_data to the database.

Parameters:

df (pd.DataFrame) – Dataframe with data to load to sil_data table

Returns:

num_rows_loaded – The number of rows loaded to the sil_data table

Return type:

int

load_sim_data(df: DataFrame) int

Loads the passed sim_data to the database.

Parameters:

df (pd.DataFrame) – Dataframe with data to load to sim_data table

Returns:

num_rows_loaded – The number of rows loaded to the sim_data table

Return type:

int

profile_id = None
read_first_row(target_table: str, pk_col_name: str) tuple

Returns the first row in the target_table, sorting off of pk_col_name.

Parameters:
  • target_table (str) – The table pull the first row from

  • pk_col_name (str) – The name of the column for the primary key id.

Returns:

pk_id – The primary key id for the newly inserted row. Returns None if issue with inserting rows.

Return type:

int

read_last_row(target_table: str, pk_col_name: str) tuple

Returns the last row in the target_table, sorting off of pk_col_name.

Parameters:
  • target_table (str) – The table pull the last row from

  • pk_col_name (str) – The name of the column for the primary key id.

Returns:

pk_id – The primary key id for the newly inserted row. Returns None if issue with inserting rows.

Return type:

int

schedule_id = None
test_id = None

battetl.load.quick_loader module

class battetl.load.quick_loader.QuickLoader(file_path)

Bases: Loader

load_cycle_stats(df: DataFrame) int

Loads cycle stats to the target database. Any cycles that already exist in the database that overlap with the new cycle data will be overwritten.

Parameters:

df (pd.DataFrame) – Data Frame containing test data to load to database.

Returns:

num_rows_loaded – The number of rows inserted into the test_data table.

Return type:

int

load_test_data(df: DataFrame, retry_cnt: int = 0) int

Loads test data to the target database. Only loads data past the latest unixtime_s field that already exists in the test_data table.

Parameters:
  • df (pd.DataFrame) – Data Frame containing test data to load to database.

  • retry_cnt (int, optional) – The number of times to retry loading data to the database.

Returns:

num_rows_loaded – The number of rows inserted into the data table.

Return type:

int

Module contents