Skip to content

Conversation

@daquinteroflex
Copy link
Collaborator

@daquinteroflex daquinteroflex commented Oct 22, 2025

Greptile Overview

Updated On: 2025-10-22 15:12:38 UTC

Greptile Summary

This PR fixes error message handling in the Component Modeler preprocessing workflow within tidy3d/web/api/webapi.py. The changes correct a critical bug where error details were being retrieved from the wrong field (message instead of result) when split job preprocessing fails. The error messages are enhanced to include status information (e.g., "failed", "error") for improved debugging context. Additionally, a console log message is updated to use lowercase capitalization, aligning with the codebase's established logging conventions. These changes ensure that users receive accurate and informative error messages when Component Modeler preprocessing encounters issues, improving the overall debugging experience for the web API component of Tidy3D.

Important Files Changed

Changed Files
Filename Score Overview
tidy3d/web/api/webapi.py 5/5 Fixed error message retrieval field from message to result, added status information to error messages, and corrected console log capitalization

Confidence score: 5/5

  • This PR is safe to merge with minimal risk
  • Score reflects a straightforward bug fix with clear improvements to error handling, no complex logic changes, and consistent application across both verbose and non-verbose code paths
  • No files require special attention

Sequence Diagram

sequenceDiagram
    participant User
    participant upload
    participant SimulationTask
    participant _upload_component_modeler_subtasks
    participant http
    participant Server
    participant _batch_detail_error
    participant BatchTask

    User->>upload: "upload(simulation, task_name, ...)"
    upload->>SimulationTask: "create(task_type='RF', ...)"
    SimulationTask->>Server: "POST create task"
    Server-->>SimulationTask: "task with batch_id"
    SimulationTask-->>upload: "task object"
    
    upload->>_upload_component_modeler_subtasks: "resource_id, verbose, solver_version"
    
    _upload_component_modeler_subtasks->>http: "POST tidy3d/async-biz/component-modeler-split"
    http-->>_upload_component_modeler_subtasks: "AsyncJobDetail"
    
    loop Poll split job status
        _upload_component_modeler_subtasks->>http: "GET monitor_split_path"
        http-->>_upload_component_modeler_subtasks: "AsyncJobDetail with progress"
    end
    
    alt Split job succeeds
        _upload_component_modeler_subtasks->>BatchTask: "check(solver_version, batch_type='RF_SWEEP')"
        BatchTask->>Server: "POST validation request"
        
        loop Poll validation status
            _upload_component_modeler_subtasks->>BatchTask: "detail(batch_type='RF_SWEEP')"
            BatchTask->>Server: "GET batch details"
            Server-->>BatchTask: "BatchDetail"
            BatchTask-->>_upload_component_modeler_subtasks: "BatchDetail"
        end
        
        alt Validation fails
            _upload_component_modeler_subtasks->>_batch_detail_error: "resource_id"
            _batch_detail_error->>BatchTask: "detail(batch_type='RF_SWEEP')"
            BatchTask->>Server: "GET batch details"
            Server-->>BatchTask: "BatchDetail with validateErrors"
            BatchTask-->>_batch_detail_error: "BatchDetail"
            
            loop Parse validation errors
                _batch_detail_error->>_batch_detail_error: "json.loads(error_str)"
                _batch_detail_error->>_batch_detail_error: "extract validation_error"
            end
            
            _batch_detail_error-->>_upload_component_modeler_subtasks: "WebError with details"
            _upload_component_modeler_subtasks-->>upload: "WebError"
            upload-->>User: "raise WebError"
        else Validation succeeds
            _upload_component_modeler_subtasks-->>upload: "None (success)"
        end
    else Split job fails
        _upload_component_modeler_subtasks-->>upload: "WebError"
        upload-->>User: "raise WebError"
    end
    
    upload->>upload: "estimate_cost(resource_id, ...)"
    upload-->>User: "return resource_id"
Loading

Context used:

  • Rule from dashboard - Use single quotes around class names like 'WavePort' in error messages and warnings. Use double back... (source)

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.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@daquinteroflex daquinteroflex changed the title fix(rf): error message of preprocess modeler fix(rf, FXC-3797): error message of preprocess modeler Oct 22, 2025
Copy link
Contributor

@dmarek-flex dmarek-flex left a comment

Choose a reason for hiding this comment

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

Changelog?

@daquinteroflex daquinteroflex added this pull request to the merge queue Oct 22, 2025
@daquinteroflex
Copy link
Collaborator Author

daquinteroflex commented Oct 22, 2025

Probably doesn't require it as it's already in the previous async item, users haven't interacted with this

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 22, 2025
@daquinteroflex daquinteroflex force-pushed the dario/fix_cm_pre_workflow branch from cd2fb9c to 02b9f15 Compare October 23, 2025 15:02
@github-actions
Copy link
Contributor

Diff Coverage

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

  • tidy3d/web/api/webapi.py (0.0%): Missing lines 201,237-238,283-284

Summary

  • Total: 5 lines
  • Missing: 5 lines
  • Coverage: 0%

tidy3d/web/api/webapi.py

Lines 197-205

  197         "protocolVersion": _get_protocol_version(),
  198     }
  199 
  200     if verbose:
! 201         console.log("Starting modeler and subtasks validation...")
  202 
  203     initial_resp = http.post(split_path, payload)
  204     split_job_detail = AsyncJobDetail(**initial_resp)
  205     monitor_split_path = f"{split_path}?asyncId={split_job_detail.asyncId}"

Lines 233-242

  233                     break
  234                 time.sleep(RUN_REFRESH_TIME)
  235 
  236             if split_job_detail.status in ERROR_STATES:
! 237                 msg = split_job_detail.result or "An unknown error occurred."
! 238                 final_error = WebError(
  239                     f"Component modeler split job failed ({split_job_detail.status}): {msg}"
  240                 )
  241 
  242             if not final_error:

Lines 279-288

  279             time.sleep(RUN_REFRESH_TIME)
  280 
  281         # Check for split job failure.
  282         if split_job_detail.status in ERROR_STATES:
! 283             msg = split_job_detail.result or "An unknown error occurred."
! 284             final_error = WebError(
  285                 f"Component modeler split job failed ({split_job_detail.status}): {msg}"
  286             )
  287 
  288         # If split succeeded, poll for validation completion.

@daquinteroflex daquinteroflex added this pull request to the merge queue Oct 23, 2025
Merged via the queue into develop with commit 7d63ace Oct 23, 2025
25 checks passed
@daquinteroflex daquinteroflex deleted the dario/fix_cm_pre_workflow branch October 23, 2025 16:11
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.

3 participants