Skip to content

fix: Surface underlying import errors for SAM3 backend availability checks#487

Merged
giswqs merged 1 commit intomainfrom
fix/sam3-import-error-logging
Feb 6, 2026
Merged

fix: Surface underlying import errors for SAM3 backend availability checks#487
giswqs merged 1 commit intomainfrom
fix/sam3-import-error-logging

Conversation

@giswqs
Copy link
Member

@giswqs giswqs commented Feb 6, 2026

Summary

When SAM3 backend imports fail, the error messages now include the actual underlying import exception. This helps users diagnose issues like DLL conflicts, pyarrow version mismatches, or missing dependencies, rather than just seeing a generic 'pip install segment-geospatial[samgeo3]' message.

Related Issue

Addresses opengeos/geoai#519

Changes

  • Capture the actual ImportError exception when setting SAM3_META_AVAILABLE and SAM3_TRANSFORMERS_AVAILABLE flags
  • Include the underlying exception details in the error message when raising ImportError

Example

Before this change:

ImportError: Meta SAM3 is not available. Please install it as:
    pip install segment-geospatial[samgeo3]

After this change (when e.g., a DLL conflict exists):

ImportError: Meta SAM3 is not available. Please install it as:
    pip install segment-geospatial[samgeo3]

Underlying import error:
    DLL load failed while importing _lib: The specified procedure could not be found.

This makes it much easier for users to identify and resolve the root cause of import failures.

…hecks

When SAM3 backend imports fail, the error messages now include the actual
underlying import exception. This helps users diagnose issues like DLL
conflicts or missing dependencies, rather than just seeing a generic
'pip install' message.

Addresses opengeos/geoai#519
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances error reporting for SAM3 backend import failures by capturing and surfacing the underlying ImportError exceptions. When users encounter import issues (e.g., DLL conflicts, pyarrow version mismatches, or missing dependencies), they now see the actual error details instead of just generic installation instructions.

Changes:

  • Capture ImportError exceptions when checking SAM3_META and SAM3_TRANSFORMERS availability
  • Include underlying exception details in error messages raised during backend initialization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

@github-actions github-actions bot temporarily deployed to pull request February 6, 2026 01:55 Inactive
@giswqs giswqs merged commit cf5c296 into main Feb 6, 2026
16 checks passed
@giswqs giswqs deleted the fix/sam3-import-error-logging branch February 6, 2026 01:56
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.

2 participants