Skip to content

Commit

Permalink
Display resource state in expandable area
Browse files Browse the repository at this point in the history
  • Loading branch information
sultaniman committed Mar 12, 2024
1 parent 894316b commit 27e41af
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
21 changes: 11 additions & 10 deletions dlt/helpers/streamlit_app/blocks/resource_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
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


Expand All @@ -11,18 +14,16 @@ def resource_state_info(
schema_name: str,
resource_name: str,
) -> None:
sources = pipeline.state.get("sources") or {}
schema = sources.get(schema_name)
sources_state = pipeline.state.get("sources") or {}
schema = sources_state.get(schema_name)
if not schema:
st.error(f"Schema with name: {schema_name} is not found")
return

resource = schema["resources"].get(resource_name)
if not resource:
return

if "incremental" in resource:
for incremental_name, incremental_spec in resource["incremental"].items():
tag(incremental_name, label="Incremental")
spec = yaml.safe_dump(incremental_spec)
with st.expander("Resource state"):
resource = schema["resources"].get(resource_name)
if not resource:
st.info(f"{resource_name} is missing resource state")
else:
spec = yaml.safe_dump(resource)
st.code(spec, language="yaml")
2 changes: 1 addition & 1 deletion dlt/helpers/streamlit_app/blocks/table_hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def list_table_hints(pipeline: dlt.Pipeline, tables: List[TTableSchema]) -> None:
current_schema = pipeline.default_schema
current_schema = st.session_state["schema"] or pipeline.default_schema
if st.session_state["schema"]:
current_schema = st.session_state["schema"]

Expand Down

0 comments on commit 27e41af

Please sign in to comment.