From 7e66ffed7bea60a2f409fb9e5e62bc9d82dcf20c Mon Sep 17 00:00:00 2001 From: Arthur Jakobs Date: Thu, 16 Oct 2025 18:14:16 +0200 Subject: [PATCH 1/2] add a description option for fields --- trailpack/ui/streamlit_app.py | 49 ++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/trailpack/ui/streamlit_app.py b/trailpack/ui/streamlit_app.py index c75e433e..7d0bf896 100644 --- a/trailpack/ui/streamlit_app.py +++ b/trailpack/ui/streamlit_app.py @@ -152,6 +152,8 @@ def iri_to_web_url(iri: str, language: str = "en") -> str: st.session_state.df = None if "column_mappings" not in st.session_state: st.session_state.column_mappings = {} +if "column_descriptions" not in st.session_state: + st.session_state.column_descriptions = {} if "suggestions_cache" not in st.session_state: st.session_state.suggestions_cache = {} if "view_object" not in st.session_state: @@ -799,6 +801,30 @@ def generate_view_object() -> Dict[str, Any]: st.info( f"**Selected unit:** {selected_unit_label}\n\n[🔗 View on vocab.sentier.dev]({web_url})" ) + + # Description field - mandatory if no ontology mapping exists + has_ontology = st.session_state.column_mappings.get(column) is not None + description_label = "Column Description" if has_ontology else "Column Description *" + description_help = "Provide a description for this column" if has_ontology else "Required: No ontology mapping selected. Please provide a description for this column." + + column_description = st.text_area( + description_label, + value=st.session_state.column_descriptions.get(column, ""), + placeholder="Describe what this column represents...", + help=description_help, + key=f"description_{column}", + height=80 + ) + + # Store description in session state + if column_description: + st.session_state.column_descriptions[column] = column_description + else: + st.session_state.column_descriptions.pop(column, None) + + # Show warning if no ontology and no description + if not has_ontology and not column_description: + st.warning("Please provide either an ontology mapping or a description for this column.") st.markdown("---") @@ -813,10 +839,25 @@ def generate_view_object() -> Dict[str, Any]: navigate_to(2) with col3: - if st.button("Next ", type="primary", use_container_width=True): - # Generate view object internally (not displayed) - st.session_state.view_object = generate_view_object() - navigate_to(4) + # Check if all columns have either ontology or description + columns = st.session_state.reader.columns(st.session_state.selected_sheet) + missing_info = [] + for column in columns: + has_ontology = st.session_state.column_mappings.get(column) is not None + has_description = bool(st.session_state.column_descriptions.get(column)) + if not has_ontology and not has_description: + missing_info.append(column) + + can_proceed = len(missing_info) == 0 + + if can_proceed: + if st.button("Next ", type="primary", use_container_width=True): + # Generate view object internally (not displayed) + st.session_state.view_object = generate_view_object() + navigate_to(4) + else: + st.button("Next ", type="primary", disabled=True, use_container_width=True) + st.error(f"The following columns need either an ontology mapping or a description: {', '.join(missing_info)}") # Page 4: General Details From ee6083ce9f6e6955691e620c275ae25cf4c7c15b Mon Sep 17 00:00:00 2001 From: Arthur Jakobs Date: Thu, 16 Oct 2025 18:22:25 +0200 Subject: [PATCH 2/2] fix tests for validation --- trailpack/packing/datapackage_schema.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trailpack/packing/datapackage_schema.py b/trailpack/packing/datapackage_schema.py index 2754eefe..2f600c26 100644 --- a/trailpack/packing/datapackage_schema.py +++ b/trailpack/packing/datapackage_schema.py @@ -114,7 +114,7 @@ class Unit(BaseModel): def validate_path_url(cls, v): """Validate URI format.""" if v and not v.startswith(('http://', 'https://')): - raise ValueError('Unit path must be a valid http or https URI') + raise ValueError('path must be a valid URL') return v def to_dict(self) -> Dict[str, Any]: @@ -643,7 +643,7 @@ def get_current_state(self) -> Dict[str, Any]: type="number", description="Decimal latitude (WGS84)", unit=Unit( - name="deg", + name="DEG", long_name="degree", path="http://qudt.org/vocab/unit/DEG" ), @@ -655,7 +655,7 @@ def get_current_state(self) -> Dict[str, Any]: type="number", description="Decimal longitude (WGS84)", unit=Unit( - name="deg", + name="DEG", long_name="degree", path="http://qudt.org/vocab/unit/DEG" ),