Skip to content

Commit

Permalink
[task.yaml.orig] user_io defaults to std_io
Browse files Browse the repository at this point in the history
  • Loading branch information
Virv12 committed Nov 13, 2024
1 parent 036e267 commit ddc7ef6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
15 changes: 15 additions & 0 deletions task-maker-format/src/ioi/dag/task_type/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,28 @@ use crate::{EvaluationData, SourceFile, Tag};

/// The type of communication for the solution in a communication task.
#[derive(Debug, Clone, Copy, Serialize, Deserialize, TypeScriptify, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum UserIo {
/// Communication is achieved by using stdin/stdout.
StdIo,
/// Communication is achieved by using the pipes passed in argv.
FifoIo,
}

impl UserIo {
/// Used for deserialization.
/// Returns UserIo::StdIo.
pub fn std_io() -> Self {
UserIo::StdIo
}

/// Used for deserialization.
/// Returns UserIo::FifoIo.
pub fn fifo_io() -> Self {
UserIo::FifoIo
}
}

/// The internal data of a task of type `Batch`.
#[derive(Debug, Clone, Serialize, Deserialize, TypeScriptify)]
pub struct CommunicationTypeData {
Expand Down
15 changes: 5 additions & 10 deletions task-maker-format/src/ioi/format/italian_yaml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ struct TaskYAML {
///
/// Can be either "std_io" for using stdin/stdout, or "fifo_io" for using pipes given in argv.
/// Defaults to "fifo_io".
pub user_io: Option<String>,
#[serde(default = "UserIo::fifo_io")]
pub user_io: UserIo,

/// Compatibility with cms, unused.
pub score_mode: Option<String>,
Expand Down Expand Up @@ -437,7 +438,8 @@ struct TaskYAMLOrig {
///
/// Can be either "std_io" for using stdin/stdout, or "fifo_io" for using pipes given in argv.
/// Defaults to "fifo_io".
pub user_io: Option<String>,
#[serde(default = "UserIo::std_io")]
pub user_io: UserIo,
}

impl TaskYAMLOrig {
Expand Down Expand Up @@ -864,17 +866,10 @@ fn parse_communication_task_data(
// Link the manager statically. This makes sure that it will work also outside this machine.
manager.link_static();

let user_io = match yaml.user_io.as_deref() {
None => UserIo::FifoIo,
Some("std_io") => UserIo::StdIo,
Some("fifo_io") => UserIo::FifoIo,
Some(other) => bail!("Unsupported value \"{}\" for user_io in task.yaml", other),
};

Ok(Some(TaskType::Communication(CommunicationTypeData {
manager: Arc::new(manager),
num_processes: yaml.num_processes.unwrap_or(1),
user_io,
user_io: yaml.user_io,
})))
}

Expand Down

0 comments on commit ddc7ef6

Please sign in to comment.