Skip to content

Commit

Permalink
fix single structure upload (#736)
Browse files Browse the repository at this point in the history
* fix single structure upload

* fix upload append (test this)

* bugfix in place update
  • Loading branch information
PythonFZ authored Nov 18, 2024
1 parent 32507bc commit 7c7286b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 5 additions & 2 deletions app/src/components/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ export const setupFrames = (
if (x?.start > step && frame_update) {
setStep(x.start);
} else if (x?.start === step) {
setStep(x.start);
const frame = await currentRoomCon.get(step);
setCurrentFrameFromObject(frame);
} else if (x?.indices?.includes(step)) {
const frame = await currentRoomCon.get(step);
setCurrentFrameFromObject(frame);
Expand All @@ -368,7 +369,9 @@ export const setupFrames = (
if (x?.start > step && frame_update) {
setStep(x.start);
} else if (x?.start === step) {
setStep(x.start);
// this should never happen?
const frame = await defaultRoomCon.get(step);
setCurrentFrameFromObject(frame);
} else if (x?.indices?.includes(step)) {
const frame = await defaultRoomCon.get(step);
setCurrentFrameFromObject(frame);
Expand Down
10 changes: 3 additions & 7 deletions zndraw/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def upload(
typer.echo(f"Uploading to: {url}/token/{vis.token}")

if not append:
size = len(vis)
print(f"Deleting {size} existing figures ...")
del vis[: size - 1]
del vis[:]
typer.echo(f"Reading {fileio.name} ...")

generator = get_generator_from_filename(fileio)
Expand All @@ -41,9 +39,7 @@ def upload(
if browser:
webbrowser.open(f"{url}/token/{vis.token}")

if not append:
# There must be a frame otherwise removing everything currently doesn't work
del vis[0]
vis.extend(frames[1:])
if len(frames) > 1:
vis.extend(frames[1:])

vis.figures.update(load_plots_to_dict(plots, fileio.remote, fileio.rev))

0 comments on commit 7c7286b

Please sign in to comment.