Skip to content

Commit 5abc2ca

Browse files
authored
Merge pull request #110 from guzman-raphael/hybrid-zenoh-keyexpr
Make zenoh key expression structure easier to maintain
2 parents 74c2612 + abac26f commit 5abc2ca

File tree

20 files changed

+325
-258
lines changed

20 files changed

+325
-258
lines changed

.github/workflows/tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Install code coverage
2323
uses: taiki-e/install-action@cargo-llvm-cov
2424
- name: Run syntax and style tests
25-
run: cargo clippy --all-targets -- -D warnings
25+
run: cargo clippy --no-default-features --features=test --all-targets -- -D warnings
2626
- name: Run format test
2727
run: cargo fmt --check
2828
- name: Run integration tests w/ coverage report
@@ -31,6 +31,8 @@ jobs:
3131
run: |
3232
mkdir -p tests/.tmp
3333
cargo llvm-cov \
34+
--no-default-features \
35+
--features=test \
3436
--ignore-filename-regex "bin/.*|lib\.rs" \
3537
--cobertura \
3638
--output-path target/llvm-cov-target/cobertura.xml \

.vscode/launch.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"cargo": {
99
"args": [
1010
"test",
11+
"--no-default-features",
12+
"--features=test",
1113
"--no-run",
1214
"--package=orcapod",
1315
"--test",
@@ -31,6 +33,8 @@
3133
"cargo": {
3234
"args": [
3335
"test",
36+
"--no-default-features",
37+
"--features=test",
3438
"--no-run",
3539
"--package=orcapod",
3640
"--test",
@@ -53,6 +57,8 @@
5357
"cargo": {
5458
"args": [
5559
"test",
60+
"--no-default-features",
61+
"--features=test",
5662
"--no-run",
5763
"--lib",
5864
"--package=orcapod"
@@ -86,6 +92,8 @@
8692
"cargo": {
8793
"args": [
8894
"test",
95+
"--no-default-features",
96+
"--features=test",
8997
"--no-run",
9098
"--package=orcapod",
9199
"--bin=exe_file_stem"

.vscode/settings.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
{
2+
"[markdown]": {
3+
"editor.defaultFormatter": null
4+
},
25
"editor.formatOnPaste": false,
36
"editor.formatOnSave": true,
47
"editor.rulers": [
58
100
69
],
710
"files.autoSave": "off",
811
"files.insertFinalNewline": true,
9-
"[markdown]": {
10-
"editor.defaultFormatter": null
11-
},
1212
"gitlens.showWelcomeOnInstall": false,
1313
"gitlens.showWhatsNewAfterUpgrades": false,
1414
"lldb.consoleMode": "evaluate",
15+
"rust-analyzer.cargo.features": [
16+
"test"
17+
],
18+
"rust-analyzer.cargo.noDefaultFeatures": true,
1519
"rust-analyzer.check.command": "clippy",
1620
"rust-analyzer.runnables.extraTestBinaryArgs": [
1721
"--nocapture"
@@ -22,10 +26,10 @@
2226
],
2327
"jupyter.kernels.excludePythonEnvironments": [
2428
"/bin/python3",
25-
"/usr/bin/python3",
29+
"/usr/bin/python3"
2630
],
2731
"notebook.formatOnSave.enabled": true,
2832
"notebook.output.scrolling": true,
2933
"python.defaultInterpreterPath": "~/.local/share/base/bin/python3",
30-
"python.terminal.activateEnvironment": false,
34+
"python.terminal.activateEnvironment": false
3135
}

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ categories = [
2323
license = "MIT license"
2424
edition = "2024"
2525

26+
[features]
27+
default = []
28+
test = []
29+
2630
[lib]
2731
crate-type = ["rlib", "cdylib"]
2832

@@ -53,6 +57,8 @@ heck = "0.5.0"
5357
hex = "0.4.3"
5458
# hashmaps that preserve insertion order
5559
indexmap = { version = "2.9.0", features = ["serde"] }
60+
# utilities for iterables
61+
itertools = "0.14.0"
5662
# random name generator
5763
names = "0.14.0"
5864
# graph algorithms
@@ -106,6 +112,7 @@ restriction = "deny"
106112
style = "deny"
107113
suspicious = "deny"
108114

115+
allow_attributes = { level = "allow", priority = 127 } # Useful when suppressing warnings is also desired.
109116
arbitrary_source_item_ordering = { level = "allow", priority = 127 } # allow arbitrary ordering to keep relevant code nearby
110117
arithmetic_side_effects = { level = "allow", priority = 127 } # allow arithmetic for convenience though it could overflow
111118
as_conversions = { level = "allow", priority = 127 } # allow casting

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
```bash
1212
#!/bin/bash
1313
set -e # fail early on non-zero exit
14-
cargo clippy --all-targets -- -D warnings # Rust syntax and style tests
14+
cargo clippy --no-default-features --features=test --all-targets -- -D warnings # Rust syntax and style tests
1515
cargo fmt --check # Rust formatting test
16-
cargo llvm-cov --no-clean --ignore-filename-regex "bin/.*|lib\.rs" -- --nocapture # Rust integration tests w/ stdout coverage summary
17-
cargo llvm-cov --no-clean --ignore-filename-regex "bin/.*|lib\.rs" --html -- --nocapture # Rust integration tests w/ HTML coverage report (target/llvm-cov/html/index.html)
18-
cargo llvm-cov --no-clean --ignore-filename-regex "bin/.*|lib\.rs" --codecov --output-path target/llvm-cov-target/codecov.json -- --nocapture # Rust integration tests w/ codecov coverage report
19-
cargo llvm-cov --no-clean --ignore-filename-regex "bin/.*|lib\.rs" --cobertura --output-path target/llvm-cov-target/cobertura.xml -- --nocapture # Rust integration tests w/ cobertura coverage report
20-
. ~/.local/share/base/bin/activate && maturin develop --uv && export RUST_BACKTRACE=1 && python tests/extra/python/smoke_test.py -- tests/.tmp && python tests/extra/python/agent_test.py # Python integration tests
16+
cargo llvm-cov --no-clean --no-default-features --features=test --ignore-filename-regex "bin/.*|lib\.rs" -- --nocapture # Rust integration tests w/ stdout coverage summary
17+
cargo llvm-cov --no-clean --no-default-features --features=test --ignore-filename-regex "bin/.*|lib\.rs" --html -- --nocapture # Rust integration tests w/ HTML coverage report (target/llvm-cov/html/index.html)
18+
cargo llvm-cov --no-clean --no-default-features --features=test --ignore-filename-regex "bin/.*|lib\.rs" --codecov --output-path target/llvm-cov-target/codecov.json -- --nocapture # Rust integration tests w/ codecov coverage report
19+
cargo llvm-cov --no-clean --no-default-features --features=test --ignore-filename-regex "bin/.*|lib\.rs" --cobertura --output-path target/llvm-cov-target/cobertura.xml -- --nocapture # Rust integration tests w/ cobertura coverage report
20+
. ~/.local/share/base/bin/activate && maturin develop --uv && export RUST_BACKTRACE=1 && python tests/extra/python/smoke_test.py -- tests/.tmp && python tests/extra/python/agent_test.py -- tests/.tmp # Python integration tests
2121
```
2222

2323
## Docs
@@ -29,6 +29,15 @@ cargo modules dependencies --lib --no-uses --no-fns --focus-on "orcapod::uniffi:
2929
cargo modules dependencies --lib --no-uses --no-fns --focus-on "orcapod::uniffi::{model::{Pod,PodJob,PodResult},store::filestore::LocalFileStore,orchestrator::{PodRun,docker::LocalDockerOrchestrator}}" --layout dot | dot -T svg > docs/images/orcapod_diagram.svg # orcapod diagram as SVG
3030
```
3131

32+
## Git Worktrees
33+
34+
Update your git to at least version 2.48 since that is when the `--relative-paths` option was added to git worktree. That option makes it compatible with launching using VSCode DevContainers.
35+
36+
```bash
37+
git worktree add /path/to/new/dir-name branch-name --relative-paths # create
38+
git worktree remove dir-name # delete
39+
```
40+
3241
## Project Management
3342

3443
Progress is tracked under GH project [orcapod](https://github.com/orgs/walkerlab/projects/2).

cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
"strsim",
7979
"getrandom",
8080
"wasi",
81-
"patchelf"
81+
"patchelf",
82+
"itertools"
8283
],
8384
"useGitignore": false,
8485
"ignorePaths": [

src/core/crypto.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::{
2626
clippy::indexing_slicing,
2727
reason = "Reading less than 0 is impossible."
2828
)]
29-
pub(crate) fn hash_stream(stream: &mut impl Read) -> Result<String> {
29+
pub fn hash_stream(stream: &mut impl Read) -> Result<String> {
3030
const BUFFER_SIZE: usize = 8 << 10; // 8KB chunks to match with page size typically found
3131
let mut hash = Sha256::new();
3232

@@ -88,7 +88,7 @@ pub fn hash_dir(dirpath: impl AsRef<Path>) -> Result<String> {
8888
/// # Errors
8989
///
9090
/// Will return error if hashing fails on file or directory.
91-
pub(crate) fn hash_blob(
91+
pub fn hash_blob(
9292
namespace_lookup: &HashMap<String, PathBuf, RandomState>,
9393
blob: &Blob,
9494
) -> Result<Blob> {
@@ -102,7 +102,7 @@ pub(crate) fn hash_blob(
102102
})
103103
}
104104

105-
pub(crate) fn make_random_hash() -> String {
105+
pub fn make_random_hash() -> String {
106106
let mut bytes = [0; 32];
107107
rand::rng().fill_bytes(&mut bytes);
108108
hex::encode(bytes)

src/core/error.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,9 @@ impl fmt::Debug for OrcaError {
122122
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
123123
match &self.kind {
124124
Kind::AgentCommunicationFailure { backtrace, .. }
125-
| Kind::EmptyResponseWhenLoadingContainerAltImage { backtrace, .. }
126-
| Kind::GeneratedNamesOverflow { backtrace, .. }
127125
| Kind::IncompletePacket { backtrace, .. }
128126
| Kind::InvalidFilepath { backtrace, .. }
129-
| Kind::InvalidPodResultTerminatedDatetime { backtrace, .. }
130-
| Kind::KeyMissing { backtrace, .. }
131-
| Kind::NoAnnotationFound { backtrace, .. }
132-
| Kind::NoContainerNames { backtrace, .. }
133-
| Kind::NoFileName { backtrace, .. }
134-
| Kind::NoMatchingPodRun { backtrace, .. }
135-
| Kind::NoRemainingServices { backtrace, .. }
136-
| Kind::NoTagFoundInContainerAltImage { backtrace, .. }
127+
| Kind::MissingInfo { backtrace, .. }
137128
| Kind::BollardError { backtrace, .. }
138129
| Kind::ChronoParseError { backtrace, .. }
139130
| Kind::DOTError { backtrace, .. }

src/core/mod.rs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
1-
/// State change verification via cryptographic utilities.
2-
pub mod crypto;
1+
macro_rules! inner_attr_to_each {
2+
{ #!$attr:tt $($it:item)* } => {
3+
$(
4+
#$attr
5+
$it
6+
)*
7+
}
8+
}
9+
310
pub(crate) mod error;
411
pub(crate) mod graph;
5-
/// Components of the data model.
6-
pub mod model;
7-
pub(crate) mod orchestrator;
812
pub(crate) mod pipeline;
913
pub(crate) mod store;
1014
pub(crate) mod util;
1115
pub(crate) mod validation;
16+
17+
inner_attr_to_each! {
18+
#![cfg(feature = "default")]
19+
pub(crate) mod crypto;
20+
pub(crate) mod model;
21+
pub(crate) mod orchestrator;
22+
}
23+
24+
#[cfg(feature = "test")]
25+
inner_attr_to_each! {
26+
#![cfg_attr(
27+
feature = "test",
28+
allow(
29+
missing_docs,
30+
clippy::missing_errors_doc,
31+
clippy::missing_panics_doc,
32+
reason = "Documentation not necessary since private API.",
33+
),
34+
)]
35+
pub mod crypto;
36+
pub mod model;
37+
pub mod orchestrator;
38+
}

src/core/model.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use serde::{Deserialize as _, Deserializer, Serialize, Serializer};
1111
use serde_yaml::{self, Value};
1212
use std::{
1313
collections::{BTreeMap, HashMap},
14+
hash::BuildHasher,
1415
result,
1516
sync::Arc,
1617
};
@@ -38,8 +39,8 @@ pub fn to_yaml<T: Serialize>(instance: &T) -> Result<String> {
3839
Ok(yaml)
3940
}
4041

41-
pub(crate) fn serialize_hashmap<S, K: Ord + Serialize, V: Serialize>(
42-
map: &HashMap<K, V>,
42+
pub fn serialize_hashmap<S, K: Ord + Serialize, V: Serialize, BH: BuildHasher>(
43+
map: &HashMap<K, V, BH>,
4344
serializer: S,
4445
) -> result::Result<S::Ok, S::Error>
4546
where
@@ -49,9 +50,9 @@ where
4950
sorted.serialize(serializer)
5051
}
5152

52-
#[expect(clippy::ref_option, reason = "Serde requires this signature.")]
53-
pub(crate) fn serialize_hashmap_option<S, K: Ord + Serialize, V: Serialize>(
54-
map_option: &Option<HashMap<K, V>>,
53+
#[allow(clippy::ref_option, reason = "Serde requires this signature.")]
54+
pub fn serialize_hashmap_option<S, K: Ord + Serialize, V: Serialize, BH: BuildHasher>(
55+
map_option: &Option<HashMap<K, V, BH>>,
5556
serializer: S,
5657
) -> result::Result<S::Ok, S::Error>
5758
where
@@ -63,11 +64,8 @@ where
6364
sorted.serialize(serializer)
6465
}
6566

66-
#[expect(
67-
clippy::expect_used,
68-
reason = "Function signature required by serde API."
69-
)]
70-
pub(crate) fn deserialize_pod<'de, D>(deserializer: D) -> result::Result<Arc<Pod>, D::Error>
67+
#[expect(clippy::expect_used, reason = "Serde requires this signature.")]
68+
pub fn deserialize_pod<'de, D>(deserializer: D) -> result::Result<Arc<Pod>, D::Error>
7169
where
7270
D: Deserializer<'de>,
7371
{
@@ -89,11 +87,8 @@ where
8987
)
9088
}
9189

92-
#[expect(
93-
clippy::expect_used,
94-
reason = "Function signature required by serde API."
95-
)]
96-
pub(crate) fn deserialize_pod_job<'de, D>(deserializer: D) -> result::Result<Arc<PodJob>, D::Error>
90+
#[expect(clippy::expect_used, reason = "Serde requires this signature.")]
91+
pub fn deserialize_pod_job<'de, D>(deserializer: D) -> result::Result<Arc<PodJob>, D::Error>
9792
where
9893
D: Deserializer<'de>,
9994
{

0 commit comments

Comments
 (0)