Skip to content

Commit

Permalink
Merge pull request #831 from Gliese852/ensure-unique-id
Browse files Browse the repository at this point in the history
Ensure Model ID is unique
  • Loading branch information
boltgolt committed Sep 5, 2023
2 parents 5385699 + ef60fa5 commit 3cc017b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions howdy/src/cli/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@
# Set the default label
label = "Initial model"

# some id's can be skipped, but the last id is always the maximum
next_id = encodings[-1]["id"] + 1 if encodings else 0

# Get the label from the cli arguments if provided
if builtins.howdy_args.arguments:
label = builtins.howdy_args.arguments[0]

# If models already exist, set that default label
elif encodings:
label = _("Model #") + str(len(encodings) + 1)
# Or set the default label
else:
label = _("Model #") + str(next_id)

# Keep de default name if we can't ask questions
if builtins.howdy_args.y:
Expand All @@ -106,7 +109,7 @@
insert_model = {
"time": int(time.time()),
"label": label,
"id": len(encodings),
"id": next_id,
"data": []
}

Expand Down

0 comments on commit 3cc017b

Please sign in to comment.