Skip to content

Commit

Permalink
Added validations for variable group selection
Browse files Browse the repository at this point in the history
In the case where the algorithm developer didn't select the proper variable in the 'get_group_variables' in the data loader, the error was being thrown much later and was very hard to trace.
  • Loading branch information
ThanKarab committed Nov 1, 2024
1 parent d253d72 commit cbda677
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,4 @@ pyrightconfig.json
/configs
/smpc_configs
.stored_data/
*.db
9 changes: 8 additions & 1 deletion exareme2/controller/services/exareme2/controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import concurrent
import itertools
import traceback
from abc import ABC
from abc import abstractmethod
Expand Down Expand Up @@ -194,7 +195,7 @@ def __init__(
A boolean flag denoting if the 'Not Available' values will be kept in the
"data model views" or not
check_min_rows: bool
A boolean flag denoting if a "minimum row count threshol" will be in palce
A boolean flag denoting if a "minimum row count threshold" will be in place
or not
command_id: int
A unique id
Expand Down Expand Up @@ -228,6 +229,12 @@ def create_data_model_views(
if self._data_model_views:
return

if not list(itertools.chain(*self._variable_groups)):
raise ValueError(
"There are not variables in the 'variable_groups' of the algorithm. "
"Please check that the 'variable_groups' in the data loader are pointing to the proper variables."
)

views_per_localworker = {}
for worker in self._local_workers:
try:
Expand Down
4 changes: 4 additions & 0 deletions exareme2/controller/services/exareme2/tasks_handler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import itertools
from typing import List
from typing import Optional

Expand Down Expand Up @@ -87,6 +88,9 @@ def create_data_model_views(
dropna: bool = True,
check_min_rows: bool = True,
) -> List[TableInfo]:
if not list(itertools.chain(*columns_per_view)):
raise ValueError("'columns_per_view' are completely empty.")

result_str = self._worker_tasks_handler.create_data_model_views(
request_id=self._request_id,
context_id=context_id,
Expand Down

0 comments on commit cbda677

Please sign in to comment.