Skip to content

Commit

Permalink
feat!: split JS package into separate crates (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
sd2k authored Nov 8, 2024
1 parent 7ecd929 commit 9e28cc7
Show file tree
Hide file tree
Showing 48 changed files with 680 additions and 427 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
- uses: actions/setup-node@v4
- name: Install dependencies
run: npm ci
working-directory: crates/augurs-js/testpkg
working-directory: js/testpkg
- name: Run typecheck
run: npm run typecheck
working-directory: crates/augurs-js/testpkg
working-directory: js/testpkg
- name: Run tests
run: npm run test:ci
working-directory: crates/augurs-js/testpkg
working-directory: js/testpkg
13 changes: 13 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
members = [
"crates/*",
"examples/*",
"js/*",
]
exclude = [
# These aren't crates, they're Javascript packages in an inconvenient location.
"js/augurs",
"js/testpkg",
]
resolver = "2"

Expand Down Expand Up @@ -35,21 +41,28 @@ augurs-prophet = { version = "0.5.3", path = "crates/augurs-prophet" }
augurs-seasons = { version = "0.5.3", path = "crates/augurs-seasons" }
augurs-testing = { path = "crates/augurs-testing" }

augurs-core-js = { path = "js/augurs-core-js" }

anyhow = "1.0.89"
bytemuck = "1.18.0"
chrono = "0.4.38"
distrs = "0.2.1"
getrandom = { version = "0.2.10", features = ["js"] }
itertools = "0.13.0"
js-sys = "0.3.64"
num-traits = "0.2.19"
rand = "0.8.5"
roots = "0.0.8"
serde = { version = "1.0.166", features = ["derive"] }
statrs = "0.17.1"
serde_json = "1.0.128"
serde-wasm-bindgen = "0.6.0"
thiserror = "1.0.40"
tinyvec = "1.6.0"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", default-features = false }
tsify-next = { version = "0.5.3", default-features = false, features = ["js"] }
wasm-bindgen = "=0.2.93"

assert_approx_eq = "1.1.0"
criterion = "0.5.1"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ APIs are subject to change, and functionality may not be fully implemented.
| [`augurs-prophet`][] | The Prophet time series forecasting algorithm | alpha |
| [`augurs-seasons`][] | Seasonality detection using periodograms | alpha - working and tested against Python in limited scenarios |
| [`augurs-testing`][] | Testing data and, eventually, evaluation harness for implementations | alpha - just data right now |
| [`augurs-js`][] | WASM bindings to augurs | alpha |
| [`js/*`][js-libs] | WASM bindings to augurs | alpha |
| [`pyaugurs`][] | Python bindings to augurs | alpha |

## Developing
Expand Down Expand Up @@ -79,11 +79,11 @@ Licensed under the Apache License, Version 2.0 `<http://www.apache.org/licenses/
[`augurs-dtw`]: https://crates.io/crates/augurs-dtw
[`augurs-ets`]: https://crates.io/crates/augurs-ets
[`augurs-mstl`]: https://crates.io/crates/augurs-mstl
[`augurs-js`]: https://crates.io/crates/augurs-js
[`augurs-outlier`]: https://crates.io/crates/augurs-outlier
[`augurs-prophet`]: https://crates.io/crates/augurs-prophet
[`augurs-seasons`]: https://crates.io/crates/augurs-seasons
[`augurs-testing`]: https://crates.io/crates/augurs-testing
[js-libs]: https://github.com/grafana/augurs/tree/main/js
[`pyaugurs`]: https://crates.io/crates/pyaugurs
[`just`]: https://just.systems/man/en/
[`bacon`]: https://dystroy.org/bacon
2 changes: 1 addition & 1 deletion bacon.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ analyzer = "nextest"
command = [
"cargo", "test", "--doc", "--color", "always",
"--all-features", "--workspace",
"--exclude", "augurs-js",
"--exclude", "*-js",
"--exclude", "pyaugurs",
]
need_stdout = true
Expand Down
5 changes: 5 additions & 0 deletions crates/augurs-dtw/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- define lints in Cargo.toml instead of each crate's lib.rs ([#138](https://github.com/grafana/augurs/pull/138))

## [0.5.0](https://github.com/grafana/augurs/compare/augurs-dtw-v0.5.0...augurs-dtw-v0.4.3) - 2024-10-18

No changes to the Rust crate; this version bump is due to breaking changes in the
Javascript package.

## [0.4.0](https://github.com/grafana/augurs/compare/augurs-dtw-v0.3.1...augurs-dtw-v0.4.0) - 2024-10-16

### Added
Expand Down
8 changes: 0 additions & 8 deletions crates/augurs-js/.cargo/config.toml

This file was deleted.

24 changes: 0 additions & 24 deletions crates/augurs-js/CHANGELOG.md

This file was deleted.

1 change: 0 additions & 1 deletion crates/augurs-js/LICENSE-APACHE

This file was deleted.

1 change: 0 additions & 1 deletion crates/augurs-js/LICENSE-MIT

This file was deleted.

65 changes: 0 additions & 65 deletions crates/augurs-js/README.md

This file was deleted.

46 changes: 0 additions & 46 deletions crates/augurs-js/prepublish.js

This file was deleted.

8 changes: 0 additions & 8 deletions crates/augurs-js/rust-toolchain.toml

This file was deleted.

33 changes: 33 additions & 0 deletions js/augurs-changepoint-js/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "augurs-changepoint-js"
version.workspace = true
authors.workspace = true
documentation.workspace = true
repository.workspace = true
license.workspace = true
edition.workspace = true
keywords.workspace = true
description = "JavaScript bindings for the augurs-changepoint library."
publish = false

[lib]
bench = false
crate-type = ["cdylib", "rlib"]
doc = false
doctest = false
test = false

[dependencies]
augurs-core-js.workspace = true
augurs-changepoint = { workspace = true, features = ["serde"] }
getrandom = { version = "0.2.10", features = ["js"] }
js-sys = "0.3.64"
serde.workspace = true
serde-wasm-bindgen = "0.6.0"
tracing.workspace = true
tsify-next = { version = "0.5.3", default-features = false, features = ["js"] }
wasm-bindgen.workspace = true

[package.metadata.wasm-pack.profile.release]
# previously had just ['-O4']
wasm-opt = ['-O4', '--enable-bulk-memory', '--enable-threads']
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use wasm_bindgen::prelude::*;
use augurs_changepoint::{
dist, ArgpcpDetector, BocpdDetector, DefaultArgpcpDetector, Detector, NormalGammaDetector,
};

use crate::VecF64;
use augurs_core_js::VecF64;

#[derive(Debug)]
enum EitherDetector {
Expand Down Expand Up @@ -49,6 +48,7 @@ const DEFAULT_HAZARD_LAMBDA: f64 = 250.0;
#[wasm_bindgen]
impl ChangepointDetector {
#[wasm_bindgen(constructor)]
#[allow(non_snake_case)]
pub fn new(detectorType: ChangepointDetectorType) -> Result<ChangepointDetector, JsValue> {
match detectorType {
ChangepointDetectorType::NormalGamma => Self::normal_gamma(None),
Expand Down
36 changes: 36 additions & 0 deletions js/augurs-clustering-js/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
name = "augurs-clustering-js"
version.workspace = true
authors.workspace = true
documentation.workspace = true
repository.workspace = true
license.workspace = true
edition.workspace = true
keywords.workspace = true
description = "JavaScript bindings for the augurs-clustering library."
publish = false

[lib]
bench = false
crate-type = ["cdylib", "rlib"]
doc = false
doctest = false
test = false

[dependencies]
augurs-core-js.workspace = true
augurs-clustering.workspace = true
getrandom.workspace = true
js-sys.workspace = true
serde.workspace = true
serde-wasm-bindgen.workspace = true
tracing.workspace = true
tsify-next.workspace = true
wasm-bindgen.workspace = true

[package.metadata.wasm-pack.profile.release]
# previously had just ['-O4']
wasm-opt = ['-O4', '--enable-bulk-memory', '--enable-threads']

[lints]
workspace = true
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::Deserialize;
use tsify_next::Tsify;
use wasm_bindgen::prelude::*;

use crate::dtw::DistanceMatrix;
use augurs_core_js::{DistanceMatrix, VecVecF64};

/// Options for the dynamic time warping calculation.
#[derive(Clone, Debug, Default, Deserialize, Tsify)]
Expand Down Expand Up @@ -43,7 +43,8 @@ impl DbscanClusterer {
///
/// The return value is an `Int32Array` of cluster IDs, with `-1` indicating noise.
#[wasm_bindgen]
pub fn fit(&self, distanceMatrix: &DistanceMatrix) -> Vec<isize> {
self.inner.fit(distanceMatrix.inner())
#[allow(non_snake_case)]
pub fn fit(&self, distanceMatrix: VecVecF64) -> Result<Vec<isize>, JsError> {
Ok(self.inner.fit(&DistanceMatrix::new(distanceMatrix)?.into()))
}
}
Loading

0 comments on commit 9e28cc7

Please sign in to comment.