Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
84f51a2
PYPROJECT.TOML: added pylint configuration
roiedanino Jul 28, 2025
070cdde
SRC/API/PYTHON: fix pylint warnings in src, examples and tests
roiedanino Aug 3, 2025
f5c7827
EXAMPLES/PYTHON: fixed formatting
roiedanino Aug 3, 2025
f221647
EXAMPLES/PYTHON: added missing copyrights, mypy config
roiedanino Aug 4, 2025
f7ca214
PYPROJECT.TOML: True -> true
roiedanino Aug 4, 2025
88159e7
EXAMPLES/PYTHON: added blank line
roiedanino Aug 4, 2025
f3e932d
SRC/API/PYTHON: changed backends param type to Optional
roiedanino Aug 4, 2025
502dd48
SRC/API/PYTHON: formatting
roiedanino Aug 4, 2025
14015bd
.PRE-COMMIT-CONFIG.YAML: added pylint to pre-commit
roiedanino Aug 4, 2025
63d2dd4
.PRE-COMMIT-CONFIG: formatting
roiedanino Aug 4, 2025
c89f3fb
PYPROJECT.TOML: fix pylint import issues in CI
roiedanino Aug 4, 2025
ae9ec1d
.GITLAB: fixed import issue
roiedanino Aug 5, 2025
82dc3a9
PYPROJECT.TOML: reverted ignore-modules
roiedanino Aug 6, 2025
30c0e93
EXAMPLES/PYTHON: changed relative import in examples to examples.python
roiedanino Aug 6, 2025
92d4c7c
EXAMPLES/PYTHON: fixed import order
roiedanino Aug 6, 2025
8f4c735
EXAMPLES/PYTHON: fixed import order again
roiedanino Aug 6, 2025
ac1c86a
.PRE_COMMIT-CONFIG: add . to dependencies for pylint
roiedanino Aug 6, 2025
b167c98
.PRE_COMMIT-CONFIG: add source roots to dependencies for pylint
roiedanino Aug 6, 2025
c8087a0
.PRE_COMMIT-CONFIG: fix import issues in pylint - another try
roiedanino Aug 6, 2025
67d1866
.PRE-COMMIT-CONFIG: pip install before running pre-commit to recogniz…
roiedanino Aug 7, 2025
ce5b87c
.GITHUB/WORKFLOWS: trying adding nixl to the path without installing it
roiedanino Aug 7, 2025
4299b06
.GITHUB/WORKFLOWS: trying adding nixl to PYTHONPATH
roiedanino Aug 7, 2025
b8436a9
.GITLAB: add pylint checks in test_python.sh instead as nixl package …
roiedanino Aug 7, 2025
264c505
EXAMPLES/PYTHON: fixed import issues
roiedanino Aug 11, 2025
97d0d49
TEST/PYTHON: added __init__.py files to fix imports
roiedanino Aug 11, 2025
2a5f5d4
EXAMPLES/PYTHON: fixed import issues
roiedanino Aug 11, 2025
e3496ae
EXAMPLES/PYTHON: import ordering
roiedanino Aug 11, 2025
748bfce
Merge branch 'main' into pylint-ci-fixed
roiedanino Aug 11, 2025
eaaa862
EXAMPLES/PYTHON: fixed formatting
roiedanino Aug 11, 2025
99603fb
EXAMPLES/PYTHON: fixed more pylint issues from upstream
roiedanino Aug 11, 2025
76334e8
EXAMPLES/PYTHON: formatting
roiedanino Aug 11, 2025
79ea489
EXAMPLE/PYTHON: removed a blank line
roiedanino Aug 11, 2025
2f9ad2d
.GITLAB: fixed paths on pylint execution
roiedanino Aug 11, 2025
3d92223
EXAMPLES/PYTHON: supressed import issues
roiedanino Aug 20, 2025
cd89ea5
Merge branch 'main' into pylint-ci-fixed
roiedanino Aug 20, 2025
4284420
EXAMPLES/PYTHON: fixed pyling issues in telemetry_reader.py
roiedanino Aug 24, 2025
8c11154
EXAMPLES/PYTHON: more pylint fixes
roiedanino Aug 24, 2025
51da97a
EXAMPLES/PYTHON: removed unused import
roiedanino Aug 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .gitlab/test_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pip3 install --break-system-packages .
pip3 install --break-system-packages pytest
pip3 install --break-system-packages pytest-timeout
pip3 install --break-system-packages zmq
pip3 install --break-system-packages pylint

