MCPcopy Create free account
hub / github.com/It4innovations/hyperqueue / validate

Method validate

crates/hyperqueue/src/client/commands/submit/defs.rs:324–350  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

322
323impl JobDef {
324 pub fn validate(&self) -> crate::Result<()> {
325 if self.tasks.is_empty() && self.array.is_none() {
326 return Err(HqError::DeserializationError("No tasks defined".into()));
327 }
328
329 if let Some(array) = &self.array {
330 if !self.tasks.is_empty() {
331 return Err(HqError::DeserializationError(
332 "Definition of array job and individual task cannot be mixed".into(),
333 ));
334 }
335 if array.ids.is_none() && array.entries.is_empty() {
336 return Err(HqError::DeserializationError(
337 "One of attributes of array must be defined: 'ids', 'entries'".into(),
338 ));
339 }
340 if let Some(ids) = &array.ids
341 && !array.entries.is_empty()
342 && ids.id_count() as usize != array.entries.len()
343 {
344 return Err(HqError::DeserializationError(
345 "Items 'ids' and 'entries' does not match".into(),
346 ));
347 }
348 }
349 Ok(())
350 }
351
352 pub fn parse(str: &str) -> crate::Result<JobDef> {
353 let jdef: JobDef = toml::from_str(str)?;

Callers 5

p_allocation_requestFunction · 0.45
gather_configurationFunction · 0.45
resource_requestMethod · 0.45
parseMethod · 0.45

Calls 4

intoMethod · 0.80
id_countMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected