Skip to content

Commit

Permalink
consume generator in batches of 16
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonFZ committed Nov 18, 2024
1 parent e73c179 commit 4f9608f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions zndraw/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def upload(
append: bool,
plots: list[str],
browser: bool,
batch_size: int = 16,
):
"""Upload a file to ZnDraw."""
if token is None:
Expand All @@ -34,12 +35,21 @@ def upload(

generator = get_generator_from_filename(fileio)

frames = list(generator)
vis.append(frames[0])
if browser:
webbrowser.open(f"{url}/token/{vis.token}")

if len(frames) > 1:
vis.extend(frames[1:])
frames = []
for frame in generator:
frames.append(frame)
if len(frames) == batch_size:
vis.extend(frames)
frames = []
vis.extend(frames)
# frames = list(generator)
# vis.append(frames[0])


# if len(frames) > 1:
# vis.extend(frames[1:])

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

0 comments on commit 4f9608f

Please sign in to comment.