Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions 01-intro/anysystem-intro/ping-pong/impl_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class PingClient(Process):
def __init__(self, proc_id: str, server_id: str):
self._id = proc_id
self._server_id = server_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# process messages from the local user
Expand All @@ -25,6 +28,9 @@ class PingServer(Process):
def __init__(self, proc_id: str):
self._id = proc_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# process messages from the local user (not used in this example)
pass
Expand Down
6 changes: 6 additions & 0 deletions 01-intro/anysystem-intro/ping-pong/impl_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def __init__(self, proc_id: str, server_id: str):
self._server_id = server_id
self._ping = None

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# process messages from the local user
if msg.type == 'PING':
Expand All @@ -32,6 +35,9 @@ class PingServer(Process):
def __init__(self, proc_id: str):
self._id = proc_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# process messages from the local user (not used in this example)
pass
Expand Down
1 change: 1 addition & 0 deletions 01-intro/anysystem-intro/ping-pong/tests/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub fn build_system(config: &TestConfig) -> System {
let client = client_f.build(("client", "server"), config.seed);
sys.add_process("server", boxed!(server), "server-node");
sys.add_process("client", boxed!(client), "client-node");

sys
}

Expand Down
20 changes: 13 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions anysystem/python/anysystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ def time(self) -> float:


class Process:
@abc.abstractmethod
def on_start(self, ctx: Context):
"""
This method is called after the process instance is created.
"""