pylint src/ examples/ test/python

echo "==== Running ETCD server ===="
etcd_port=$(get_next_tcp_port)
Expand Down Expand Up @@ -82,9 +85,11 @@ python3 query_mem_example.py
export NIXL_TELEMETRY_ENABLE=1
blocking_send_recv_port=$(get_next_tcp_port)

python3 blocking_send_recv_example.py --mode="target" --ip=127.0.0.1 --port="$blocking_send_recv_port"&
python3 examples/python/blocking_send_recv_example.py --mode="target" --ip=127.0.0.1 --port="$blocking_send_recv_port"&
sleep 5
python3 blocking_send_recv_example.py --mode="initiator" --ip=127.0.0.1 --port="$blocking_send_recv_port"
python3 examples/python/blocking_send_recv_example.py --mode="initiator" --ip=127.0.0.1 --port="$blocking_send_recv_port"

python3 examples/python/query_mem_example.py

python3 telemetry_reader.py --telemetry_path /tmp/initiator &
telePID=$!
Expand Down
14 changes: 14 additions & 0 deletions examples/python/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why need to run with python -m ?

Copy link
Contributor Author

@roiedanino roiedanino Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise relative imports won't work - from . import util

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems wait_for_transfer_completion is used only in 2 place so maybe just keep it as is without introducing utilities module?

Copy link
Contributor Author

@roiedanino roiedanino Aug 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we would need to import the other module in the same way to avoid that code duplication. If you meant leaving the code duplication as it was, I don't think we want to suppress those pylint warnings.

Maybe I'll try using full path import instead

# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
18 changes: 13 additions & 5 deletions examples/python/blocking_send_recv_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
# limitations under the License.

import argparse
import enum
import sys

import torch

Expand All @@ -25,6 +27,12 @@
logger = get_logger(__name__)


class BlockingSendRecvErrCodes(enum.Enum):
MEM_REG_FAILED = 1
TRANSFER_FAILED = 2
DATA_VERIFICATION_FAILED = 3


def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, required=True)
Expand Down Expand Up @@ -66,7 +74,7 @@ def parse_args():
reg_descs = agent.register_memory(tensors)
if not reg_descs: # Same as reg_descs if successful
logger.error("Memory registration failed.")
exit()
sys.exit(BlockingSendRecvErrCodes.MEM_REG_FAILED.value)

# Target code
if args.mode == "target":
Expand Down Expand Up @@ -116,25 +124,25 @@ def parse_args():

if not xfer_handle:
logger.error("Creating transfer failed.")
exit()
sys.exit(BlockingSendRecvErrCodes.TRANSFER_FAILED.value)

state = agent.transfer(xfer_handle)
if state == "ERR":
logger.error("Posting transfer failed.")
exit()
sys.exit(BlockingSendRecvErrCodes.TRANSFER_FAILED.value)
while True:
state = agent.check_xfer_state(xfer_handle)
if state == "ERR":
logger.error("Transfer got to Error state.")
exit()
sys.exit(BlockingSendRecvErrCodes.TRANSFER_FAILED.value)
elif state == "DONE":
break

# Verify data after read
for i, tensor in enumerate(tensors):
if not torch.allclose(tensor, torch.ones(10)):
logger.error("Data verification failed for tensor %d.", i)
exit()
sys.exit(BlockingSendRecvErrCodes.DATA_VERIFICATION_FAILED.value)
logger.info("%s Data verification passed", args.mode)

if args.mode != "target":
Expand Down
40 changes: 18 additions & 22 deletions examples/python/nixl_api_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import enum
import os
import sys

import numpy as np
import torch

# pylint: disable=import-error,no-name-in-module
import nixl._utils as nixl_utils
from examples.python import util
from nixl._api import nixl_agent, nixl_agent_config
from nixl.logging import get_logger

# Configure logging
logger = get_logger(__name__)


class NixlApiExampleErrCodes(enum.Enum):
CREATE_TRANSFER_FAILED = 1
PREP_TRANSFER_SIDE_HANDLES_FAILED = 2
MAKE_PREPPED_TRANSFER_FAILED = 3
TRANSFER_FAILED = 4


