Skip to content

Commit 198024e

Browse files
authored
Bindings: fix crash in python examples when NIXL_PLUGIN_DIR not set (#963)
Signed-off-by: Ovidiu Mara <[email protected]>
1 parent 2bef67e commit 198024e

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

examples/python/nixl_api_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# Allocate memory and register with NIXL
3434

3535
logger.info(
36-
"Using NIXL Plugins from:\n%s",
36+
"Using NIXL Plugins from: %s",
3737
os.environ.get("NIXL_PLUGIN_DIR", "default location"),
3838
)
3939

examples/python/nixl_gds_example.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
logger.error("Please specify file path in argv")
3535
exit(0)
3636

37-
logger.info("Using NIXL Plugins from:\n%s", os.environ["NIXL_PLUGIN_DIR"])
37+
logger.info(
38+
"Using NIXL Plugins from: %s",
39+
os.environ.get("NIXL_PLUGIN_DIR", "default location"),
40+
)
3841

3942
agent_config = nixl_agent_config(backends=[])
4043
nixl_agent1 = nixl_agent("GDSTester", agent_config)

examples/python/partial_md_example.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ def invalidate_target_metadata(
7979
)
8080
args = parser.parse_args()
8181

82-
logger.info("Using NIXL Plugins from: %s", os.environ["NIXL_PLUGIN_DIR"])
82+
logger.info(
83+
"Using NIXL Plugins from: %s",
84+
os.environ.get("NIXL_PLUGIN_DIR", "default location"),
85+
)
8386

8487
if args.etcd:
8588
etcd_endpoints = os.getenv("NIXL_ETCD_ENDPOINTS", "")

examples/python/query_mem_example.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@
5555
non_existent_file = "/tmp/nixl_example_nonexistent.txt"
5656

5757
try:
58-
logger.info("Using NIXL Plugins from: %s", os.environ["NIXL_PLUGIN_DIR"])
58+
logger.info(
59+
"Using NIXL Plugins from: %s",
60+
os.environ.get("NIXL_PLUGIN_DIR", "default location"),
61+
)
5962

6063
# Create an NIXL agent
6164
logger.info("Creating NIXL agent...")

test/python/prep_xfer_perf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ def perf_test_array(num_descs: int, addr_base: int, length: int):
139139
)
140140
args = parser.parse_args()
141141

142-
logger.info("Using NIXL Plugins from:\n%s", os.environ["NIXL_PLUGIN_DIR"])
142+
logger.info(
143+
"Using NIXL Plugins from: %s",
144+
os.environ.get("NIXL_PLUGIN_DIR", "default location"),
145+
)
143146

144147
# Example using nixl_agent_config
145148
agent = init_agent()

0 commit comments

Comments
 (0)