Skip to content

Commit

Permalink
Fix #505
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrotsmnrd committed Dec 16, 2024
1 parent 6ba57ab commit f70b5fa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
18 changes: 12 additions & 6 deletions ragna/deploy/_ui/components/metadata_filters_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ def __init__(self, corpus_metadata, **params):
)
self.add_filter_row_button.on_click(self.add_filter_row)

self.corpus_names_select.param.watch(self.reset_filter_rows, "value")


def create_filter_row(self):
return [
FilterRow(
Expand All @@ -165,9 +164,6 @@ def create_filter_row(self):
)
]

def reset_filter_rows(self, event=None):
self.filter_rows = self.create_filter_row()

def add_filter_row(self, event):
self.filter_rows = self.filter_rows + self.create_filter_row()

Expand All @@ -188,7 +184,7 @@ def render_filters_rows(self):
*self.filter_rows,
css_classes=["metadata-filter-row-collection"],
)

def construct_metadata_filters(self):
metadata_filters = [
filter_row.construct_metadata_filter()
Expand All @@ -201,6 +197,16 @@ def construct_metadata_filters(self):
return MetadataFilter.and_(metadata_filters).to_primitive()

def __panel__(self):


if len(self.corpus_names) == 0:
return pn.Column(
pn.pane.HTML("<b>No corpus available for selected source storage</b>"),
sizing_mode="stretch_both",
height_policy="max",
)


return pn.Column(
self.corpus_names_select,
pn.pane.HTML("<b>Metadata Filters</b>"),
Expand Down
6 changes: 5 additions & 1 deletion ragna/deploy/_ui/modal_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ def add_error_message(self):
)
def corpus_or_upload_row(self):
if self.corpus_or_upload == USE_CORPUS_LABEL:

if self.config.source_storage_name in self.corpus_names:
corpus_names = self.corpus_names[self.config.source_storage_name]
else:
Expand All @@ -428,7 +429,10 @@ def corpus_or_upload_row(self):
corpus_names=corpus_names, corpus_metadata=corpus_metadata
)

data = pn.Column(self.metadata_filter_rows_title, self.metadata_filter_rows)
if len(corpus_names) > 0:
data = pn.Column(self.metadata_filter_rows_title, self.metadata_filter_rows)
else:
data = pn.Column(self.metadata_filter_rows)

self.error = False
return data
Expand Down

0 comments on commit f70b5fa

Please sign in to comment.