Skip to content
Open
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
36 changes: 36 additions & 0 deletions lab-sdk/src/lab/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,42 @@ def get_all(cls):
if storage.exists(index_file):
with storage.open(index_file, "r") as f:
data = json.load(f)

name = data.get("name")
exp_id = data.get("id")

# If both name and id are missing, skip this experiment
if not name and not exp_id:
print(
f"Experiment at {exp_path} missing required 'name' and 'id' fields; skipping"
)
continue

# If name missing but id present, copy id -> name and persist
if not name and exp_id:
data["name"] = exp_id
try:
with storage.open(index_file, "w") as wf:
json.dump(data, wf, indent=4)
name = exp_id
except Exception:
# If we couldn't persist, skip to avoid inconsistent state
continue

# If id missing but name present, copy name -> id and persist
if not exp_id and name:
data["id"] = name
try:
with storage.open(index_file, "w") as wf:
json.dump(data, wf, indent=4)
exp_id = name
except Exception as e:
print(
f"Failed to write corrected index.json for experiment '{name}' at {index_file} (copied name -> id): {e}"
)
# If we couldn't persist, skip to avoid inconsistent state
continue

experiments.append(data)
except Exception:
pass
Expand Down
72 changes: 38 additions & 34 deletions src/renderer/components/Experiment/SelectExperimentMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export default function SelectExperimentMenu({ models }) {
sx={{
backgroundColor: 'transparent !important',
fontSize: '20px',
color: 'var(--joy-palette-neutral-plainDisabledColor)',
color: 'var(--joy-palette-neutralDisabledColor)',
paddingLeft: 1,
paddingRight: 0,
minHeight: '22px',
Expand Down Expand Up @@ -332,43 +332,47 @@ export default function SelectExperimentMenu({ models }) {
>
{isLoading && <MenuItem>Loading...</MenuItem>}
{data &&
data.map((experiment: any) => {
return (
<MenuItem
selected={experimentInfo?.name === experiment.name}
variant={
experimentInfo?.name === experiment.name
? 'soft'
: undefined
}
onClick={createHandleClose(experiment.name)}
key={experiment.id}
sx={{
display: 'flex',
alignItems: 'center',
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
}}
>
<span
style={{
overflow: 'hidden',
data
.filter(
(experiment: any) => experiment?.id && experiment?.name,
) // skip bad rows
.map((experiment: any) => {
return (
<MenuItem
selected={experimentInfo?.id === experiment.id}
variant={
experimentInfo?.id === experiment.id
? 'soft'
: undefined
}
onClick={createHandleClose(experiment.id)}
key={experiment.id}
sx={{
display: 'flex',
alignItems: 'center',
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
flex: 1,
minWidth: 0,
}}
title={experiment.name}
>
{experiment.name}
</span>
{experimentInfo?.name === experiment.name && (
<CheckIcon style={{ marginLeft: 'auto' }} />
)}
</MenuItem>
);
})}
<span
style={{
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
flex: 1,
minWidth: 0,
}}
title={experiment.name}
>
{experiment.name}
</span>
{experimentInfo?.id === experiment.id && (
<CheckIcon style={{ marginLeft: 'auto' }} />
)}
</MenuItem>
);
})}
</Box>
<Divider />
<MenuItem onClick={() => setModalOpen(true)}>
Expand Down