Skip to content

Commit 8aa990c

Browse files
authored
SmartSim environment variables updated using new naming convention (#666)
Updates SmartSim environment variable names with the new naming convention. [ committed by @AlyssaCote ] [ approved by @ashao ]
1 parent 128598b commit 8aa990c

File tree

9 files changed

+50
-40
lines changed

9 files changed

+50
-40
lines changed

doc/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Jump to:
1313

1414
Description
1515

16+
- Update SmartSim environment variables using new naming convention
1617
- Refactor `exception_handler`
1718
- Add RequestDispatcher and the possibility of batching inference requests
1819
- Enable hostname selection for dragon tasks

smartsim/_core/_cli/build.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,22 @@ def check_py_tf_version(versions: Versioner) -> None:
7878
def check_backends_install() -> bool:
7979
"""Checks if backends have already been installed.
8080
Logs details on how to proceed forward
81-
if the RAI_PATH environment variable is set or if
81+
if the SMARTSIM_RAI_LIB environment variable is set or if
8282
backends have already been installed.
8383
"""
84-
rai_path = os.environ.get("RAI_PATH", "")
84+
rai_path = os.environ.get("SMARTSIM_RAI_LIB", "")
8585
installed = installed_redisai_backends()
8686
msg = ""
8787

8888
if rai_path and installed:
8989
msg = (
9090
f"There is no need to build. backends are already built and "
91-
f"specified in the environment at 'RAI_PATH': {CONFIG.redisai}"
91+
f"specified in the environment at 'SMARTSIM_RAI_LIB': {CONFIG.redisai}"
9292
)
9393
elif rai_path and not installed:
9494
msg = (
95-
"Before running 'smart build', unset your RAI_PATH environment "
96-
"variable with 'unset RAI_PATH'."
95+
"Before running 'smart build', unset your SMARTSIM_RAI_LIB environment "
96+
"variable with 'unset SMARTSIM_RAI_LIB'."
9797
)
9898
elif not rai_path and installed:
9999
msg = (
@@ -368,7 +368,7 @@ def _configure_keydb_build(versions: Versioner) -> None:
368368
CONFIG.conf_path = Path(CONFIG.core_path, "config", "keydb.conf")
369369
if not CONFIG.conf_path.resolve().is_file():
370370
raise SSConfigError(
371-
"Database configuration file at REDIS_CONF could not be found"
371+
"Database configuration file at SMARTSIM_REDIS_CONF could not be found"
372372
)
373373

374374

smartsim/_core/_install/builder.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,15 +342,19 @@ def build_from_git(
342342
bin_path = Path(dependency_path, "bin").resolve()
343343
try:
344344
database_exe = next(bin_path.glob("*-server"))
345-
database = Path(os.environ.get("REDIS_PATH", database_exe)).resolve()
345+
database = Path(
346+
os.environ.get("SMARTSIM_REDIS_SERVER_EXE", database_exe)
347+
).resolve()
346348
_ = expand_exe_path(str(database))
347349
except (TypeError, FileNotFoundError) as e:
348350
raise BuildError("Installation of redis-server failed!") from e
349351

350352
# validate install -- redis-cli
351353
try:
352354
redis_cli_exe = next(bin_path.glob("*-cli"))
353-
redis_cli = Path(os.environ.get("REDIS_CLI_PATH", redis_cli_exe)).resolve()
355+
redis_cli = Path(
356+
os.environ.get("SMARTSIM_REDIS_CLI_EXE", redis_cli_exe)
357+
).resolve()
354358
_ = expand_exe_path(str(redis_cli))
355359
except (TypeError, FileNotFoundError) as e:
356360
raise BuildError("Installation of redis-cli failed!") from e

smartsim/_core/config/config.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@
4040
# These values can be set through environment variables to
4141
# override the default behavior of SmartSim.
4242
#
43-
# RAI_PATH
43+
# SMARTSIM_RAI_LIB
4444
# - Path to the RAI shared library
4545
# - Default: /smartsim/smartsim/_core/lib/redisai.so
4646
#
47-
# REDIS_CONF
47+
# SMARTSIM_REDIS_CONF
4848
# - Path to the redis.conf file
4949
# - Default: /SmartSim/smartsim/_core/config/redis.conf
5050
#
51-
# REDIS_PATH
51+
# SMARTSIM_REDIS_SERVER_EXE
5252
# - Path to the redis-server executable
5353
# - Default: /SmartSim/smartsim/_core/bin/redis-server
5454
#
55-
# REDIS_CLI_PATH
55+
# SMARTSIM_REDIS_CLI_EXE
5656
# - Path to the redis-cli executable
5757
# - Default: /SmartSim/smartsim/_core/bin/redis-cli
5858
#
@@ -105,45 +105,50 @@ def __init__(self) -> None:
105105
@property
106106
def redisai(self) -> str:
107107
rai_path = self.lib_path / "redisai.so"
108-
redisai = Path(os.environ.get("RAI_PATH", rai_path)).resolve()
108+
redisai = Path(os.environ.get("SMARTSIM_RAI_LIB", rai_path)).resolve()
109109
if not redisai.is_file():
110110
raise SSConfigError(
111111
"RedisAI dependency not found. Build with `smart` cli "
112-
"or specify RAI_PATH"
112+
"or specify SMARTSIM_RAI_LIB"
113113
)
114114
return str(redisai)
115115

116116
@property
117117
def database_conf(self) -> str:
118-
conf = Path(os.environ.get("REDIS_CONF", self.conf_path)).resolve()
118+
conf = Path(os.environ.get("SMARTSIM_REDIS_CONF", self.conf_path)).resolve()
119119
if not conf.is_file():
120120
raise SSConfigError(
121-
"Database configuration file at REDIS_CONF could not be found"
121+
"Database configuration file at SMARTSIM_REDIS_CONF could not be found"
122122
)
123123
return str(conf)
124124

125125
@property
126126
def database_exe(self) -> str:
127127
try:
128128
database_exe = next(self.bin_path.glob("*-server"))
129-
database = Path(os.environ.get("REDIS_PATH", database_exe)).resolve()
129+
database = Path(
130+
os.environ.get("SMARTSIM_REDIS_SERVER_EXE", database_exe)
131+
).resolve()
130132
exe = expand_exe_path(str(database))
131133
return exe
132134
except (TypeError, FileNotFoundError) as e:
133135
raise SSConfigError(
134-
"Specified database binary at REDIS_PATH could not be used"
136+
"Specified database binary at SMARTSIM_REDIS_SERVER_EXE "
137+
"could not be used"
135138
) from e
136139

137140
@property
138141
def database_cli(self) -> str:
139142
try:
140143
redis_cli_exe = next(self.bin_path.glob("*-cli"))
141-
redis_cli = Path(os.environ.get("REDIS_CLI_PATH", redis_cli_exe)).resolve()
144+
redis_cli = Path(
145+
os.environ.get("SMARTSIM_REDIS_CLI_EXE", redis_cli_exe)
146+
).resolve()
142147
exe = expand_exe_path(str(redis_cli))
143148
return exe
144149
except (TypeError, FileNotFoundError) as e:
145150
raise SSConfigError(
146-
"Specified Redis binary at REDIS_CLI_PATH could not be used"
151+
"Specified Redis binary at SMARTSIM_REDIS_CLI_EXE could not be used"
147152
) from e
148153

149154
@property
@@ -163,7 +168,7 @@ def dragon_dotenv(self) -> Path:
163168
def dragon_server_path(self) -> t.Optional[str]:
164169
return os.getenv(
165170
"SMARTSIM_DRAGON_SERVER_PATH",
166-
os.getenv("SMARTSIM_DRAGON_SERVER_PATH_EXP", None),
171+
os.getenv("_SMARTSIM_DRAGON_SERVER_PATH_EXP", None),
167172
)
168173

169174
@property

smartsim/_core/utils/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def _installed(base_path: Path, backend: str) -> bool:
221221
"""
222222
backend_key = f"redisai_{backend}"
223223
backend_path = base_path / backend_key / f"{backend_key}.so"
224-
backend_so = Path(os.environ.get("RAI_PATH", backend_path)).resolve()
224+
backend_so = Path(os.environ.get("SMARTSIM_RAI_LIB", backend_path)).resolve()
225225

226226
return backend_so.is_file()
227227

smartsim/database/orchestrator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ def __init__(
265265
raise SSConfigError(
266266
"SmartSim not installed with pre-built extensions (Redis)\n"
267267
"Use the `smart` cli tool to install needed extensions\n"
268-
"or set REDIS_PATH and REDIS_CLI_PATH in your environment\n"
269-
"See documentation for more information"
268+
"or set SMARTSIM_REDIS_SERVER_EXE and SMARTSIM_REDIS_CLI_EXE "
269+
"in your environment\nSee documentation for more information"
270270
) from e
271271

272272
if self.launcher != "local":

smartsim/experiment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def __init__(
178178
def _set_dragon_server_path(self) -> None:
179179
"""Set path for dragon server through environment varialbes"""
180180
if not "SMARTSIM_DRAGON_SERVER_PATH" in environ:
181-
environ["SMARTSIM_DRAGON_SERVER_PATH_EXP"] = osp.join(
181+
environ["_SMARTSIM_DRAGON_SERVER_PATH_EXP"] = osp.join(
182182
self.exp_path, CONFIG.dragon_default_subdir
183183
)
184184

tests/on_wlm/test_dragon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_dragon_global_path(global_dragon_teardown, wlmutils, test_dir, monkeypa
5656

5757
def test_dragon_exp_path(global_dragon_teardown, wlmutils, test_dir, monkeypatch):
5858
monkeypatch.delenv("SMARTSIM_DRAGON_SERVER_PATH", raising=False)
59-
monkeypatch.delenv("SMARTSIM_DRAGON_SERVER_PATH_EXP", raising=False)
59+
monkeypatch.delenv("_SMARTSIM_DRAGON_SERVER_PATH_EXP", raising=False)
6060
exp: Experiment = Experiment(
6161
"test_dragon_connection",
6262
exp_path=test_dir,

tests/test_config.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def get_redisai_env(
6666
"""
6767
env = os.environ.copy()
6868
if rai_path is not None:
69-
env["RAI_PATH"] = rai_path
69+
env["SMARTSIM_RAI_LIB"] = rai_path
7070
else:
71-
env.pop("RAI_PATH", None)
71+
env.pop("SMARTSIM_RAI_LIB", None)
7272

7373
if lib_path is not None:
7474
env["SMARTSIM_DEP_INSTALL_PATH"] = lib_path
@@ -85,7 +85,7 @@ def make_file(filepath: str) -> None:
8585

8686

8787
def test_redisai_invalid_rai_path(test_dir, monkeypatch):
88-
"""An invalid RAI_PATH and valid SMARTSIM_DEP_INSTALL_PATH should fail"""
88+
"""An invalid SMARTSIM_RAI_LIB and valid SMARTSIM_DEP_INSTALL_PATH should fail"""
8989

9090
rai_file_path = os.path.join(test_dir, "lib", "mock-redisai.so")
9191
make_file(os.path.join(test_dir, "lib", "redisai.so"))
@@ -94,15 +94,15 @@ def test_redisai_invalid_rai_path(test_dir, monkeypatch):
9494

9595
config = Config()
9696

97-
# Fail when no file exists @ RAI_PATH
97+
# Fail when no file exists @ SMARTSIM_RAI_LIB
9898
with pytest.raises(SSConfigError) as ex:
9999
_ = config.redisai
100100

101101
assert "RedisAI dependency not found" in ex.value.args[0]
102102

103103

104104
def test_redisai_valid_rai_path(test_dir, monkeypatch):
105-
"""A valid RAI_PATH should override valid SMARTSIM_DEP_INSTALL_PATH and succeed"""
105+
"""A valid SMARTSIM_RAI_LIB should override valid SMARTSIM_DEP_INSTALL_PATH and succeed"""
106106

107107
rai_file_path = os.path.join(test_dir, "lib", "mock-redisai.so")
108108
make_file(rai_file_path)
@@ -117,7 +117,7 @@ def test_redisai_valid_rai_path(test_dir, monkeypatch):
117117

118118

119119
def test_redisai_invalid_lib_path(test_dir, monkeypatch):
120-
"""Invalid RAI_PATH and invalid SMARTSIM_DEP_INSTALL_PATH should fail"""
120+
"""Invalid SMARTSIM_RAI_LIB and invalid SMARTSIM_DEP_INSTALL_PATH should fail"""
121121

122122
rai_file_path = f"{test_dir}/railib/redisai.so"
123123

@@ -133,7 +133,7 @@ def test_redisai_invalid_lib_path(test_dir, monkeypatch):
133133

134134

135135
def test_redisai_valid_lib_path(test_dir, monkeypatch):
136-
"""Valid RAI_PATH and invalid SMARTSIM_DEP_INSTALL_PATH should succeed"""
136+
"""Valid SMARTSIM_RAI_LIB and invalid SMARTSIM_DEP_INSTALL_PATH should succeed"""
137137

138138
rai_file_path = os.path.join(test_dir, "lib", "mock-redisai.so")
139139
make_file(rai_file_path)
@@ -147,7 +147,7 @@ def test_redisai_valid_lib_path(test_dir, monkeypatch):
147147

148148

149149
def test_redisai_valid_lib_path_null_rai(test_dir, monkeypatch):
150-
"""Missing RAI_PATH and valid SMARTSIM_DEP_INSTALL_PATH should succeed"""
150+
"""Missing SMARTSIM_RAI_LIB and valid SMARTSIM_DEP_INSTALL_PATH should succeed"""
151151

152152
rai_file_path: t.Optional[str] = None
153153
lib_file_path = os.path.join(test_dir, "lib", "redisai.so")
@@ -166,35 +166,35 @@ def test_redis_conf():
166166
assert Path(config.database_conf).is_file()
167167
assert isinstance(config.database_conf, str)
168168

169-
os.environ["REDIS_CONF"] = "not/a/path"
169+
os.environ["SMARTSIM_REDIS_CONF"] = "not/a/path"
170170
config = Config()
171171
with pytest.raises(SSConfigError):
172172
config.database_conf
173-
os.environ.pop("REDIS_CONF")
173+
os.environ.pop("SMARTSIM_REDIS_CONF")
174174

175175

176176
def test_redis_exe():
177177
config = Config()
178178
assert Path(config.database_exe).is_file()
179179
assert isinstance(config.database_exe, str)
180180

181-
os.environ["REDIS_PATH"] = "not/a/path"
181+
os.environ["SMARTSIM_REDIS_SERVER_EXE"] = "not/a/path"
182182
config = Config()
183183
with pytest.raises(SSConfigError):
184184
config.database_exe
185-
os.environ.pop("REDIS_PATH")
185+
os.environ.pop("SMARTSIM_REDIS_SERVER_EXE")
186186

187187

188188
def test_redis_cli():
189189
config = Config()
190190
assert Path(config.redisai).is_file()
191191
assert isinstance(config.redisai, str)
192192

193-
os.environ["REDIS_CLI_PATH"] = "not/a/path"
193+
os.environ["SMARTSIM_REDIS_CLI_EXE"] = "not/a/path"
194194
config = Config()
195195
with pytest.raises(SSConfigError):
196196
config.database_cli
197-
os.environ.pop("REDIS_CLI_PATH")
197+
os.environ.pop("SMARTSIM_REDIS_CLI_EXE")
198198

199199

200200
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)