Skip to content

Commit a44c844

Browse files
Merge pull request #43 from Synicix/pod-job2
Add pod-job model
2 parents a6656ea + e9e3342 commit a44c844

File tree

15 files changed

+587
-271
lines changed

15 files changed

+587
-271
lines changed

.clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ excessive-nesting-threshold = 3
22
too-many-arguments-threshold = 10
33
allowed-prefixes = ["..", "GPU", "Orca"]
44
min-ident-chars-threshold = 2
5-
allowed-idents-below-min-chars = ["..", "k", "f", "re", "id"]
5+
allowed-idents-below-min-chars = ["..", "k", "f", "re", "id", "Ok"]

.devcontainer/devcontainer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"source=${localWorkspaceFolderBasename}_devcontainer_docker_data,target=/var/lib/docker,type=volume"
1010
],
1111
"remoteEnv": {
12-
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
12+
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}",
13+
"RUST_BACKTRACE": "1"
1314
},
1415
"postStartCommand": "docker system prune -fa && docker volume prune -f",
1516
"hostRequirements": {

.github/workflows/tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,6 @@ jobs:
2121
- name: Run format test
2222
run: cargo fmt --check
2323
- name: Run integration tests w/ coverage report
24-
run: cargo llvm-cov -- --nocapture
24+
env:
25+
RUST_BACKTRACE: full
26+
run: cargo llvm-cov -- --nocapture

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ glob = "0.3.1"
3131
regex = "1.11.0"
3232
heck = "0.5.0"
3333
colored = "2.1.0"
34+
thiserror = "2.0.11"
3435

3536
[dev-dependencies]
3637
tempfile = "3.13.0"
@@ -93,9 +94,9 @@ std_instead_of_alloc = { level = "allow", priority = 127 } # we shou
9394
std_instead_of_core = { level = "allow", priority = 127 } # we should use std when possible
9495
string_add = { level = "allow", priority = 127 } # simple concat ok
9596
string_lit_chars_any = { level = "allow", priority = 127 } # favor readability until a perf case comes up
96-
todo = { level = "warn", priority = 127 } # warn todos
9797
use_debug = { level = "warn", priority = 127 } # debug print
9898

9999
# temporary
100-
single_call_fn = { level = "allow", priority = 127 } # remove once other models are in
100+
todo = { level = "allow", priority = 127 } # allow until folder hash and input collection cases are complete, then warn todos
101+
single_call_fn = { level = "allow", priority = 127 } # remove once more models need pointer serializers/deserializers
101102
tests_outside_test_module = { level = "allow", priority = 127 } # for now due to false-positive for integration tests: https://github.com/rust-lang/rust-clippy/pull/13038

cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"millicores",
1010
"zenmldocker",
1111
"zenml",
12-
"indoc"
12+
"indoc",
13+
"thiserror"
1314
]
1415
}

src/error.rs

