Lien
09/05/2023, 3:48 PMdata_asset
and simply output to as a csv?
from dagster import StaticPartitionsDefinition, AssetExecutionContext, asset
import pandas as pd
dataset_partitions_def = StaticPartitionsDefinition(
["weather", "rain"]
)
@asset(partitions_def=dataset_partitions_def)
def data_asset(context: AssetExecutionContext):
# read in the content
Example I/O manager
class MyPartitionedIOManager(IOManager):
def _get_path(self, context) -> str:
if context.has_partition_key:
return (f"/sfo_q2_{context.asset_partition_key}_sample.csv")
else:
return "/".join(context.asset_key.path)
def handle_output(self, context, obj):
obj.to_csv(f"/output/sfo_q2_{context.asset_partition_key}_sample.csv")
def load_input(self, context):
return pd.read_csv(self._get_path(context))
Odette Harary
09/05/2023, 8:52 PMLien
09/14/2023, 8:28 AM