Untitled
import logging import click import pandas as pd from google.protobuf.wrappers_pb2 import DoubleValue from tradewell.data.s3 import write_s3_table from tradewell.util.cli import load_config, run_click_command from tradewell.util.proto import now_header from tradewell.util.pyarrow import log_table_stats, proto_records_to_table from tradewell.util.tradewell_s3_file_system import create_file_system from tradewell_proto.quote_pb2 import Quote logger = logging.getLogger(__name__) TABLE_NAME = "batch-example" @click.command() @click.option("--date", type=pd.Timestamp, required=True) def batch_example(date: pd.Timestamp) -> None: config = load_config() file_system = create_file_system(config.env_bucket, config) # Load all your data # Train your model # Then you evaluate your model on the given 'date' to generate prices # Store those prices in a pandas dataframe # Convert your pandas dataframe into PyArrow Table df = gen_predictions_for_date(date) table = your_func_to_convert_pandas_df_to_pyarrow_table(df) log_table_stats(logger, TABLE_NAME, table) write_s3_table(table, TABLE_NAME, date, file_system) if __name__ == "__main__": run_click_command(batch_example)
Leave a Comment