diff --git a/src/scitex/__init__.py b/src/scitex/__init__.py index 08d5e6b26..497e608f5 100755 --- a/src/scitex/__init__.py +++ b/src/scitex/__init__.py @@ -206,7 +206,8 @@ def __repr__(self): # (and submodule imports like `from scitex.. import Y`) resolve to the # external package without requiring a `src/scitex//` directory in this repo. _EXTERNAL_REEXPORTS = { - "ai": "scitex_ai", + "ml": "scitex_ml", + "genai": "scitex_genai", "etc": "scitex_etc", "gists": "scitex_gists", "audit": "scitex_audit", @@ -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.` 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") @@ -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", @@ -433,7 +433,8 @@ def __getattr__(name): "io", "gen", "plt", - "ai", + "ml", + "genai", "pd", "str", "stats", diff --git a/tests/custom/test_imports.py b/tests/custom/test_imports.py index cbf53c79f..9cb8ece6d 100755 --- a/tests/custom/test_imports.py +++ b/tests/custom/test_imports.py @@ -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 diff --git a/tests/scitex/test_subset_identity_peers.py b/tests/scitex/test_subset_identity_peers.py index b494c127e..e275d6aff 100755 --- a/tests/scitex/test_subset_identity_peers.py +++ b/tests/scitex/test_subset_identity_peers.py @@ -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"),