Skip to content

Commit

Permalink
metdata for trips
Browse files Browse the repository at this point in the history
  • Loading branch information
odette-elementl committed Jul 17, 2023
1 parent af9a838 commit d595cbf
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dagster_university/assets/trips.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dagster import asset
from dagster import asset, MetadataValue
from dagster_duckdb import DuckDBResource

import pandas as pd
import requests

from . import constants
Expand All @@ -11,7 +11,7 @@
@asset(
group_name="raw_files",
)
def taxi_zones_file():
def taxi_zones_file(context):
"""
The raw CSV file for the taxi zones dataset. Sourced from the NYC Open Data portal.
"""
Expand All @@ -21,6 +21,9 @@ def taxi_zones_file():

with open(constants.TAXI_ZONES_FILE_PATH, "wb") as output_file:
output_file.write(raw_taxi_zones.content)
num_rows = len(pd.read_csv(constants.TAXI_ZONES_FILE_PATH))
context.add_output_metadata({'Number of records': MetadataValue.int(num_rows)})


## Lesson 4 (HW) , 6
@asset(
Expand Down Expand Up @@ -64,7 +67,9 @@ def taxi_trips_file(context):

with open(constants.TAXI_TRIPS_TEMPLATE_FILE_PATH.format(month_to_fetch), "wb") as output_file:
output_file.write(raw_trips.content)

num_rows = len(pd.read_parquet(constants.TAXI_TRIPS_TEMPLATE_FILE_PATH.format(month_to_fetch)))
context.add_output_metadata({'Number of records':MetadataValue.int(num_rows)})


## Lesson 4, 8, 6
@asset(
Expand Down

0 comments on commit d595cbf

Please sign in to comment.