-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve task and pin models by supporting resources with units and making a lot optional #36
Conversation
…king a lot optional
Note: This is actually a good place to add more user data validation, so we catch it early and reject it. For example we could check if the image is a properly formatted URI or other stuff like the check if the CID or the fallback url ist set etc. |
src/models.rs
Outdated
|
||
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)] | ||
#[serde(untagged)] | ||
pub enum NumberOrString { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it and also added FromStr, so now "1024kB".parse::<ComputeUnit>()
works :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is now ByteUnit
, CoreUnit
and TimeUnit
src/models.rs
Outdated
let str = serde_json::from_value::<NumberOrString>(json!("60min")).unwrap(); | ||
assert_eq!(str.as_number(), Some(60 * 60)); | ||
assert_eq!(str.as_string(), "60min"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Especially with time (but possibly with storage space as well), I'd maybe test also combinations like "1h 47min 3 sec". Would "3kb 3M" parse ? What about "7min 8gpus" 🙈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"7min 8gpus" is probably something for the future but for time we can use humantime crate which does exactly what you describe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it then make sense to split different types (CPUs/GPUs, MEM, Time) and possibly have an enum including them, with some brute force parsing logic trying each one (or w/ regex match based heuristics)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When removing the time cases (which I did), the rest of the units isnt that much, so I think its fine like this. We can always extend it, but I feel it does its job well.
…ctor of one megabyte when no unit is given
@tuommaki Would you have another look at this when you find time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is fine now. There are some semantic issues (such as mgpu) still, I think, but maybe we can ignore them for a bit as long as we don't document & advertise use of them.
This tries to improve our model layer, especially for tasks and pins as those two are really end-user facing.
env: []
to make it parsecpus: 1000mcpu
works the same ascpus: 1000
, but also get stuff liketime: 3h