Skip to content

Conversation

QingengWei
Copy link
Contributor

@QingengWei QingengWei commented Aug 25, 2025

Greptile Summary

This PR adds priority parameter support to the Tidy3D web API's batch processing system, specifically targeting vGPU queue management. The changes enable users to specify task priority levels from 1 (lowest) to 10 (highest) when submitting simulations to the vGPU queue.

The implementation adds the priority parameter to three key components:

  1. Job class (container.py): Both Job.run() and Job.start() methods now accept an optional priority parameter
  2. Batch class (container.py): Both Batch.run() and Batch.start() methods now support priority, with proper threading implementation to ensure all jobs in a batch inherit the same priority
  3. run_async function (asynchronous.py): The high-level async interface now accepts priority and passes it through to the underlying batch processing

The parameter propagation follows a clear chain: run_async()Batch.run()Batch.start() → individual Job.start()webapi.start(). All methods maintain backward compatibility by making priority optional with a default value of None. The change integrates well with the existing codebase architecture and follows established patterns for parameter passing through the web API layers.

This enhancement gives users fine-grained control over task execution order in the vGPU queue, which is valuable for managing multiple simulations with different urgency levels.

Important Files Changed

Click to expand file changes
Filename Score Overview
tidy3d/web/api/container.py 4/5 Added priority parameter to Job and Batch classes with proper propagation through run/start methods
tidy3d/web/api/asynchronous.py 4/5 Added priority parameter to run_async function with documentation and batch integration

Confidence score: 4/5

  • This PR is generally safe to merge with well-structured changes that maintain backward compatibility
  • Score reflects solid implementation following established patterns, though some edge cases around parameter validation could be addressed
  • Pay close attention to the threading implementation in Batch.start() to ensure priority is properly propagated to all jobs

Sequence Diagram

sequenceDiagram
    participant User
    participant run_async
    participant Batch
    participant Job
    participant web
    
    User->>run_async: "run_async(simulations, priority=5)"
    run_async->>Batch: "Batch(simulations, folder_name, ...)"
    run_async->>Batch: "batch.run(path_dir, priority)"
    Batch->>Batch: "upload()"
    Batch->>Batch: "start(priority)"
    loop for each job in batch
        Batch->>Job: "job.start(priority)"
        Job->>web: "web.start(task_id, solver_version, pay_type, priority)"
    end
    Batch->>Batch: "monitor()"
    Batch->>User: "return BatchData"
Loading

@QingengWei
Copy link
Contributor Author

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 6 comments

Edit Code Review Bot Settings | Greptile

Copy link
Contributor

Diff Coverage

Diff: origin/develop...HEAD, staged and unstaged changes

  • tidy3d/web/api/asynchronous.py (100%)
  • tidy3d/web/api/container.py (100%)

Summary

  • Total: 9 lines
  • Missing: 0 lines
  • Coverage: 100%

@QingengWei QingengWei changed the title Webapi: add priority to Bach, Job, and run_async add priority to Bach, Job, and run_async Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant