Skip to content

Commit ad1e3a1

Browse files
Merge pull request #88 from Synicix/dev
Rename parameters to match new spec
2 parents 89cc07b + acb6b0d commit ad1e3a1

File tree

7 files changed

+87
-90
lines changed

7 files changed

+87
-90
lines changed

src/core/orchestrator/docker.rs

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::{
22
core::util::get,
33
uniffi::{
44
error::{Result, selector},
5-
model::{Input, PodJob},
5+
model::{PathSet, PodJob},
66
orchestrator::{RunInfo, Status, docker::LocalDockerOrchestrator},
77
},
88
};
@@ -50,52 +50,48 @@ impl LocalDockerOrchestrator {
5050
host_output_directory.to_string_lossy(),
5151
pod_job.pod.output_dir.to_string_lossy(),
5252
)];
53-
let input_binds = pod_job
54-
.pod
55-
.input_stream
56-
.iter()
57-
.try_fold::<_, _, Result<_>>(
58-
vec![],
59-
|mut flattened_binds, (stream_name, stream_info)| {
60-
flattened_binds.extend(match get(&pod_job.input_stream, stream_name)? {
61-
Input::Unary(blob) => {
62-
vec![format!(
53+
let input_binds = pod_job.pod.input_spec.iter().try_fold::<_, _, Result<_>>(
54+
vec![],
55+
|mut flattened_binds, (stream_name, stream_info)| {
56+
flattened_binds.extend(match get(&pod_job.input_packet, stream_name)? {
57+
PathSet::Unary(blob) => {
58+
vec![format!(
59+
"{}:{}:{}",
60+
path::absolute(
61+
get(namespace_lookup, &blob.location.namespace)?
62+
.join(&blob.location.path)
63+
)?
64+
.to_string_lossy(),
65+
stream_info.path.to_string_lossy(),
66+
"ro"
67+
)]
68+
}
69+
PathSet::Collection(blobs) => blobs
70+
.iter()
71+
.map(|blob| {
72+
Ok(format!(
6373
"{}:{}:{}",
6474
path::absolute(
6575
get(namespace_lookup, &blob.location.namespace)?
6676
.join(&blob.location.path)
6777
)?
6878
.to_string_lossy(),
69-
stream_info.path.to_string_lossy(),
70-
"ro"
71-
)]
72-
}
73-
Input::Collection(blobs) => blobs
74-
.iter()
75-
.map(|blob| {
76-
Ok(format!(
77-
"{}:{}:{}",
78-
path::absolute(
79-
get(namespace_lookup, &blob.location.namespace)?
80-
.join(&blob.location.path)
81-
)?
79+
stream_info
80+
.path
81+
.join(blob.location.path.file_name().context(
82+
selector::NoFileName {
83+
path: blob.location.path.clone()
84+
}
85+
)?)
8286
.to_string_lossy(),
83-
stream_info
84-
.path
85-
.join(blob.location.path.file_name().context(
86-
selector::NoFileName {
87-
path: blob.location.path.clone()
88-
}
89-
)?)
90-
.to_string_lossy(),
91-
"ro"
92-
))
93-
})
94-
.collect::<Result<_>>()?,
95-
});
96-
Ok(flattened_binds)
97-
},
98-
)?;
87+
"ro"
88+
))
89+
})
90+
.collect::<Result<_>>()?,
91+
});
92+
Ok(flattened_binds)
93+
},
94+
)?;
9995
Ok((input_binds, output_bind))
10096
}
10197
#[expect(

