Skip to content

Commit 5f86800

Browse files
committed
Try lazy loading; consolidate pylintrc and pyproject
1 parent 9fcc31d commit 5f86800

File tree

4 files changed

+69
-34
lines changed

4 files changed

+69
-34
lines changed

.pylintrc

Lines changed: 0 additions & 25 deletions
This file was deleted.

manify/__init__.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,24 @@
22
import manify.embedders
33
import manify.manifolds
44
import manify.predictors
5-
import manify.utils
5+
6+
# Dynamically check for utils dependencies
7+
try:
8+
import importlib.util
9+
10+
_utils_deps = ["networkx", "pandas", "matplotlib", "scipy", "anndata", "basemap"]
11+
_missing_deps = [dep for dep in _utils_deps if importlib.util.find_spec(dep) is None]
12+
13+
if not _missing_deps:
14+
import manify.utils
15+
16+
HAS_UTILS = True
17+
else:
18+
HAS_UTILS = False
19+
except ImportError:
20+
HAS_UTILS = False
21+
22+
# Expose flag for users to check
23+
__all__ = ["curvature_estimation", "embedders", "manifolds", "predictors"]
24+
if HAS_UTILS:
25+
__all__.append("utils")

manify/utils/__init__.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1-
import manify.utils.benchmarks
2-
import manify.utils.dataloaders
3-
import manify.utils.link_prediction
4-
import manify.utils.preprocessing
5-
import manify.utils.visualization
1+
# Lazy loading variant of utils imports - changed to this so that missing imports would be non-breaking for core manify
2+
3+
4+
def __getattr__(name):
5+
if name == "benchmarks":
6+
import manify.utils.benchmarks
7+
8+
return manify.utils.benchmarks
9+
elif name == "dataloaders":
10+
import manify.utils.dataloaders
11+
12+
return manify.utils.dataloaders
13+
elif name == "link_prediction":
14+
import manify.utils.link_prediction
15+
16+
return manify.utils.link_prediction
17+
elif name == "preprocessing":
18+
import manify.utils.preprocessing
19+
20+
return manify.utils.preprocessing
21+
elif name == "visualization":
22+
import manify.utils.visualization
23+
24+
return manify.utils.visualization
25+
else:
26+
raise AttributeError(f"module 'manify.utils' has no attribute '{name}'")

pyproject.toml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ dependencies = [
1717
"tqdm",
1818
"cvxpy",
1919
"scikit-learn==1.5.1",
20-
"jaxtyping"
2120
]
2221

23-
[pyproject.optional_dependencies]
22+
[project.optional-dependencies]
2423
dev = [
2524
"jaxtyping",
2625
]
@@ -36,11 +35,31 @@ utils = [
3635
[tool.setuptools]
3736
packages = ["manify"]
3837

38+
# Pylint configuration
39+
[tool.pylint.master]
40+
init-hook = "import sys; sys.path.append('.')"
41+
fail-under = 8.0
42+
ignore = "__pycache__,.git,venv"
43+
44+
[tool.pylint.reports]
45+
output-format = "colorized"
46+
3947
[tool.pylint.format]
4048
max-line-length = 120
4149

4250
[tool.pylint."MESSAGES CONTROL"]
4351
disable = ["invalid-name"]
4452

53+
[tool.pylint.basic]
54+
good-names = "i,j,k,ex,Run,_,fp"
55+
argument-rgx = "[a-z_][a-z0-9_]{2,30}$"
56+
variable-rgx = "[a-z_][a-z0-9_]{2,30}$"
57+
class-rgx = "[A-Z][a-zA-Z0-9]+$"
58+
const-rgx = "(([A-Z_][A-Z0-9_]*)|(__.*__))"
59+
module-rgx = "([a-z_][a-z0-9_]*)"
60+
61+
[tool.pylint.typecheck]
62+
generated-members = "torch.*,nn.*"
63+
4564
[tool.pytest.ini_options]
46-
adopts = "--jaxtyping-packages=beartype.beartype"
65+
adopts = "--jaxtyping-packages=beartype.beartype"

0 commit comments

Comments
 (0)