Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions src/scitex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ def __repr__(self):
# (and submodule imports like `from scitex.<short>.<sub> import Y`) resolve to the
# external package without requiring a `src/scitex/<short>/` directory in this repo.
_EXTERNAL_REEXPORTS = {
"ai": "scitex_ai",
"ml": "scitex_ml",
"genai": "scitex_genai",
"etc": "scitex_etc",
"gists": "scitex_gists",
"audit": "scitex_audit",
Expand Down Expand Up @@ -263,23 +264,22 @@ def __repr__(self):
# Hard-missing — friendly install hint via the __getattr__ proxy below.
pass

# Deprecated module aliases. All four (`ml`, `verify`, `reproduce`, `rng`)
# are handled by tiny shim directories at `src/scitex/{ml,verify,reproduce,
# rng}/__init__.py` so:
# 1. `import scitex.<alias>` keeps working (Python finds the dir).
# 2. The DeprecationWarning fires only when the deprecated path is
# actually used (not on every `import scitex`).
# 3. We avoid eager in-tree imports here — those can trigger circular
# imports when the canonical leaf transitively reaches back into the
# umbrella (`scitex.plt`, `scitex.config`, etc.).
# See also `__getattr__` below — that catches `getattr(scitex, "ml")` too.
# Deprecated module aliases (`ai`, `verify`, `reproduce`, `rng`) are resolved
# lazily via `__getattr__` below: the DeprecationWarning fires only when the
# deprecated path is actually accessed (not on every `import scitex`), and we
# avoid eager in-tree imports that could trigger circular imports.
#
# `ai` is the legacy name for what is now split into the canonical `ml`
# (classical/deep ML — scitex_ml) and `genai` (generative-AI providers —
# scitex_genai). `scitex.ai` redirects to `scitex.ml`.


# Create lazy modules
io = _LazyModule("io")
gen = _LazyModule("gen")
plt = _LazyModule("plt")
ai = _LazyModule("ai", external="scitex_ai")
ml = _LazyModule("ml", external="scitex_ml")
genai = _LazyModule("genai", external="scitex_genai")
pd = _LazyModule("pd")
str = _LazyModule("str", external="scitex_str")
stats = _LazyModule("stats")
Expand Down Expand Up @@ -365,7 +365,7 @@ def __repr__(self):
# can be deleted. Each access emits a DeprecationWarning and returns the
# canonical lazy module.
_DEPRECATED_MODULE_ALIASES = {
"ml": "ai",
"ai": "ml",
"reproduce": "repro",
"rng": "repro",
"verify": "clew",
Expand Down Expand Up @@ -433,7 +433,8 @@ def __getattr__(name):
"io",
"gen",
"plt",
"ai",
"ml",
"genai",
"pd",
"str",
"stats",
Expand Down
3 changes: 0 additions & 3 deletions tests/custom/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ def test_is_array_like_with_scalar(self):
"scitex.ml", # Optional ML dependencies
"scitex.nn", # torch docstring compatibility issue
"scitex.session.template", # Module object not callable issue
"scitex.ai.optim.Ranger_Deep_Learning_Optimizer.setup", # noqa: E501
"scitex.ai.sk", # Deprecated/missing module
"scitex.ai.sklearn.clf", # Deprecated/missing module
}

# Module patterns to skip
Expand Down
1 change: 0 additions & 1 deletion tests/scitex/test_subset_identity_peers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
("scitex_logging", "scitex.logging"),
("scitex_datetime", "scitex.dt"),
("scitex_ml", "scitex.ml"),
("scitex_ai", "scitex.ai"),
("scitex_writer", "scitex.writer"),
("scitex_repro", "scitex.repro"),
("scitex_session", "scitex.session"),
Expand Down
Loading