Skip to content

Commit

Permalink
# type: ignore to the 'rescue'
Browse files Browse the repository at this point in the history
  • Loading branch information
mcgov committed Oct 29, 2024
1 parent 5512d54 commit 67bb78a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
9 changes: 6 additions & 3 deletions microsoft/testsuites/dpdk/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def _uninstall(self) -> None:
if not (isinstance(self._os, Posix) and self._check_if_installed()):
return
if self._os_dependencies is not None:
for os_package_check in self._os_dependencies:
for os_package_check in self._os_dependencies.requirements:
if (
os_package_check.matcher(self._os, self._arch)
and os_package_check.packages
Expand All @@ -313,8 +313,11 @@ def _check_if_installed(self) -> bool:
# For dpdk, pkg-manager install is only for 'dpdk' and 'dpdk-dev'
# This will take too long if it's more than a few packages.
if self._os_dependencies is not None:
for os_package_check in self._os_dependencies:
if os_package_check.matcher(self._os) and os_package_check.packages:
for os_package_check in self._os_dependencies.requirements:
if (
os_package_check.matcher(self._os, self._arch)
and os_package_check.packages
):
for pkg in os_package_check.packages:
if not self._os.package_exists(pkg):
return False
Expand Down
24 changes: 13 additions & 11 deletions microsoft/testsuites/dpdk/dpdktestpmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,34 @@
# older debian kernels won't have mana_ib packaged,
# so skip the check on those kernels.
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, Debian)
matcher=lambda os, arch=None: isinstance(os, Debian) # type: ignore
and bool(os.get_kernel_information().version >= "5.15.0")
and os.is_package_in_repo("linux-modules-extra-azure"),
packages=["linux-modules-extra-azure"],
),
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, Debian),
matcher=lambda os, arch=None: isinstance(os, Debian), # type: ignore
packages=["dpdk", "dpdk-dev"],
stop_on_match=True,
),
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, Suse)
matcher=lambda os, arch=None: isinstance(os, Suse) # type: ignore
and bool(parse_version(os.information.release) == "15.5.0"),
packages=["dpdk22", "dpdk22-devel"],
stop_on_match=True,
),
OsPackageDependencies(
# alma/rocky have started
# including testpmd by default in 'dpdk'
matcher=lambda os, arch=None: isinstance(os, Fedora)
matcher=lambda os, arch=None: isinstance(os, Fedora) # type: ignore
and not os.is_package_in_repo("dpdk-devel"),
packages=["dpdk"],
stop_on_match=True,
),
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, (Fedora, Suse)),
matcher=lambda os, arch=None: isinstance( # type: ignore
os, (Fedora, Suse)
),
packages=["dpdk", "dpdk-devel"],
stop_on_match=True,
),
Expand All @@ -99,7 +101,7 @@
DPDK_SOURCE_DEPENDENCIES = DependencyInstaller(
requirements=[
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, Ubuntu)
matcher=lambda os, arch=None: isinstance(os, Ubuntu) # type: ignore
and os.information.codename == "bionic",
packages=[
"build-essential",
Expand All @@ -120,14 +122,14 @@
# older debian kernels won't have mana_ib packaged,
# so skip the check on those kernels.
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, Debian)
matcher=lambda os, arch=None: isinstance(os, Debian) # type: ignore
and bool(os.get_kernel_information().version >= "5.15.0")
and os.is_package_in_repo("linux-modules-extra-azure"),
packages=["linux-modules-extra-azure"],
),
# Install 32-bit dependencies if we're building for i386
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, Debian)
matcher=lambda os, arch=None: isinstance(os, Debian) # type: ignore
and arch == CpuArchitecture.I386,
packages=[
"python3-pyelftools",
Expand All @@ -142,7 +144,7 @@
],
),
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, Debian),
matcher=lambda os, arch=None: isinstance(os, Debian), # type: ignore
packages=[
"build-essential",
"libnuma-dev",
Expand All @@ -154,7 +156,7 @@
stop_on_match=True,
),
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, Suse),
matcher=lambda os, arch=None: isinstance(os, Suse), # type: ignore
packages=[
"psmisc",
"libnuma-devel",
Expand All @@ -165,7 +167,7 @@
stop_on_match=True,
),
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, (Fedora)),
matcher=lambda os, arch=None: isinstance(os, (Fedora)), # type: ignore
packages=[
"psmisc",
"numactl-devel",
Expand Down
20 changes: 10 additions & 10 deletions microsoft/testsuites/dpdk/rdmacore.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
RDMA_CORE_SOURCE_DEPENDENCIES = DependencyInstaller(
[
OsPackageDependencies(
matcher=lambda os, _arch=None: isinstance(os, Debian)
matcher=lambda os, _arch=None: isinstance(os, Debian) # type: ignore
# install linux-modules-extra-azure if it's available for mana_ib
# older debian kernels won't have mana_ib packaged,
# so skip the check on those kernels.
Expand All @@ -30,7 +30,7 @@
packages=["linux-modules-extra-azure"],
),
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, (Debian))
matcher=lambda os, arch=None: isinstance(os, (Debian)) # type: ignore
and arch == CpuArchitecture.I386,
packages=[
"python3-pyelftools",
Expand All @@ -53,7 +53,7 @@
],
),
OsPackageDependencies(
matcher=lambda os, arch=None: isinstance(os, (Debian))
matcher=lambda os, arch=None: isinstance(os, (Debian)) # type: ignore
and arch == CpuArchitecture.I386,
# Weirdly, I've run into errors trying to
packages=[
Expand All @@ -62,7 +62,7 @@
stop_on_match=True,
),
OsPackageDependencies(
matcher=lambda os, _arch=None: isinstance(os, Debian),
matcher=lambda os, _arch=None: isinstance(os, Debian), # type: ignore
packages=[
"cmake",
"libudev-dev",
Expand All @@ -83,7 +83,7 @@
stop_on_match=True,
),
OsPackageDependencies(
matcher=lambda os, _arch=None: isinstance(os, Fedora),
matcher=lambda os, _arch=None: isinstance(os, Fedora), # type: ignore
packages=[
"cmake",
"libudev-devel",
Expand Down Expand Up @@ -120,7 +120,7 @@
RDMA_CORE_PACKAGE_DEPENDENCIES = DependencyInstaller(
[
OsPackageDependencies(
matcher=lambda os, _=None: isinstance(os, Debian)
matcher=lambda os, _=None: isinstance(os, Debian) # type: ignore
# install linux-modules-extra-azure if it's available for mana_ib
# older debian kernels won't have mana_ib packaged,
# so skip the check on those kernels.
Expand All @@ -129,19 +129,19 @@
packages=["linux-modules-extra-azure"],
),
OsPackageDependencies(
matcher=lambda os, _=None: isinstance(os, Debian),
matcher=lambda os, _=None: isinstance(os, Debian), # type: ignore
packages=["ibverbs-providers", "libibverbs-dev"],
),
OsPackageDependencies(
matcher=lambda os, _=None: isinstance(os, Suse),
matcher=lambda os, _=None: isinstance(os, Suse), # type: ignore
packages=["rdma-core-devel", "librdmacm1"],
),
OsPackageDependencies(
matcher=lambda os, _=None: isinstance(os, Fedora),
matcher=lambda os, _=None: isinstance(os, Fedora), # type: ignore
packages=["librdmacm-devel"],
),
OsPackageDependencies(
matcher=lambda os, _=None: isinstance(os, (Fedora, Debian, Suse)),
matcher=lambda os, _=None: isinstance(os, (Fedora, Debian, Suse)), # type: ignore
packages=["rdma-core"],
stop_on_match=True,
),
Expand Down

0 comments on commit 67bb78a

Please sign in to comment.