@abc.abstractmethod
def on_local_message(self, msg: Message, ctx: Context):
"""
Expand Down
24 changes: 24 additions & 0 deletions homework/01-guarantees/solution/guarantees.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ def __init__(self, proc_id: str, receiver_id: str):
self._id = proc_id
self._receiver = receiver_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# receive message for delivery from local user
pass
Expand All @@ -25,6 +28,9 @@ class AtMostOnceReceiver(Process):
def __init__(self, proc_id: str):
self._id = proc_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# not used in this task
pass
Expand All @@ -46,6 +52,9 @@ def __init__(self, proc_id: str, receiver_id: str):
self._id = proc_id
self._receiver = receiver_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# receive message for delivery from local user
pass
Expand All @@ -63,6 +72,9 @@ class AtLeastOnceReceiver(Process):
def __init__(self, proc_id: str):
self._id = proc_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# not used in this task
pass
Expand All @@ -84,6 +96,9 @@ def __init__(self, proc_id: str, receiver_id: str):
self._id = proc_id
self._receiver = receiver_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# receive message for delivery from local user
pass
Expand All @@ -101,6 +116,9 @@ class ExactlyOnceReceiver(Process):
def __init__(self, proc_id: str):
self._id = proc_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# not used in this task
pass
Expand All @@ -122,6 +140,9 @@ def __init__(self, proc_id: str, receiver_id: str):
self._id = proc_id
self._receiver = receiver_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# receive message for delivery from local user
pass
Expand All @@ -139,6 +160,9 @@ class ExactlyOnceOrderedReceiver(Process):
def __init__(self, proc_id: str):
self._id = proc_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# not used in this task
pass
Expand Down
1 change: 1 addition & 0 deletions homework/01-guarantees/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ anysystem = "0.1.2"
assertables = "3.2.2"
clap = { version = "3.1.17", features = ["cargo", "derive"] }
env_logger = "0.9.0"
indexmap = "2.12.1"
log = "0.4.14"
rand = "0.8.5"
rand_pcg = "0.3.1"
Expand Down
5 changes: 3 additions & 2 deletions homework/01-guarantees/tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ mod common;
mod tests;
mod tests_mc;

use std::collections::{BTreeMap, HashSet};
use std::collections::HashSet;
use std::env;
use std::io::Write;

use clap::Parser;
use env_logger::Builder;
use indexmap::IndexMap;
use log::LevelFilter;

use anysystem::test::{TestResult, TestSuite};
Expand Down Expand Up @@ -272,7 +273,7 @@ fn main() {
}
}

fn score(results: BTreeMap<String, TestResult>) -> f32 {
fn score(results: IndexMap<String, TestResult>) -> f32 {
let guarantees = HashSet::from(["AT MOST ONCE", "AT LEAST ONCE", "EXACTLY ONCE", "EXACTLY ONCE ORDERED"]);
let mut failed_guarantees: HashSet<&str> = HashSet::new();
let mut failed_overheads: HashSet<&str> = HashSet::new();
Expand Down
3 changes: 3 additions & 0 deletions homework/04-broadcast/solution/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def __init__(self, proc_id: str, processes: List[str]):
self._id = proc_id
self._processes = processes

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
if msg.type == 'SEND':
bcast_msg = Message('BCAST', {
Expand Down
1 change: 1 addition & 0 deletions homework/04-broadcast/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
anysystem = "0.1.2"
clap = { version = "3.2.17", features = ["cargo", "derive"] }
env_logger = "0.9.0"
indexmap = "2.12.1"
log = "0.4.17"
rand = "0.8.5"
rand_pcg = "0.3.1"
Expand Down
5 changes: 3 additions & 2 deletions homework/04-broadcast/tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ mod common;
mod tests;
mod tests_mc;

use std::collections::{BTreeMap, HashSet};
use std::collections::HashSet;
use std::env;
use std::io::Write;

use clap::Parser;
use env_logger::Builder;
use indexmap::IndexMap;
use log::LevelFilter;

use anysystem::python::PyProcessFactory;
Expand Down Expand Up @@ -99,7 +100,7 @@ fn main() {
}
}

fn score(results: BTreeMap<String, TestResult>) -> f32 {
fn score(results: IndexMap<String, TestResult>) -> f32 {
let mut violated = HashSet::new();
for (_, result) in results {
if let Err(e) = result {
Expand Down
3 changes: 3 additions & 0 deletions homework/06-membership/solution/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class GroupMember(Process):
def __init__(self, proc_id: str):
self._id = proc_id

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
if msg.type == 'JOIN':
# Add process to the group
Expand Down
1 change: 1 addition & 0 deletions homework/06-membership/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ anysystem = "0.1.2"
assertables = "3.2.2"
clap = { version = "3.2.17", features = ["cargo", "derive"] }
env_logger = "0.9.0"
indexmap = "2.12.1"
log = "0.4.17"
rand = "0.8.5"
rand_pcg = "0.3.1"
Expand Down
5 changes: 3 additions & 2 deletions homework/06-membership/tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ mod common;
mod tests;
mod tests_mc;

use std::collections::{BTreeMap, HashSet};
use std::collections::HashSet;
use std::env;
use std::io::Write;

use clap::Parser;
use env_logger::Builder;
use indexmap::IndexMap;
use log::LevelFilter;
use rand::prelude::*;
use rand_pcg::Pcg64;
Expand Down Expand Up @@ -152,7 +153,7 @@ macro_rules! string_set {
);
}

fn score(results: BTreeMap<String, TestResult>, monkeys: u32, disable_mc_tests: bool) -> f32 {
fn score(results: IndexMap<String, TestResult>, monkeys: u32, disable_mc_tests: bool) -> f32 {
let basic_group = string_set! {
"SIMPLE",
"GET MEMBERS SEMANTICS",
Expand Down
3 changes: 3 additions & 0 deletions homework/07-kv-sharding/solution/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ def __init__(self, node_id: str, nodes: List[str]):
self._nodes = set(nodes)
self._data = {}

def on_start(self, ctx: Context):
pass

def on_local_message(self, msg: Message, ctx: Context):
# Get value for the key.
# Request:
Expand Down
1 change: 1 addition & 0 deletions homework/07-kv-sharding/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ assertables = "3.2.2"
clap = { version = "3.2.17", features = ["cargo", "derive"] }
decorum = "0.3.1"
env_logger = "0.9.0"
indexmap = "2.12.1"
log = "0.4.17"
rand = "0.8.5"
rand_pcg = "0.3.1"
Expand Down
5 changes: 3 additions & 2 deletions homework/07-kv-sharding/tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ mod common;
mod tests;
mod tests_mc;

use std::collections::{BTreeMap, HashSet};
use std::collections::HashSet;
use std::env;
use std::io::Write;

use clap::Parser;
use env_logger::Builder;
use indexmap::IndexMap;
use log::LevelFilter;

use anysystem::python::PyProcessFactory;
Expand Down Expand Up @@ -112,7 +113,7 @@ macro_rules! string_set {
);
}

fn score(results: BTreeMap<String, TestResult>) -> f32 {
fn score(results: IndexMap<String, TestResult>) -> f32 {
let basic_group = string_set! {
"SINGLE NODE", "INSERTS", "DELETES", "MEMORY OVERHEAD", "MC NORMAL"
};
Expand Down
Loading