Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions trailpack/packing/datapackage_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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"
),
Expand All @@ -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"
),
Expand Down
49 changes: 45 additions & 4 deletions trailpack/ui/streamlit_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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("---")

Expand All @@ -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
Expand Down