Skip to content

Commit

Permalink
Add yaml representer for pendulum datetime (#1192)
Browse files Browse the repository at this point in the history
* Add yaml representer for pendulum datetime

* Fix linting issues
  • Loading branch information
sultaniman authored Apr 5, 2024
1 parent 86f2d8d commit bded03c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions dlt/helpers/streamlit_app/blocks/resource_state.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
from typing import Union

import dlt
import pendulum
import streamlit as st
import yaml

from dlt.common import json
from dlt.common.libs.pandas import pandas as pd
from dlt.common.pipeline import resource_state, TSourceState
from dlt.common.schema.utils import group_tables_by_resource
from dlt.helpers.streamlit_app.widgets.tags import tag

def date_to_iso(
dumper: yaml.SafeDumper, data: Union[pendulum.Date, pendulum.DateTime]
) -> yaml.ScalarNode:
return dumper.represent_datetime(data) # type: ignore[arg-type]


yaml.representer.SafeRepresenter.add_representer(pendulum.Date, date_to_iso) # type: ignore[arg-type]
yaml.representer.SafeRepresenter.add_representer(pendulum.DateTime, date_to_iso) # type: ignore[arg-type]


def resource_state_info(
Expand All @@ -21,6 +28,7 @@ def resource_state_info(
return

resource = schema["resources"].get(resource_name)

with st.expander("Resource state", expanded=(resource is None)):
if not resource:
st.info(f"{resource_name} is missing resource state")
Expand Down

0 comments on commit bded03c

Please sign in to comment.