Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install code coverage
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run syntax and style tests
run: cargo clippy --all-targets -- -D warnings
run: cargo clippy --no-default-features --features=test --all-targets -- -D warnings
- name: Run format test
run: cargo fmt --check
- name: Run integration tests w/ coverage report
Expand All @@ -31,6 +31,8 @@ jobs:
run: |
mkdir -p tests/.tmp
cargo llvm-cov \
--no-default-features \
--features=test \
--ignore-filename-regex "bin/.*|lib\.rs" \
--cobertura \
--output-path target/llvm-cov-target/cobertura.xml \
Expand Down
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"cargo": {
"args": [
"test",
"--no-default-features",
"--features=test",
"--no-run",
"--package=orcapod",
"--test",
Expand All @@ -31,6 +33,8 @@
"cargo": {
"args": [
"test",
"--no-default-features",
"--features=test",
"--no-run",
"--package=orcapod",
"--test",
Expand All @@ -53,6 +57,8 @@
"cargo": {
"args": [
"test",
"--no-default-features",
"--features=test",
"--no-run",
"--lib",
"--package=orcapod"
Expand Down Expand Up @@ -86,6 +92,8 @@
"cargo": {
"args": [
"test",
"--no-default-features",
"--features=test",
"--no-run",
"--package=orcapod",
"--bin=exe_file_stem"
Expand Down
14 changes: 9 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
{
"[markdown]": {
"editor.defaultFormatter": null
},
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.rulers": [
100
],
"files.autoSave": "off",
"files.insertFinalNewline": true,
"[markdown]": {
"editor.defaultFormatter": null
},
"gitlens.showWelcomeOnInstall": false,
"gitlens.showWhatsNewAfterUpgrades": false,
"lldb.consoleMode": "evaluate",
"rust-analyzer.cargo.features": [
"test"
],
"rust-analyzer.cargo.noDefaultFeatures": true,
"rust-analyzer.check.command": "clippy",
"rust-analyzer.runnables.extraTestBinaryArgs": [
"--nocapture"
Expand All @@ -22,10 +26,10 @@
],
"jupyter.kernels.excludePythonEnvironments": [
"/bin/python3",
"/usr/bin/python3",
"/usr/bin/python3"
],
"notebook.formatOnSave.enabled": true,
"notebook.output.scrolling": true,
"python.defaultInterpreterPath": "~/.local/share/base/bin/python3",
"python.terminal.activateEnvironment": false,
"python.terminal.activateEnvironment": false
}
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ categories = [
license = "MIT license"
edition = "2024"

[features]
default = []
test = []

[lib]
crate-type = ["rlib", "cdylib"]

Expand Down Expand Up @@ -53,6 +57,8 @@ heck = "0.5.0"
hex = "0.4.3"
# hashmaps that preserve insertion order
indexmap = { version = "2.9.0", features = ["serde"] }
# utilities for iterables
itertools = "0.14.0"
# random name generator
names = "0.14.0"
# graph algorithms
Expand Down Expand Up @@ -106,6 +112,7 @@ restriction = "deny"
style = "deny"
suspicious = "deny"

allow_attributes = { level = "allow", priority = 127 } # Useful when suppressing warnings is also desired.
arbitrary_source_item_ordering = { level = "allow", priority = 127 } # allow arbitrary ordering to keep relevant code nearby
arithmetic_side_effects = { level = "allow", priority = 127 } # allow arithmetic for convenience though it could overflow
as_conversions = { level = "allow", priority = 127 } # allow casting
Expand Down
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
```bash
#!/bin/bash
set -e # fail early on non-zero exit
cargo clippy --all-targets -- -D warnings # Rust syntax and style tests
cargo clippy --no-default-features --features=test --all-targets -- -D warnings # Rust syntax and style tests
cargo fmt --check # Rust formatting test
cargo llvm-cov --no-clean --ignore-filename-regex "bin/.*|lib\.rs" -- --nocapture # Rust integration tests w/ stdout coverage summary
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)
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
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
. ~/.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
cargo llvm-cov --no-clean --no-default-features --features=test --ignore-filename-regex "bin/.*|lib\.rs" -- --nocapture # Rust integration tests w/ stdout coverage summary
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)
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
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
. ~/.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
```

## Docs
Expand All @@ -29,6 +29,15 @@ cargo modules dependencies --lib --no-uses --no-fns --focus-on "orcapod::uniffi:
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
```

## Git Worktrees

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.

```bash
git worktree add /path/to/new/dir-name branch-name --relative-paths # create
git worktree remove dir-name # delete
```

## Project Management

Progress is tracked under GH project [orcapod](https://github.com/orgs/walkerlab/projects/2).
Expand Down
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
"strsim",
"getrandom",
"wasi",
"patchelf"
"patchelf",
"itertools"
],
"useGitignore": false,
"ignorePaths": [
Expand Down
6 changes: 3 additions & 3 deletions src/core/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::{
clippy::indexing_slicing,
reason = "Reading less than 0 is impossible."
)]
pub(crate) fn hash_stream(stream: &mut impl Read) -> Result<String> {
pub fn hash_stream(stream: &mut impl Read) -> Result<String> {
const BUFFER_SIZE: usize = 8 << 10; // 8KB chunks to match with page size typically found
let mut hash = Sha256::new();

Expand Down Expand Up @@ -88,7 +88,7 @@ pub fn hash_dir(dirpath: impl AsRef<Path>) -> Result<String> {
/// # Errors
///
/// Will return error if hashing fails on file or directory.
pub(crate) fn hash_blob(
pub fn hash_blob(
namespace_lookup: &HashMap<String, PathBuf, RandomState>,
blob: &Blob,
) -> Result<Blob> {
Expand All @@ -102,7 +102,7 @@ pub(crate) fn hash_blob(
})
}

pub(crate) fn make_random_hash() -> String {
pub fn make_random_hash() -> String {
let mut bytes = [0; 32];
rand::rng().fill_bytes(&mut bytes);
hex::encode(bytes)
Expand Down
11 changes: 1 addition & 10 deletions src/core/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,9 @@ impl fmt::Debug for OrcaError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match &self.kind {
Kind::AgentCommunicationFailure { backtrace, .. }
| Kind::EmptyResponseWhenLoadingContainerAltImage { backtrace, .. }
| Kind::GeneratedNamesOverflow { backtrace, .. }
| Kind::IncompletePacket { backtrace, .. }
| Kind::InvalidFilepath { backtrace, .. }
| Kind::InvalidPodResultTerminatedDatetime { backtrace, .. }
| Kind::KeyMissing { backtrace, .. }
| Kind::NoAnnotationFound { backtrace, .. }
| Kind::NoContainerNames { backtrace, .. }
| Kind::NoFileName { backtrace, .. }
| Kind::NoMatchingPodRun { backtrace, .. }
| Kind::NoRemainingServices { backtrace, .. }
| Kind::NoTagFoundInContainerAltImage { backtrace, .. }
| Kind::MissingInfo { backtrace, .. }
| Kind::BollardError { backtrace, .. }
| Kind::ChronoParseError { backtrace, .. }
| Kind::DOTError { backtrace, .. }
Expand Down
37 changes: 32 additions & 5 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
/// State change verification via cryptographic utilities.
pub mod crypto;
macro_rules! inner_attr_to_each {
{ #!$attr:tt $($it:item)* } => {
$(
#$attr
$it
)*
}
}

pub(crate) mod error;
pub(crate) mod graph;
/// Components of the data model.
pub mod model;
pub(crate) mod orchestrator;
pub(crate) mod pipeline;
pub(crate) mod store;
pub(crate) mod util;
pub(crate) mod validation;

inner_attr_to_each! {
#![cfg(feature = "default")]
pub(crate) mod crypto;
pub(crate) mod model;
pub(crate) mod orchestrator;
}

#[cfg(feature = "test")]
inner_attr_to_each! {
#![cfg_attr(
feature = "test",
allow(
missing_docs,
clippy::missing_errors_doc,
clippy::missing_panics_doc,
reason = "Documentation not necessary since private API.",
),
)]
pub mod crypto;
pub mod model;
pub mod orchestrator;
}
25 changes: 10 additions & 15 deletions src/core/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use serde::{Deserialize as _, Deserializer, Serialize, Serializer};
use serde_yaml::{self, Value};
use std::{
collections::{BTreeMap, HashMap},
hash::BuildHasher,
result,
sync::Arc,
};
Expand Down Expand Up @@ -38,8 +39,8 @@ pub fn to_yaml<T: Serialize>(instance: &T) -> Result<String> {
Ok(yaml)
}

pub(crate) fn serialize_hashmap<S, K: Ord + Serialize, V: Serialize>(
map: &HashMap<K, V>,
pub fn serialize_hashmap<S, K: Ord + Serialize, V: Serialize, BH: BuildHasher>(
map: &HashMap<K, V, BH>,
serializer: S,
) -> result::Result<S::Ok, S::Error>
where
Expand All @@ -49,9 +50,9 @@ where
sorted.serialize(serializer)
}

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

#[expect(
clippy::expect_used,
reason = "Function signature required by serde API."
)]
pub(crate) fn deserialize_pod<'de, D>(deserializer: D) -> result::Result<Arc<Pod>, D::Error>
#[expect(clippy::expect_used, reason = "Serde requires this signature.")]
pub fn deserialize_pod<'de, D>(deserializer: D) -> result::Result<Arc<Pod>, D::Error>
where
D: Deserializer<'de>,
{
Expand All @@ -89,11 +87,8 @@ where
)
}

#[expect(
clippy::expect_used,
reason = "Function signature required by serde API."
)]
pub(crate) fn deserialize_pod_job<'de, D>(deserializer: D) -> result::Result<Arc<PodJob>, D::Error>
#[expect(clippy::expect_used, reason = "Serde requires this signature.")]
pub fn deserialize_pod_job<'de, D>(deserializer: D) -> result::Result<Arc<PodJob>, D::Error>
where
D: Deserializer<'de>,
{
Expand Down
Loading