Skip to content

Commit

Permalink
Merge branch 'main' into py-convert-from-v1-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jetuk committed Aug 6, 2024
2 parents b218272 + 01bf34e commit c128831
Show file tree
Hide file tree
Showing 27 changed files with 516 additions and 119 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/deploy-book.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Deploy book
on:
# Deploy the book when the Rust (Linux) workflow completes on main
workflow_run:
workflows: ["Rust (Linux)"]
branches: [main]
workflows: [ "Rust (Linux)" ]
branches: [ main ]
types:
- completed

Expand All @@ -18,6 +18,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: swatinem/rust-cache@v2
- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: swatinem/rust-cache@v2
- name: Run Clippy
run: cargo clippy --all-targets --features highs,cbc
run: cargo clippy --all-targets --features highs,cbc --all --exclude ipm-simd
- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
Expand All @@ -44,6 +45,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: swatinem/rust-cache@v2
- name: Build
run: cargo build --verbose --no-default-features --package [email protected]
- name: Run tests
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: swatinem/rust-cache@v2
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
Expand Down Expand Up @@ -98,6 +99,7 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: swatinem/rust-cache@v2
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ env:
CARGO_TERM_COLOR: always
# Make sure CI fails on all warnings, including Clippy lints
RUSTFLAGS: "-Dwarnings"
ACTIONS_RUNNER_DEBUG: true
ACTIONS_STEP_DEBUG: true

jobs:
build:
Expand All @@ -19,9 +21,12 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- uses: swatinem/rust-cache@v2
- name: Run Clippy
run: cargo clippy --all-targets --features highs,cbc
- name: Build
run: cargo build --verbose --features highs,cbc
- name: Run tests
run: cargo test --features highs,cbc
# Only test the library and binaries, not the docs
# There were some issues with the docs tests timing out on Windows CI
run: cargo test --features highs,cbc --verbose --lib --bins -- --test-threads=1
23 changes: 6 additions & 17 deletions ipm-ocl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,14 @@ where
let row_offsets = ocl::Buffer::<u32>::builder()
.queue(queue.clone())
.flags(ocl::flags::MEM_READ_WRITE)
.copy_host_slice(
a.row_offsets()
.into_iter()
.map(|r| *r as u32)
.collect::<Vec<_>>()
.as_slice(),
)
.copy_host_slice(a.row_offsets().iter().map(|r| *r as u32).collect::<Vec<_>>().as_slice())
.len(a.row_offsets().len())
.build()?;

let col_indices = ocl::Buffer::<u32>::builder()
.queue(queue.clone())
.flags(ocl::flags::MEM_READ_WRITE)
.copy_host_slice(
a.col_indices()
.into_iter()
.map(|r| *r as u32)
.collect::<Vec<_>>()
.as_slice(),
)
.copy_host_slice(a.col_indices().iter().map(|r| *r as u32).collect::<Vec<_>>().as_slice())
.len(a.col_indices().len())
.build()?;

