Skip to content

Commit b5a807a

Browse files
committed
fixing the bug so that now the model will be auto-dumped after its attribute is being queried
1 parent 892d736 commit b5a807a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

stemflow/lazyloading/lazyloading.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ def __getattr__(self, name):
9191
# Try autoloading and then delegate
9292
if name.startswith("__"): # avoid dunder recursion
9393
raise AttributeError(name)
94-
with self._lock:
95-
if self.estimator is None and self.auto_load:
96-
self._load_inplace()
97-
if self.estimator is not None and hasattr(self.estimator, name):
98-
return getattr(self.estimator, name)
99-
# Fallback to default behavior
100-
raise AttributeError(f"{type(self).__name__} has no attribute '{name}'")
10194

95+
if self.estimator is None and not self.auto_load:
96+
raise AttributeError(f"Trying to get a attribute of estimator, but the estimator can not be auto-loaded from the disk because auto_load=False.")
97+
98+
with self._loaded_estimator() as est:
99+
if hasattr(est, name):
100+
return getattr(est, name)
101+
else:
102+
raise AttributeError(f"{type(est).__name__} has no attribute '{name}'")
103+
102104
# ---------- Persistence helpers ----------
103105
def _resolve_path(self) -> Path:
104106
if self.dump_dir is None:
@@ -144,6 +146,7 @@ def dump(self) -> Path:
144146
tmp_dir.rmdir()
145147
except Exception:
146148
pass
149+
147150
return path
148151

149152

0 commit comments

Comments
 (0)