Lines changed: 45 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,111 +3,81 @@ use glob;
33
use regex;
44
use serde_yaml;
55
use std::{
6-
error::Error,
76
fmt,
87
fmt::{Display, Formatter},
98
io,
109
path::PathBuf,
1110
result,
1211
};
12+
use thiserror::Error;
1313
/// Shorthand for a Result that returns an `OrcaError`.
1414
pub type Result<T> = result::Result<T, OrcaError>;
15-
1615
/// Possible errors you may encounter.
17-
#[derive(Debug)]
16+
#[derive(Error, Debug)]
1817
pub(crate) enum Kind {
19-
/// Returned if a file is not expected to exist.
20-
FileExists(PathBuf),
21-
/// Returned if an annotation was expected to exist.
22-
NoAnnotationFound(String, String, String),
23-
/// Returned if a model save was attempted without an annotation set.
24-
MissingAnnotationOnSave,
25-
/// Returned if an annotation delete was attempted on a model's last annotation.
26-
DeletingLastAnnotation(String, String, String),
27-
/// Returned if a regular expression was expected to match.
28-
NoRegexMatch,
29-
/// Wrapper around `glob::GlobError`
30-
GlobError(glob::GlobError),
31-
/// Wrapper around `glob::PatternError`
32-
GlobPatternError(glob::PatternError),
33-
/// Wrapper around `regex::Error`
34-
RegexError(regex::Error),
35-
/// Wrapper around `serde_yaml::Error`
36-
SerdeYamlError(serde_yaml::Error),
37-
/// Wrapper around `io::Error`
38-
IoError(io::Error),
18+
#[error("File `{}` already exists.", path.to_string_lossy().bright_cyan())]
19+
FileExists { path: PathBuf },
20+
#[error("No annotation found for `{name}:{version}` {class}.")]
21+
NoAnnotationFound {
22+
class: String,
23+
name: String,
24+
version: String,
25+
},
26+
#[error(transparent)]
27+
GlobPatternError(#[from] glob::PatternError),
28+
#[error(transparent)]
29+
RegexError(#[from] regex::Error),
30+
#[error(transparent)]
31+
SerdeYamlError(#[from] serde_yaml::Error),
32+
#[error(transparent)]
33+
IoError(#[from] io::Error),
3934
}
40-
4135
/// A stable error API interface.
42-
#[derive(Debug)]
43-
pub struct OrcaError(Kind);
44-
impl Error for OrcaError {}
36+
#[derive(Error, Debug)]
37+
pub struct OrcaError {
38+
kind: Kind,
39+
}
4540
impl OrcaError {
46-
/// Returns `true` if the error was caused by an attempt to delete a model's last annotation.
47-
pub const fn is_deleting_last_annotation(&self) -> bool {
48-
matches!(self.0, Kind::DeletingLastAnnotation(_, _, _))
41+
/// Returns `true` if the error was caused by an invalid model annotation.
42+
pub const fn is_invalid_annotation(&self) -> bool {
43+
matches!(self.kind, Kind::NoAnnotationFound { .. })
4944
}
5045
}
5146
impl Display for OrcaError {
52-
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
53-
match &self.0 {
54-
Kind::FileExists(path) => {
55-
write!(
56-
f,
57-
"File `{}` already exists.",
58-
path.to_string_lossy().bright_cyan()
59-
)
60-
}
61-
Kind::NoAnnotationFound(class, name, version) => {
62-
write!(f, "No annotation found for `{name}:{version}` {class}.")
63-
}
64-
Kind::MissingAnnotationOnSave => {
65-
write!(f, "No annotation found when attempting to store.")
66-
}
67-
Kind::DeletingLastAnnotation(class, name, version) => {
68-
write!(
69-
f,
70-
"Attempted to delete the last annotation for `{name}:{version}` {class}."
71-
)
72-
}
73-
Kind::NoRegexMatch => {
74-
write!(f, "No match for regex.")
75-
}
76-
Kind::GlobError(error) => write!(f, "{error}"),
77-
Kind::GlobPatternError(error) => write!(f, "{error}"),
78-
Kind::SerdeYamlError(error) => write!(f, "{error}"),
79-
Kind::RegexError(error) => write!(f, "{error}"),
80-
Kind::IoError(error) => write!(f, "{error}"),
81-
}
82-
}
83-
}
84-
impl From<glob::GlobError> for OrcaError {
85-
fn from(error: glob::GlobError) -> Self {
86-
Self(Kind::GlobError(error))
47+
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
48+
write!(f, "{}", self.kind)
8749
}
8850
}
8951
impl From<glob::PatternError> for OrcaError {
9052
fn from(error: glob::PatternError) -> Self {
91-
Self(Kind::GlobPatternError(error))
92-
}
93-
}
94-
impl From<serde_yaml::Error> for OrcaError {
95-
fn from(error: serde_yaml::Error) -> Self {
96-
Self(Kind::SerdeYamlError(error))
53+
Self {
54+
kind: Kind::GlobPatternError(error),
55+
}
9756
}
9857
}
9958
impl From<regex::Error> for OrcaError {
10059
fn from(error: regex::Error) -> Self {
101-
Self(Kind::RegexError(error))
60+
Self {
61+
kind: Kind::RegexError(error),
62+
}
63+
}
64+
}
65+
impl From<serde_yaml::Error> for OrcaError {
66+
fn from(error: serde_yaml::Error) -> Self {
67+
Self {
68+
kind: Kind::SerdeYamlError(error),
69+
}
10270
}
10371
}
10472
impl From<io::Error> for OrcaError {
10573
fn from(error: io::Error) -> Self {
106-
Self(Kind::IoError(error))
74+
Self {
75+
kind: Kind::IoError(error),
76+
}
10777
}
10878
}
10979
impl From<Kind> for OrcaError {
110-
fn from(error: Kind) -> Self {
111-
Self(error)
80+
fn from(kind: Kind) -> Self {
81+
Self { kind }
11282
}
11383
}

0 commit comments

Comments
 (0)