Expand Down Expand Up @@ -439,6 +427,7 @@ impl<T> PathFollowingDirectClSolver<T>
where
T: ocl::OclPrm + GetClProgram,
{
#[allow(clippy::too_many_arguments)]
pub fn from_data(
queue: &ocl::Queue,
program: &ocl::Program,
Expand All @@ -456,7 +445,7 @@ where
let buffers = PathFollowingDirectClBuffers::from_data(&a, num_lps, queue)?;

let kernel_normal_init = ocl::Kernel::builder()
.program(&program)
.program(program)
.name("normal_eqn_init")
.queue(queue.clone())
.global_work_size(num_lps)
Expand All @@ -470,7 +459,7 @@ where
.build()?;

let kernel_normal_eq_step = ocl::Kernel::builder()
.program(&program)
.program(program)
.name("normal_eqn_step")
.queue(queue.clone())
.global_work_size(num_lps)
Expand Down Expand Up @@ -619,6 +608,6 @@ mod tests {
let queue = ocl::Queue::new(&context, device, None).unwrap();

let a = test_matrx();
let pf = PathFollowingDirectClBuffers::from_data(&a, 10, &queue).unwrap();
let _pf = PathFollowingDirectClBuffers::from_data(&a, 10, &queue).unwrap();
}
}
41 changes: 21 additions & 20 deletions pywr-book/src/building_documentation.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Contributing to Documentation

The documentation for Pywr V2 is located in the pywr-next repository, [here](https://github.com/pywr/pywr-next) in the `pywr-book` subfolder.
The documentation for Pywr V2 is located in the pywr-next repository, [here](https://github.com/pywr/pywr-next) in the
`pywr-book` subfolder.

The documentation is written using 'markdown', a format which enables easy formatting for the web.
The documentation is written using 'markdown', a format which enables easy formatting for the web.

This website can help get started: [www.markdownguide.org](https://www.markdownguide.org)

To contribute documentation for Pywr V2, we recommend following the steps below to ensure we can review and integrate any changes as easily as possible.
To contribute documentation for Pywr V2, we recommend following the steps below to ensure we can review and integrate
any changes as easily as possible.

## Steps to create documentation

Expand All @@ -16,19 +18,19 @@ To contribute documentation for Pywr V2, we recommend following the steps below

2. Clone the fork

``` <bash>
```bash
git clone https://github.com/MYUSER/pywr-next
```

3. Create a branch

``` <bash>
```bash
git checkout -b my-awesome-docs
```

4. Open the book documentation in your favourite editor

``` <bash>
```bash
vi pywr-next/pywr-book/introduction.md
```

Expand All @@ -38,27 +40,26 @@ Which should look something like this:

5. Having modified the documentation, add and commit the changes <ins>using the commit format<ins>

```<bash>
```bash
git add introduction.md"
```
```<bash>
```bash
git commit -m "docs: Add an example documentation"
```
6. Create a pull request from your branch
1. In your fork, click on the 'Pull Requests' tab
![Pull request](./images/making_documentation/pr1.png "Pull Request")
6. Create a pull request from your branch
1. In your fork, click on the 'Pull Requests' tab
![Pull request](./images/making_documentation/pr1.png "Pull Request")
2. Click on 'New Pull Request'
![Pull request](./images/making_documentation/pr2.png "Pull Request")
2. Click on 'New Pull Request'
![Pull request](./images/making_documentation/pr2.png "Pull Request")
3. Choose your branch from the drop-down on the right-hand-side
![Pull request](./images/making_documentation/pr3.png "Pull Request")
3. Choose your branch from the drop-down on the right-hand-side
![Pull request](./images/making_documentation/pr3.png "Pull Request")
4. Click 'Create Pull Request' when the button appears
![Pull request](./images/making_documentation/pr4.png "Pull Request")

5. Add a note if you want, and click 'Create Pull Request'
![Pull request](./images/making_documentation/pr5.png "Pull Request")
4. Click 'Create Pull Request' when the button appears
![Pull request](./images/making_documentation/pr4.png "Pull Request")
5. Add a note if you want, and click 'Create Pull Request'
![Pull request](./images/making_documentation/pr5.png "Pull Request")
6 changes: 6 additions & 0 deletions pywr-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ schemars = { workspace = true }

pywr-core = { path = "../pywr-core" }
pywr-schema = { path = "../pywr-schema" }

[features]
cbc = ["pywr-core/cbc", "pywr-schema/cbc"]
highs = ["pywr-core/highs", "pywr-schema/highs"]
ipm-ocl = ["pywr-core/ipm-ocl", "pywr-schema/ipm-ocl"]
ipm-simd = ["pywr-core/ipm-simd", "pywr-schema/ipm-simd"]
10 changes: 5 additions & 5 deletions pywr-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use std::path::{Path, PathBuf};
enum Solver {
Clp,
#[cfg(feature = "highs")]
HIGHS,
Highs,
#[cfg(feature = "ipm-ocl")]
CLIPMF32,
#[cfg(feature = "ipm-ocl")]
Expand All @@ -38,7 +38,7 @@ impl Display for Solver {
match self {
Solver::Clp => write!(f, "clp"),
#[cfg(feature = "highs")]
Solver::HIGHS => write!(f, "highs"),
Solver::Highs => write!(f, "highs"),
#[cfg(feature = "ipm-ocl")]
Solver::CLIPMF32 => write!(f, "clipmf32"),
#[cfg(feature = "ipm-ocl")]
Expand Down Expand Up @@ -265,7 +265,7 @@ fn run(path: &Path, solver: &Solver, data_path: Option<&Path>, output_path: Opti
match *solver {
Solver::Clp => model.run::<ClpSolver>(&ClpSolverSettings::default()),
#[cfg(feature = "highs")]
Solver::HIGHS => model.run::<HighsSolver>(&HighsSolverSettings::default()),
Solver::Highs => model.run::<HighsSolver>(&HighsSolverSettings::default()),
#[cfg(feature = "ipm-ocl")]
Solver::CLIPMF32 => model.run_multi_scenario::<ClIpmF32Solver>(&ClIpmSolverSettings::default()),
#[cfg(feature = "ipm-ocl")]
Expand All @@ -287,7 +287,7 @@ fn run_multi(path: &Path, solver: &Solver, data_path: Option<&Path>, output_path
match *solver {
Solver::Clp => model.run::<ClpSolver>(&ClpSolverSettings::default()),
#[cfg(feature = "highs")]
Solver::HIGHS => model.run::<HighsSolver>(&HighsSolverSettings::default()),
Solver::Highs => model.run::<HighsSolver>(&HighsSolverSettings::default()),
#[cfg(feature = "ipm-ocl")]
Solver::CLIPMF32 => model.run_multi_scenario::<ClIpmF32Solver>(&ClIpmSolverSettings::default()),
#[cfg(feature = "ipm-ocl")]
Expand All @@ -305,7 +305,7 @@ fn run_random(num_systems: usize, density: usize, num_scenarios: usize, solver:
match *solver {
Solver::Clp => model.run::<ClpSolver>(&ClpSolverSettings::default()),
#[cfg(feature = "highs")]
Solver::HIGHS => model.run::<HighsSolver>(&HighsSolverSettings::default()),
Solver::Highs => model.run::<HighsSolver>(&HighsSolverSettings::default()),
#[cfg(feature = "ipm-ocl")]
Solver::CLIPMF32 => model.run_multi_scenario::<ClIpmF32Solver>(&ClIpmSolverSettings::default()),
#[cfg(feature = "ipm-ocl")]
Expand Down
Loading

0 comments on commit c128831

Please sign in to comment.