if __name__ == "__main__":
buf_size = 256
# Allocate memory and register with NIXL
Expand Down Expand Up @@ -113,30 +124,15 @@
)
if not xfer_handle_1:
logger.error("Creating transfer failed.")
exit()
sys.exit(NixlApiExampleErrCodes.CREATE_TRANSFER_FAILED.value)

# test multiple postings
for _ in range(2):
state = nixl_agent2.transfer(xfer_handle_1)
assert state != "ERR"

target_done = False
init_done = False

while (not init_done) or (not target_done):
if not init_done:
state = nixl_agent2.check_xfer_state(xfer_handle_1)
if state == "ERR":
logger.error("Transfer got to Error state.")
exit()
elif state == "DONE":
init_done = True
logger.info("Initiator done")

if not target_done:
if nixl_agent1.check_remote_xfer_done("initiator", b"UUID1"):
target_done = True
logger.info("Target done")
util.wait_for_transfer_completion(
nixl_agent2, nixl_agent1, xfer_handle_1, b"UUID1"
)

# prep transfer mode
local_prep_handle = nixl_agent2.prep_xfer_dlist(
Expand Down Expand Up @@ -173,11 +169,11 @@
)
if not local_prep_handle or not remote_prep_handle:
logger.error("Preparing transfer side handles failed.")
exit()
sys.exit(NixlApiExampleErrCodes.PREP_TRANSFER_SIDE_HANDLES_FAILED.value)

if not xfer_handle_2:
logger.error("Make prepped transfer failed.")
exit()
sys.exit(NixlApiExampleErrCodes.MAKE_PREPPED_TRANSFER_FAILED.value)

state = nixl_agent2.transfer(xfer_handle_2)
assert state != "ERR"
Expand All @@ -192,7 +188,7 @@
state = nixl_agent2.check_xfer_state(xfer_handle_2)
if state == "ERR":
logger.error("Transfer got to Error state.")
exit()
sys.exit(NixlApiExampleErrCodes.TRANSFER_FAILED.value)
elif state == "DONE":
init_done = True
logger.info("Initiator done")
Expand Down
19 changes: 14 additions & 5 deletions examples/python/nixl_gds_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import enum
import os
import sys

Expand All @@ -26,13 +27,21 @@
logger = get_logger(__name__)


class NixlGdsExampleErrCodes(enum.Enum):
MISSING_FILE_PATH = 1
CREATE_TRANSFER_FAILED = 2
TRANSFER_FAILED = 3
INIT_XFER_FAILED = 4
DATA_VERIFICATION_FAILED = 5


if __name__ == "__main__":
buf_size = 16 * 4096
# Allocate memory and register with NIXL

if len(sys.argv) < 2:
logger.error("Please specify file path in argv")
exit(0)
sys.exit(NixlGdsExampleErrCodes.MISSING_FILE_PATH.value)

logger.info("Using NIXL Plugins from:\n%s", os.environ["NIXL_PLUGIN_DIR"])

Expand Down Expand Up @@ -86,7 +95,7 @@
)
if not xfer_handle_1:
logger.error("Creating transfer failed.")
exit()
sys.exit(NixlGdsExampleErrCodes.CREATE_TRANSFER_FAILED.value)

state = nixl_agent1.transfer(xfer_handle_1)
assert state != "ERR"
Expand All @@ -97,7 +106,7 @@
state = nixl_agent1.check_xfer_state(xfer_handle_1)
if state == "ERR":
logger.error("Transfer got to Error state.")
exit()
sys.exit(NixlGdsExampleErrCodes.TRANSFER_FAILED.value)
elif state == "DONE":
done = True
logger.info("Initiator done")
Expand All @@ -108,7 +117,7 @@
)
if not xfer_handle_2:
logger.error("Creating transfer failed.")
exit()
sys.exit(NixlGdsExampleErrCodes.INIT_XFER_FAILED.value)

state = nixl_agent1.transfer(xfer_handle_2)
assert state != "ERR"
Expand All @@ -119,7 +128,7 @@
state = nixl_agent1.check_xfer_state(xfer_handle_2)
if state == "ERR":
logger.error("Transfer got to Error state.")
exit()
sys.exit(NixlGdsExampleErrCodes.TRANSFER_FAILED.value)
elif state == "DONE":
done = True
logger.info("Initiator done")
Expand Down
Loading
Loading