Skip to content

Fix unguarded gudhi.tensorflow import crashing data_assimilation on plain install (#197)#198

Merged
khasawn3 merged 2 commits into
TeaspoonTDA:masterfrom
OmerJauhar:fix-197
Jun 2, 2026
Merged

Fix unguarded gudhi.tensorflow import crashing data_assimilation on plain install (#197)#198
khasawn3 merged 2 commits into
TeaspoonTDA:masterfrom
OmerJauhar:fix-197

Conversation

@OmerJauhar

Copy link
Copy Markdown
Contributor

Description

data_assimilation.py had from gudhi.tensorflow import RipsLayer at the top of the file (line 3), outside any try/except block. Since gudhi.tensorflow internally imports TensorFlow, this caused the entire module to crash on import when TensorFlow was not installed, even though TensorFlow is an optional dependency only needed by TADA.The fix moves the import inside the existing try/except block and replaces the bare except with except ImportError. Instead of raising immediately at module load time, a flag _tensorflow_available is set and checked at the start of TADA. This means:

  • rafda can be imported and used on a plain pip install teaspoon with no TensorFlow
  • Calling TADA without TensorFlow raises a clear ImportError pointing the user to pip install 'teaspoon[full]'

Motivation and Context

Closes #197. " teaspoon.DAF.data_assimilation crashes on import after plain "pip install teaspoon" => unguarded from gudhi.tensorflow import RipsLayer on line 3 defeats the developer's own tensorflow try/except #197 "

How has this been tested?

  • Confirmed from teaspoon.DAF.data_assimilation import rafda succeeds without TensorFlow installed.
  • Confirmed from teaspoon.DAF.data_assimilation import TADA succeeds without TensorFlow installed.
  • Confirmed calling TADA(...) without TensorFlow raises ImportError with the message "TADA requires TensorFlow. Install with: pip install 'teaspoon[full]'".
  • Verified via AST check that RipsLayer is no longer imported at the module top level.
  • Existing DAF test suite (tests/test_DAF.py) — 1 skipped (expected: the test correctly skips itself when TensorFlow is not available).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project. (make clean)
  • My change requires a change to the documentation.
  • All new and existing tests passed. (make tests)

@khasawn3 khasawn3 self-assigned this May 18, 2026
@stanweer1 stanweer1 requested a review from maxchumley June 1, 2026 03:37
@khasawn3 khasawn3 self-requested a review June 2, 2026 01:28
@khasawn3 khasawn3 merged commit 1bbb6f9 into TeaspoonTDA:master Jun 2, 2026
@khasawn3 khasawn3 requested review from khasawn3 and removed request for maxchumley June 2, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants