Skip to content

Commit 2074691

Browse files
mpiannucciclaude
andcommitted
Clean up project structure and documentation
- Fill in README TODOs with comprehensive feature descriptions and usage examples - Move GitHub Actions CI configuration to repository root with workspace support - Update CI pipeline for proper core library and WASM package testing - Add cross-platform testing on Ubuntu, Windows, and macOS - Configure dependabot for workspace-aware dependency updates - Remove legacy Travis CI and AppVeyor configurations from subdirectory 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4accf42 commit 2074691

File tree

6 files changed

+199
-44
lines changed

6 files changed

+199
-44
lines changed
File renamed without changes.

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "08:00"
8+
open-pull-requests-limit: 10
9+
- package-ecosystem: cargo
10+
directory: "/readap"
11+
schedule:
12+
interval: daily
13+
time: "08:00"
14+
open-pull-requests-limit: 10
15+
- package-ecosystem: cargo
16+
directory: "/readap-wasm"
17+
schedule:
18+
interval: daily
19+
time: "08:00"
20+
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,103 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main, master ]
5+
branches: [ main, wasmm ]
66
pull_request:
7-
branches: [ main, master ]
7+
branches: [ main ]
88

99
env:
1010
CARGO_TERM_COLOR: always
1111

1212
jobs:
13-
test:
14-
name: Test
13+
test-core:
14+
name: Test Core Library
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
rust:
19-
- stable
20-
- beta
21-
- nightly
18+
rust: [stable, beta]
2219
steps:
2320
- uses: actions/checkout@v4
24-
- name: Install Rust
25-
uses: dtolnay/rust-toolchain@master
21+
- uses: dtolnay/rust-toolchain@master
2622
with:
2723
toolchain: ${{ matrix.rust }}
28-
- name: Cache cargo registry
29-
uses: actions/cache@v3
24+
- uses: Swatinem/rust-cache@v2
3025
with:
31-
path: ~/.cargo/registry
32-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
33-
- name: Cache cargo index
34-
uses: actions/cache@v3
26+
workspaces: readap
27+
- name: Run core library tests
28+
run: cargo test --manifest-path readap/Cargo.toml --verbose
29+
30+
test-wasm:
31+
name: Test WASM Package
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: dtolnay/rust-toolchain@stable
3536
with:
36-
path: ~/.cargo/git
37-
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
38-
- name: Cache cargo build
39-
uses: actions/cache@v3
37+
targets: wasm32-unknown-unknown
38+
- uses: Swatinem/rust-cache@v2
39+
with:
40+
workspaces: readap-wasm
41+
- name: Install wasm-pack
42+
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
43+
- name: Build WASM package
44+
run: wasm-pack build readap-wasm --target web
45+
- name: Test WASM package in headless browsers
46+
run: wasm-pack test readap-wasm --headless --chrome --firefox
47+
48+
test-workspace:
49+
name: Test Workspace
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
- uses: dtolnay/rust-toolchain@stable
54+
with:
55+
targets: wasm32-unknown-unknown
56+
- uses: Swatinem/rust-cache@v2
57+
- name: Check workspace
58+
run: cargo check --workspace
59+
- name: Test workspace
60+
run: cargo test --workspace --verbose
61+
62+
cross-platform:
63+
name: Cross Platform
64+
strategy:
65+
matrix:
66+
os: [ubuntu-latest, windows-latest, macos-latest]
67+
runs-on: ${{ matrix.os }}
68+
steps:
69+
- uses: actions/checkout@v4
70+
- uses: dtolnay/rust-toolchain@stable
4071
with:
41-
path: target
42-
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
43-
- name: Run tests
44-
run: cargo test --verbose
72+
targets: wasm32-unknown-unknown
73+
- uses: Swatinem/rust-cache@v2
74+
- name: Check core library
75+
run: cargo check --manifest-path readap/Cargo.toml
76+
- name: Check WASM target
77+
run: cargo check --manifest-path readap-wasm/Cargo.toml --target wasm32-unknown-unknown
78+
- name: Test core library
79+
run: cargo test --manifest-path readap/Cargo.toml
4580

4681
clippy:
4782
name: Clippy
4883
runs-on: ubuntu-latest
4984
steps:
5085
- uses: actions/checkout@v4
51-
- name: Install Rust
52-
uses: dtolnay/rust-toolchain@stable
86+
- uses: dtolnay/rust-toolchain@stable
5387
with:
5488
components: clippy
55-
- name: Run clippy
56-
run: cargo clippy -- -D warnings
89+
targets: wasm32-unknown-unknown
90+
- uses: Swatinem/rust-cache@v2
91+
- name: Run clippy on workspace
92+
run: cargo clippy --workspace -- -D warnings
93+
- name: Run clippy on WASM target
94+
run: cargo clippy --manifest-path readap-wasm/Cargo.toml --target wasm32-unknown-unknown -- -D warnings
5795

5896
fmt:
5997
name: Rustfmt
6098
runs-on: ubuntu-latest
6199
steps:
62100
- uses: actions/checkout@v4
63-
- name: Install Rust
64-
uses: dtolnay/rust-toolchain@stable
101+
- uses: dtolnay/rust-toolchain@stable
65102
with:
66103
components: rustfmt
67104
- name: Check formatting
File renamed without changes.

readap-wasm/.github/dependabot.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

readap-wasm/README.md

Lines changed: 112 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,122 @@ wasm-pack publish
5353

5454
## Usage
5555

56-
Once the WASM bindings are implemented, you'll be able to parse OpenDAP data in JavaScript:
56+
### Basic Setup
5757

58-
**TODO**
58+
```typescript
59+
import init, { OpenDAPDataset } from '@readap-wasm/readap-wasm';
60+
61+
async function main() {
62+
await init(); // Initialize WASM module
63+
64+
// Load dataset with automatic metadata fetching
65+
const dataset = await OpenDAPDataset.fromURL('http://example.com/ocean.nc');
66+
67+
// Check available variables
68+
console.log('Variables:', dataset.getVariableNames());
69+
70+
// Get simple variable data
71+
const tempData = await dataset.getVariable('temperature');
72+
console.log('Temperature:', tempData.data); // Float64Array or appropriate typed array
73+
}
74+
```
75+
76+
### Advanced Data Selection
77+
78+
```typescript
79+
// Index-based selection (isel) - select by array indices
80+
const indexSelection = dataset.isel({
81+
time: 0, // first time step
82+
lat: [10, 20], // latitude indices 10-20
83+
lon: 50 // longitude index 50
84+
});
85+
86+
// Value-based selection (sel) - select by coordinate values with nearest neighbor
87+
await dataset.loadCoordinates('time'); // Load coordinates for value lookup
88+
await dataset.loadCoordinates('lat');
89+
await dataset.loadCoordinates('lon');
90+
91+
const valueSelection = dataset.sel({
92+
time: "2023-01-15T12:00:00Z", // nearest time
93+
lat: [40.0, 45.0], // latitude range 40-45°N
94+
lon: -70.0 // nearest to -70°W
95+
});
96+
97+
// Get data with selection applied
98+
const selectedData = await dataset.getVariable('temperature', valueSelection);
99+
100+
// Chain selections for complex queries
101+
const surface = dataset
102+
.sel({ depth: 0 }) // surface level
103+
.isel({ time: [0, 1, 2] }) // first 3 time steps
104+
.sel({ lat: [35, 45], lon: [-80, -60] }); // geographic subset
105+
```
106+
107+
### Multiple Variables and Batch Operations
108+
109+
```typescript
110+
// Get multiple variables efficiently
111+
const oceanData = await dataset.getVariables(['temperature', 'salinity', 'velocity']);
112+
113+
// Access individual variable data
114+
console.log('Temperature data:', oceanData.temperature.data);
115+
console.log('Salinity data:', oceanData.salinity.data);
116+
```
117+
118+
### Low-Level API Usage
119+
120+
```typescript
121+
// Manual URL building
122+
const urlBuilder = new OpenDAPUrlBuilder("http://example.com/data");
123+
console.log(urlBuilder.dasUrl()); // http://example.com/data.das
124+
console.log(urlBuilder.ddsUrl()); // http://example.com/data.dds
125+
126+
// Direct constraint building
127+
const constraints = new ConstraintBuilder()
128+
.isel({ time: { type: "single", value: 0 } })
129+
.sel({ lat: { type: "range", min: 40.0, max: 50.0 } });
130+
131+
const dodsUrl = urlBuilder.dodsUrl(constraints.build());
132+
133+
// Parse formats directly
134+
const dasResult = OpenDAPDataset.fromDAS(dasText);
135+
const ddsResult = OpenDAPDataset.fromDDS(ddsText);
136+
```
59137

60138
## Features
61139

62-
**TODO**
63-
* Full WebAssembly compatibility for browser and Node.js environments
64-
* Built with [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen) for seamless JavaScript integration
65-
* Includes [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook) for better debugging
140+
### 🚀 **High-Level API**
141+
* **Automatic Data Fetching**: Seamless HTTP requests with built-in error handling
142+
* **xarray-style Selection**: Intuitive `isel` (index) and `sel` (value) selection patterns
143+
* **Nearest Neighbor Lookup**: Automatic coordinate value → index mapping with binary search
144+
* **Lazy Loading**: Coordinates and metadata loaded only when needed for optimal performance
145+
* **Typed Arrays**: Efficient JavaScript typed arrays (Float64Array, Int32Array, etc.) for zero-copy data transfer
146+
147+
### 🔧 **Low-Level Control**
148+
* **URL Builder System**: Programmatically construct OpenDAP URLs with constraints
149+
* **Direct Format Parsing**: Parse DAS, DDS, and DODS formats independently
150+
* **Constraint Building**: Flexible constraint syntax for complex data selections
151+
* **Network-Free Core**: Underlying readap library works without network dependencies
152+
153+
### 📊 **Data Selection Capabilities**
154+
* **Index-based Selection (isel)**: Select data by array indices with ranges and multiple values
155+
* **Value-based Selection (sel)**: Select data by coordinate values with nearest neighbor matching
156+
* **Chained Selections**: Combine multiple selection operations for complex queries
157+
* **Range Support**: Efficient range selections for time series and spatial data
158+
* **Gridded Coordinates**: Intuitive handling of multi-dimensional coordinate systems
159+
160+
### 🌐 **Web Compatibility**
161+
* **Full WebAssembly compatibility** for browser and Node.js environments
162+
* **CORS Support**: Proper handling of cross-origin requests
163+
* **Built with [`wasm-bindgen`](https://github.com/rustwasm/wasm-bindgen)** for seamless JavaScript integration
164+
* **Error Handling**: Comprehensive HTTP and parsing error handling with meaningful messages
165+
* **Includes [`console_error_panic_hook`](https://github.com/rustwasm/console_error_panic_hook)** for better debugging
166+
167+
### **Performance Features**
168+
* **Zero-copy data transfer** between WASM and JavaScript where possible
169+
* **Efficient binary search** algorithms for coordinate lookup
170+
* **Minimal network requests** through intelligent constraint building
171+
* **Smart coordinate caching** to avoid redundant data fetching
66172

67173
## License
68174

0 commit comments

Comments
 (0)