Skip to content

Commit 02da2db

Browse files
improve module aliasing for submodules
1 parent a22d037 commit 02da2db

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
from agentlab.agents.hint_use_agent import *
2-
import warnings
3-
import sys
1+
import importlib, sys, warnings
2+
3+
OLD = __name__
4+
NEW = "agentlab.agents.hint_use_agent"
5+
SUBS = ("agent_configs", "generic_agent_prompt", "generic_agent", "tmlr_config")
46

57
warnings.warn(
6-
"generic_agent_hinter is renamed to hint_use_agent.",
8+
f"{OLD} is renamed to {NEW}. {OLD} will be removed in future",
79
DeprecationWarning,
810
stacklevel=2,
911
)
1012

11-
# Create module alias - redirect old module to new module
12-
import agentlab.agents.hint_use_agent as new_module
13-
14-
sys.modules["agentlab.agents.generic_agent_hinter"] = new_module
13+
# Alias the top-level
14+
new_mod = importlib.import_module(NEW)
15+
sys.modules[OLD] = new_mod
1516

16-
# Re-export everything from the new location
17-
from agentlab.agents.hint_use_agent import *
17+
# Alias known submodules
18+
for sub in SUBS:
19+
sys.modules[f"{OLD}.{sub}"] = importlib.import_module(f"{NEW}.{sub}")

0 commit comments

Comments
 (0)