src/uniffi/model.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ pub struct Pod {
4646
pub command: String,
4747
/// Exposed, internal input streams.
4848
#[serde(serialize_with = "serialize_hashmap")]
49-
pub input_stream: HashMap<String, StreamInfo>,
49+
pub input_spec: HashMap<String, PathInfo>,
5050
/// Exposed, internal output directory.
5151
pub output_dir: PathBuf,
5252
/// Exposed, internal output streams.
5353
#[serde(serialize_with = "serialize_hashmap")]
54-
pub output_stream: HashMap<String, StreamInfo>,
54+
pub output_spec: HashMap<String, PathInfo>,
5555
/// Link to source associated with image binary.
5656
pub source_commit_url: String,
5757
/// Recommendation for CPU in fractional cores.
@@ -74,9 +74,9 @@ impl Pod {
7474
annotation: Option<Annotation>,
7575
image: String,
7676
command: String,
77-
input_stream: HashMap<String, StreamInfo>,
77+
input_spec: HashMap<String, PathInfo>,
7878
output_dir: PathBuf,
79-
output_stream: HashMap<String, StreamInfo>,
79+
output_spec: HashMap<String, PathInfo>,
8080
source_commit_url: String,
8181
recommended_cpus: f32,
8282
recommended_memory: u64,
@@ -87,9 +87,9 @@ impl Pod {
8787
hash: String::new(),
8888
image,
8989
command,
90-
input_stream,
90+
input_spec,
9191
output_dir,
92-
output_stream,
92+
output_spec,
9393
source_commit_url,
9494
recommended_cpus,
9595
recommended_memory,
@@ -120,9 +120,9 @@ pub struct PodJob {
120120
pub pod: Arc<Pod>,
121121
/// Attached, external input streams.
122122
#[serde(serialize_with = "serialize_hashmap")]
123-
pub input_stream: HashMap<String, Input>,
123+
pub input_packet: HashMap<String, PathSet>,
124124
/// Attached, external output directory.
125-
pub output_dir: OrcaPath,
125+
pub output_dir: URI,
126126
/// Maximum allowable cores in fractional cores for the computation.
127127
pub cpu_limit: f32,
128128
/// Maximum allowable memory in bytes for the computation.
@@ -143,23 +143,23 @@ impl PodJob {
143143
pub fn new(
144144
annotation: Option<Annotation>,
145145
pod: Arc<Pod>,
146-
mut input_stream: HashMap<String, Input>,
147-
output_dir: OrcaPath,
146+
mut input_packet: HashMap<String, PathSet>,
147+
output_dir: URI,
148148
cpu_limit: f32,
149149
memory_limit: u64,
150150
env_vars: Option<HashMap<String, String>>,
151151
namespace_lookup: &HashMap<String, PathBuf>,
152152
) -> Result<Self> {
153-
input_stream = input_stream
153+
input_packet = input_packet
154154
.into_iter()
155155
.map(|(stream_name, stream_input)| match stream_input {
156-
Input::Unary(blob) => Ok((
156+
PathSet::Unary(blob) => Ok((
157157
stream_name,
158-
Input::Unary(hash_blob(namespace_lookup, blob)?),
158+
PathSet::Unary(hash_blob(namespace_lookup, blob)?),
159159
)),
160-
Input::Collection(blobs) => Ok((
160+
PathSet::Collection(blobs) => Ok((
161161
stream_name,
162-
Input::Collection(
162+
PathSet::Collection(
163163
blobs
164164
.into_iter()
165165
.map(|blob| hash_blob(namespace_lookup, blob))
@@ -172,7 +172,7 @@ impl PodJob {
172172
annotation,
173173
hash: String::new(),
174174
pod,
175-
input_stream,
175+
input_packet,
176176
output_dir,
177177
cpu_limit,
178178
memory_limit,
@@ -269,24 +269,25 @@ pub enum GPUModel {
269269
/// Streams are named and represent an abstraction for the file(s) that represent some particular
270270
/// data.
271271
#[derive(uniffi::Record, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
272-
pub struct StreamInfo {
272+
pub struct PathInfo {
273273
/// Path to stream file or directory.
274274
pub path: PathBuf,
275275
/// Naming pattern for the stream.
276276
pub match_pattern: String,
277277
}
278-
/// Input options.
278+
/// A set of BLOBs, either a single BLOB or a collection of BLOBs.
279+
/// Mainly use for input
279280
#[derive(uniffi::Enum, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
280281
#[serde(untagged)]
281-
pub enum Input {
282+
pub enum PathSet {
282283
/// A single BLOB.
283284
Unary(Blob),
284285
/// A series of BLOBs.
285286
Collection(Vec<Blob>),
286287
}
287288
/// Location of BLOB data.
288289
#[derive(uniffi::Record, Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Default)]
289-
pub struct OrcaPath {
290+
pub struct URI {
290291
/// Namespace alias.
291292
pub namespace: String,
292293
/// Path within namespace.
@@ -299,7 +300,7 @@ pub struct Blob {
299300
/// BLOB available options.
300301
pub kind: BlobKind,
301302
/// BLOB location.
302-
pub location: OrcaPath,
303+
pub location: URI,
303304
/// BLOB contents checksum.
304305
pub checksum: String,
305306
}

src/uniffi/orchestrator/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::uniffi::{
22
error::Result,
3-
model::{OrcaPath, PodJob, PodResult},
3+
model::{PodJob, PodResult, URI},
44
};
55
use serde::{Deserialize, Serialize};
66
use std::{collections::HashMap, path::PathBuf, sync::Arc};
@@ -12,7 +12,7 @@ pub enum ImageKind {
1212
/// `{server.com/}{name}:{tag}`. Server is optional e.g. (`alpine:latest`).
1313
Published(String),
1414
/// A packaged compute environment of image+tag as a tarball.
15-
Tarball(OrcaPath),
15+
Tarball(URI),
1616
}
1717
/// Status of a particular compute run.
1818
#[derive(uniffi::Enum, Serialize, Deserialize, Debug, PartialEq, Eq, Clone, Default)]

tests/extra/python/smoke_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Pod,
1212
PodJob,
1313
Annotation,
14-
OrcaPath,
14+
Uri,
1515
LocalDockerOrchestrator,
1616
LocalFileStore,
1717
ModelId,
@@ -29,9 +29,9 @@ def create_pod(data, _):
2929
),
3030
image="alpine:3.14",
3131
command="sleep 1",
32-
input_stream={},
32+
input_spec={},
3333
output_dir="/tmp/output",
34-
output_stream={},
34+
output_spec={},
3535
source_commit_url="https://github.com/user/simple",
3636
recommended_cpus=0.1,
3737
recommended_memory=10 << 20,
@@ -48,8 +48,8 @@ def create_pod_job(data, config):
4848
version="0.1.0",
4949
),
5050
pod=data["pod"],
51-
input_stream={},
52-
output_dir=OrcaPath(
51+
input_packet={},
52+
output_dir=Uri(
5353
namespace="default",
5454
path=".",
5555
),

tests/fixture/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use names::{Generator, Name};
1111
use orcapod::uniffi::{
1212
error::Result,
13-
model::{Annotation, Blob, BlobKind, Input, OrcaPath, Pod, PodJob, PodResult, StreamInfo},
13+
model::{Annotation, Blob, BlobKind, PathInfo, PathSet, Pod, PodJob, PodResult, URI},
1414
orchestrator::Status,
1515
store::{ModelID, ModelInfo, Store},
1616
};
@@ -41,14 +41,14 @@ pub fn pod_style() -> Result<Pod> {
4141
HashMap::from([
4242
(
4343
"extra-style".to_owned(),
44-
StreamInfo {
44+
PathInfo {
4545
path: PathBuf::from("/extra_styles/style2.t7"),
4646
match_pattern: r".*\.t7".to_owned(),
4747
},
4848
),
4949
(
5050
"base-input".to_owned(),
51-
StreamInfo {
51+
PathInfo {
5252
path: PathBuf::from("/input"),
5353
match_pattern: "input/.*".to_owned(),
5454
},
@@ -57,7 +57,7 @@ pub fn pod_style() -> Result<Pod> {
5757
PathBuf::from("/output"),
5858
HashMap::from([(
5959
"result".to_owned(),
60-
StreamInfo {
60+
PathInfo {
6161
path: PathBuf::from("./result.jpeg"),
6262
match_pattern: r".*\.jpeg".to_owned(),
6363
},
@@ -80,9 +80,9 @@ pub fn pod_job_style(namespace_lookup: &HashMap<String, PathBuf, RandomState>) -
8080
HashMap::from([
8181
(
8282
"extra-style".to_owned(),
83-
Input::Unary(Blob {
83+
PathSet::Unary(Blob {
8484
kind: BlobKind::File,
85-
location: OrcaPath {
85+
location: URI {
8686
namespace: "default".to_owned(),
8787
path: PathBuf::from("styles/mosaic.t7"),
8888
},
@@ -91,18 +91,18 @@ pub fn pod_job_style(namespace_lookup: &HashMap<String, PathBuf, RandomState>) -
9191
),
9292
(
9393
"base-input".to_owned(),
94-
Input::Collection(vec![
94+
PathSet::Collection(vec![
9595
Blob {
9696
kind: BlobKind::File,
97-
location: OrcaPath {
97+
location: URI {
9898
namespace: "default".to_owned(),
9999
path: PathBuf::from("styles/style1.t7"),
100100
},
101101
checksum: String::new(),
102102
},
103103
Blob {
104104
kind: BlobKind::File,
105-
location: OrcaPath {
105+
location: URI {
106106
namespace: "default".to_owned(),
107107
path: PathBuf::from("images/subject.jpeg"),
108108
},
@@ -111,7 +111,7 @@ pub fn pod_job_style(namespace_lookup: &HashMap<String, PathBuf, RandomState>) -
111111
]),
112112
),
113113
]),
114-
OrcaPath {
114+
URI {
115115
namespace: "default".to_owned(),
116116
path: PathBuf::from("output"),
117117
},

0 commit comments

Comments
 (0)