From fce30b2c2e6caafda41f998f9be8cb0ed781489a Mon Sep 17 00:00:00 2001 From: Matthew Scroggs Date: Tue, 24 Oct 2023 12:55:03 +0100 Subject: [PATCH] Updates for rsmpi 0.7.0 (#50) * Rename UserCommunicator -> SimpleCommunicator * use rsmpi version (#23) * Revert "use rsmpi version (#23)" This reverts commit cc5e19dcd05812145392ff9bd32f4366720a9d33. * try_ * FromRaw trait * remove unwrap() * add version consistency test * ignore pyc * fix doc build --- .github/workflows/run-tests.yml | 4 +++ .gitignore | 2 ++ _test/test_dependencies.py | 46 ++++++++++++++++++++++++++++++++ dense/Cargo.toml | 2 +- dense/src/lib.rs | 2 +- dense/src/matrix/constructors.rs | 3 +-- dense/src/traits/layout.rs | 4 +-- io/Cargo.toml | 2 +- netlib-lapack-src/lapack | 2 +- operator/Cargo.toml | 2 +- sparse/src/ghost_communicator.rs | 8 +++--- 11 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 _test/test_dependencies.py diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index c814c17f..40b6d6d2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -46,6 +46,10 @@ jobs: cargo clippy -- -D warnings cargo clippy --tests -- -D warnings cargo clippy --examples -- -D warnings + - name: Check dependency versions + run: | + python3 -m pip install pytest + python3 -m pytest _test - name: Run unit tests (debug) run: cargo test --lib --features "mpi,strict" diff --git a/.gitignore b/.gitignore index a4952d8f..fdb0d532 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ examples.sh .vscode .*.swp + +*.pyc diff --git a/_test/test_dependencies.py b/_test/test_dependencies.py new file mode 100644 index 00000000..53db960b --- /dev/null +++ b/_test/test_dependencies.py @@ -0,0 +1,46 @@ +try: + import tomllib +except ImportError: + import tomli as tomllib +import os +import pytest + + +def walk_dirs(dir, file): + out = [] + if os.path.isfile(os.path.join(dir, file)): + out.append(os.path.join(dir, file)) + for f in os.listdir(dir): + if not f.startswith(".") and os.path.isdir(os.path.join(dir, f)): + out += walk_dirs(os.path.join(dir, f), file) + return out + + +def test_dependencies(): + root_dir = os.path.join( + os.path.dirname(os.path.realpath(__file__)), "..") + if not os.path.isfile(os.path.join(root_dir, "Cargo.toml")): + pytest.skip("Test must be run from source folder") + + cargos = walk_dirs(root_dir, "Cargo.toml") + + deps = {} + errors = [] + for c in cargos: + with open(c, "rb") as f: + data = tomllib.load(f) + if "dependencies" in data: + for d, info in data["dependencies"].items(): + if isinstance(info, dict): + if "version" not in info: + info = None + else: + info = info["version"] + if d not in deps: + deps[d] = (info, c) + elif deps[d][0] != info: + errors.append( + f"Version of {d} in {c} ({info}) does not agree " + f"with version in {deps[d][1]} ({deps[d][0]})") + if len(errors) > 0: + raise ValueError("\n".join(errors)) diff --git a/dense/Cargo.toml b/dense/Cargo.toml index f1b91bce..928ec518 100644 --- a/dense/Cargo.toml +++ b/dense/Cargo.toml @@ -21,7 +21,7 @@ name = "rlst_dense" num = "0.4" cauchy = "0.4" rand = "0.8" -itertools = "0.10" +itertools = "0.11" rand_distr = "0.4" rlst-blis = { path = "../blis"} approx = { version = "0.5", features=["num-complex"] } diff --git a/dense/src/lib.rs b/dense/src/lib.rs index 1b7b2625..25853557 100644 --- a/dense/src/lib.rs +++ b/dense/src/lib.rs @@ -7,7 +7,7 @@ //! The library is early stage. The core data structures are implemented //! and functionality is continuously being added. //! -//! The core of `householder` is the [Matrix](crate::matrix::Matrix) type, +//! The core of `householder` is the [Matrix] type, //! which supports fixed size implementations, dynamic size implementations, //! and specialises also to vectors. It is agnostic to underlying storage //! layouts (i.e. row or column major) and also supports layouts with diff --git a/dense/src/matrix/constructors.rs b/dense/src/matrix/constructors.rs index 619960d1..a71e4e88 100644 --- a/dense/src/matrix/constructors.rs +++ b/dense/src/matrix/constructors.rs @@ -44,8 +44,7 @@ impl> impl MatrixD { /// Create a new matrix from another object that - /// provides [RandomAccessByValue](rlst_common::traits::RandomAccessByValue) and - /// [Shape](rlst_common::traits::Shape) traits. + /// provides [RandomAccessByValue] and [Shape] traits. pub fn from_other + Shape>(other: &Other) -> Self { let mut mat = crate::rlst_dynamic_mat![Item, other.shape()]; diff --git a/dense/src/traits/layout.rs b/dense/src/traits/layout.rs index 6b725d5c..45676b3c 100644 --- a/dense/src/traits/layout.rs +++ b/dense/src/traits/layout.rs @@ -57,8 +57,8 @@ //! are typical identical. But for more complex types (e.g. with arbitrary stride vectors) they //! are typically different from each other. //! -//! The main trait in this module is the [LayoutType](crate::traits::LayoutType) trait. -//! If this is implemented for a matrix the [Layout](crate::traits::Layout) is auto-implemented. +//! The main trait in this module is the [LayoutType] trait. +//! If this is implemented for a matrix the [Layout] is auto-implemented. //! This latter trait only provides a method to return the [LayoutType] implementation. //! This crate also provides a number of other traits. //! diff --git a/io/Cargo.toml b/io/Cargo.toml index 95f8d2be..df6f4ae8 100644 --- a/io/Cargo.toml +++ b/io/Cargo.toml @@ -22,7 +22,7 @@ num = "0.4" cauchy = "0.4" ndarray = "0.15" rand = "0.8" -itertools = "0.10" +itertools = "0.11" rand_distr = "0.4" matrixmultiply = "0.3" approx = { version = "0.5", features=["num-complex"] } diff --git a/netlib-lapack-src/lapack b/netlib-lapack-src/lapack index ae2f14fe..78666268 160000 --- a/netlib-lapack-src/lapack +++ b/netlib-lapack-src/lapack @@ -1 +1 @@ -Subproject commit ae2f14fe1f0dd94b2dacc1c35107f0ea5b5c6f07 +Subproject commit 7866626840f5d5e7e27f027a55182da8b3303872 diff --git a/operator/Cargo.toml b/operator/Cargo.toml index e22206be..fb66d801 100644 --- a/operator/Cargo.toml +++ b/operator/Cargo.toml @@ -12,7 +12,7 @@ edition = "2021" rlst-common = {path = "../common"} num = "0.4" cauchy = "0.4" -thiserror = "1" +thiserror = "1.0.40" [lib] name = "rlst_operator" diff --git a/sparse/src/ghost_communicator.rs b/sparse/src/ghost_communicator.rs index 17acf819..991d4baf 100644 --- a/sparse/src/ghost_communicator.rs +++ b/sparse/src/ghost_communicator.rs @@ -2,8 +2,8 @@ use std::os::raw::c_void; -use mpi::topology::UserCommunicator; -use mpi::traits::{AsRaw, Communicator, CommunicatorCollectives, Equivalence}; +use mpi::topology::SimpleCommunicator; +use mpi::traits::{AsRaw, Communicator, CommunicatorCollectives, Equivalence, FromRaw}; use mpi_sys; use rlst_common::types::Scalar; @@ -18,7 +18,7 @@ pub struct GhostCommunicator { pub neighborhood_receive_displacements: Vec, pub total_send_count: usize, pub total_receive_count: usize, - neighbor_comm: UserCommunicator, + neighbor_comm: SimpleCommunicator, } impl GhostCommunicator { @@ -114,7 +114,7 @@ impl GhostCommunicator { &mut raw_comm, ); - mpi::topology::UserCommunicator::from_raw(raw_comm).unwrap() + mpi::topology::SimpleCommunicator::from_raw(raw_comm) }; // We now communicate the global indices back from the receivers to the senders.