Skip to content

Commit

Permalink
Xfail networkx test; also, no verbose test for now
Browse files Browse the repository at this point in the history
  • Loading branch information
eriknw committed Nov 8, 2024
1 parent b442bc5 commit 09d876b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
16 changes: 11 additions & 5 deletions _nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,16 @@ def update_env_var(varname):
return d


def _check_networkx_version() -> tuple[int, int]:
def _check_networkx_version() -> tuple[int, int] | tuple[int, int, int]:
"""Check the version of networkx and return ``(major, minor)`` version tuple."""
import re
import warnings

import networkx as nx

version_major, version_minor = nx.__version__.split(".")[:2]
version_major, version_minor, *version_bug = nx.__version__.split(".")[:3]
if has_bug := bool(version_bug):
version_bug = version_bug[0]
if version_major != "3":
warnings.warn(
f"nx-cugraph version {__version__} is only known to work with networkx "
Expand All @@ -363,15 +365,19 @@ def _check_networkx_version() -> tuple[int, int]:
# Allow single-digit minor versions, e.g. 3.4 and release candidates, e.g. 3.4rc0
pattern = r"^\d(rc\d+)?$"

if not re.match(pattern, version_minor):
if not re.match(pattern, version_bug if has_bug else version_minor):
raise RuntimeWarning(
f"nx-cugraph version {__version__} does not work with networkx version "
f"{nx.__version__}. Please upgrade (or fix) your Python environment."
)

nxver_major = int(version_major)
nxver_minor = int(re.match(r"^\d+", version_minor).group())
return (nxver_major, nxver_minor)
if not has_bug:
nxver_minor = int(re.match(r"^\d+", version_minor).group())
return (nxver_major, nxver_minor)
nxver_minor = int(version_minor)
nxver_bug = int(re.match(r"^\d+", version_bug).group())
return (nxver_major, nxver_minor, nxver_bug)


if __name__ == "__main__":
Expand Down
1 change: 0 additions & 1 deletion ci/test_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ set +e

rapids-logger "pytest nx-cugraph"
./ci/run_nx_cugraph_pytests.sh \
--verbose \
--junitxml="${RAPIDS_TESTS_DIR}/junit-nx-cugraph.xml" \
--cov=nx_cugraph \
--cov-report=xml:"${RAPIDS_COVERAGE_DIR}/nx-cugraph-coverage.xml" \
Expand Down
2 changes: 1 addition & 1 deletion nx_cugraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from _nx_cugraph._version import __git_commit__, __version__
from _nx_cugraph import _check_networkx_version

_nxver: tuple[int, int] = _check_networkx_version()
_nxver: tuple[int, int] | tuple[int, int, int] = _check_networkx_version()

from . import utils

Expand Down
3 changes: 3 additions & 0 deletions nx_cugraph/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@ def key(testpath):
}
)

if _nxver == (3, 4, 2):
xfail[key("test_pylab.py:test_return_types")] = "Ephemeral NetworkX bug"

too_slow = "Too slow to run"
skip = {
key("test_tree_isomorphism.py:test_positive"): too_slow,
Expand Down

0 comments on commit 09d876b

Please sign in to comment.