From 27e41af04c38649d899b630d9e53a7c45af0815d Mon Sep 17 00:00:00 2001 From: Sultan Iman Date: Tue, 12 Mar 2024 11:21:06 +0100 Subject: [PATCH] Display resource state in expandable area --- .../streamlit_app/blocks/resource_state.py | 21 ++++++++++--------- .../streamlit_app/blocks/table_hints.py | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dlt/helpers/streamlit_app/blocks/resource_state.py b/dlt/helpers/streamlit_app/blocks/resource_state.py index 9cb1259d54..728acdd93a 100644 --- a/dlt/helpers/streamlit_app/blocks/resource_state.py +++ b/dlt/helpers/streamlit_app/blocks/resource_state.py @@ -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 @@ -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") diff --git a/dlt/helpers/streamlit_app/blocks/table_hints.py b/dlt/helpers/streamlit_app/blocks/table_hints.py index 8ef3c6e946..4882444d99 100644 --- a/dlt/helpers/streamlit_app/blocks/table_hints.py +++ b/dlt/helpers/streamlit_app/blocks/table_hints.py @@ -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"]