Skip to content

Commit 3c45d1a

Browse files
authored
Merge pull request #129 from automl/bug/group-name-visbility-enhancement
Bug/group name visbility enhancement
2 parents 93428bb + 2434f2b commit 3c45d1a

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
- Major overhaul of docstrings in various files
4646
- Removed unused imports and variables
4747

48+
## Groups
49+
- Groups now get a default name, if no name was entered by the user.
50+
- Groups get sorted alphabetically to appear more ordered.
51+
4852
## Additional Changes
4953
- Added a "make install examples" in Makefile
5054

deepcave/layouts/general.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ def get_layout(
337337

338338
# Load from cache if page is loaded
339339
children = []
340+
340341
for name, paths in groups.items():
341342
if name is None:
342343
continue
@@ -368,10 +369,29 @@ def callback(group_names: List[str], all_run_paths, i):
368369
self._refresh_groups = False
369370
raise PreventUpdate()
370371

372+
# For the default group names, if no name was entered
373+
group_counter = 0
374+
371375
groups = {}
372376
for group_name, run_paths in zip(group_names, all_run_paths):
373377
if group_name is None or group_name == "":
374-
continue
378+
# Set the default group name with a counter,
379+
# so the groups dont overwrite themselves
380+
group_name_unavailable = True
381+
382+
groups_cache = c.get("groups")
383+
if groups_cache is None:
384+
continue
385+
386+
# Check to see that no group name that already exists
387+
# gets picked
388+
while group_name_unavailable:
389+
group_name = f"Group {group_counter}"
390+
assert groups_cache is not None
391+
if group_name not in groups_cache.keys():
392+
group_name_unavailable = False
393+
else:
394+
group_counter += 1
375395

376396
if run_paths is None or len(run_paths) == 0:
377397
continue
@@ -386,16 +406,20 @@ def callback(group_names: List[str], all_run_paths, i):
386406

387407
groups[group_name] = valid_run_paths
388408

409+
# Sort the groups alphabetically, so when added
410+
# they appear ordered
411+
sorted_groups = dict(sorted(groups.items()))
412+
389413
try:
390414
# Now save it
391-
run_handler.update_groups(groups)
415+
run_handler.update_groups(sorted_groups)
392416
except NotMergeableError:
393417
notification.update("The selected runs are not mergeable.")
394418

395419
# This will automatically trigger the group display s.t. the selection is redo.
396420
return i + 1
397421

398-
self.logger.debug(f"Groups: {groups}")
422+
self.logger.debug(f"Groups: {sorted_groups}")
399423

400424
raise PreventUpdate()
401425

0 commit comments

Comments
 (0)