-
Notifications
You must be signed in to change notification settings - Fork 66
feat(tidy3d): FXC-3689 Per-Simulation Downloads During Batch Runs #2898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
marcorudolphflex
merged 1 commit into
develop
from
FXC-3689-per-simulation-downloads-during-batch-runs
Oct 17, 2025
Merged
feat(tidy3d): FXC-3689 Per-Simulation Downloads During Batch Runs #2898
marcorudolphflex
merged 1 commit into
develop
from
FXC-3689-per-simulation-downloads-during-batch-runs
Oct 17, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
2177a21 to
b5e27b7
Compare
Contributor
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/web/api/container.pytidy3d/web/api/tidy3d_stub.py |
b5e27b7 to
c2e34b5
Compare
yaugenst-flex
approved these changes
Oct 17, 2025
Collaborator
yaugenst-flex
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @marcorudolphflex looks great!
c2e34b5 to
5ec4203
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
refers to #2893
Previous State
Batch.run() waits for every job to finish (
Batch.monitor()) before callingBatch.download(), so even tasks that completed early don’t start transferring until the whole batch is done. This is a noticeable delay for large batches with many short simulations.Problem
Users want each simulation’s results to begin downloading immediately after that simulation hits success, rather than waiting for the entire batch to complete.
Solution
Monitor-triggered downloads: Extend the
Batch.monitor()loop to detect job transitions to success and queuejob.download()right away via a shared executor given the kwargdownload_on_success.Download in
Batch.load()is then skipped by having kwargskip_downloadwhich isFalseas default for other callers.Greptile Overview
Updated On: 2025-10-15 14:32:52 UTC
Greptile Summary
This PR implements per-simulation downloads during batch runs to improve user experience by downloading completed simulations immediately rather than waiting for the entire batch to finish. The change extends the
Batch.monitor()method with adownload_on_successparameter that creates a ThreadPoolExecutor to handle concurrent downloads when individual jobs reach "success" status. TheBatch.run()method is updated to usemonitor(download_on_success=True)followed byload(skip_download=True)to avoid double-downloading. This addresses a performance bottleneck where users experienced unnecessary delays for large batches with many short simulations that completed at different times.Changed Files
Confidence score: 4/5
Sequence Diagram
sequenceDiagram participant User participant Batch as "Batch" participant Job as "Job" participant WebAPI as "webapi" participant Executor as "ThreadPoolExecutor" participant Progress as "Progress Bar" User->>+Batch: "run(path_dir)" Batch->>+Batch: "_check_path_dir(path_dir)" Batch-->>-Batch: "create dir if needed" Batch->>+Batch: "upload()" Note over Batch,Job: "Upload Phase" Batch->>+Executor: "ThreadPoolExecutor(max_workers)" loop "For each job" Batch->>+Job: "job.upload()" Job->>+WebAPI: "web.upload(**kwargs)" WebAPI-->>-Job: "task_id" Job-->>-Batch: "uploaded" end Batch->>+Progress: "create progress bar" Progress-->>-Batch: "show upload progress" Executor-->>-Batch: "all uploads complete" Batch->>+Batch: "to_file(batch_path)" Batch-->>-Batch: "save batch.hdf5 with task_ids" Note over Batch,Job: "Start Phase" Batch->>+Batch: "start(priority)" loop "For each job" Batch->>+Job: "job.start(priority)" Job->>+WebAPI: "web.start(task_id, priority)" WebAPI-->>-Job: "started" Job-->>-Batch: "started" end Batch-->>-Batch: "all jobs started" Note over Batch,Job: "Monitor Phase with Downloads" Batch->>+Batch: "monitor(download_on_success=True)" Batch->>+Executor: "download_executor = ThreadPoolExecutor()" loop "Until all jobs complete" loop "For each job" Batch->>+Job: "job.status" Job->>+WebAPI: "web.get_info(task_id)" WebAPI-->>-Job: "status info" Job-->>-Batch: "status" alt "status == 'success'" Batch->>+Executor: "submit download job" Executor->>+Job: "job.download(path)" Job->>+WebAPI: "web.download(task_id, path)" WebAPI-->>-Job: "download complete" Job-->>-Executor: "file saved" Executor-->>-Batch: "download future" end end Batch->>+Progress: "update progress bars" Progress-->>-Batch: "display updated status" end Executor-->>-Batch: "all downloads complete" Batch-->>-Batch: "monitoring complete" Note over Batch,User: "Load Phase" Batch->>+Batch: "load(path_dir, skip_download=True)" Batch->>+Batch: "create BatchData object" Batch-->>-Batch: "BatchData with task_paths" Batch-->>-User: "BatchData"