Skip to content

Commit cd75178

Browse files
committed
update configuration files to use XML format instead of proto binary for network, population, vehicles, and ids
1 parent 0b3bc2d commit cd75178

18 files changed

+148
-137
lines changed

rust_qsim/src/simulation/controller/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,12 @@ pub fn create_output_filename(output_dir: &Path, input_file: &Path) -> PathBuf {
244244

245245
pub(crate) fn insert_number_in_proto_filename(path: &Path, part: u32) -> PathBuf {
246246
let filename = path.file_name().unwrap().to_str().unwrap();
247-
let mut stripped = filename.strip_suffix(".binpb").unwrap();
247+
let mut stripped = filename.strip_suffix(".binpb").unwrap_or_else(|| {
248+
panic!(
249+
"insert_number_in_proto_filename expects a filename ending with `.binpb`, got `{}`",
250+
filename
251+
)
252+
});
248253
if let Some(s) = stripped.strip_suffix(format!(".{part}").as_str()) {
249254
stripped = s;
250255
}

rust_qsim/src/simulation/scenario.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,22 @@ impl GlobalScenario {
4141
let network =
4242
Network::from_file_path(&net_in_path, num_parts, config.partitioning().method);
4343

44-
let mut net_out_path = create_output_filename(
45-
&io::resolve_path(config.context(), &config.output().output_dir),
46-
&net_in_path,
47-
);
44+
let output_dir = io::resolve_path(config.context(), &config.output().output_dir);
45+
let mut net_out_path = create_output_filename(&output_dir, &net_in_path);
46+
// We always write the network as proto; `insert_number_in_proto_filename` is a pure `.binpb`
47+
// part-suffix helper and therefore expects the caller to provide a `.binpb` path.
48+
let file_name = net_out_path.file_name().unwrap().to_string_lossy();
49+
let base = file_name
50+
.strip_suffix(".binpb")
51+
.or_else(|| file_name.strip_suffix(".xml"))
52+
.or_else(|| file_name.strip_suffix(".xml.gz"))
53+
.unwrap_or_else(|| {
54+
panic!(
55+
"Network output filename must end with `.binpb`, `.xml`, or `.xml.gz`, got `{}`",
56+
file_name
57+
)
58+
});
59+
net_out_path = net_out_path.with_file_name(format!("{base}.binpb"));
4860
net_out_path = insert_number_in_proto_filename(&net_out_path, num_parts);
4961
network.to_file(&net_out_path);
5062
network

rust_qsim/tests/resources/3-links-url/3-links-config-1.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
modules:
22
network:
33
type: Network
4-
path: ./test_output/simulation/execute_3_links_single_part_from_url/3-links-network.binpb
4+
path: ./test_output/simulation/execute_3_links_single_part_from_url/3-links-network.xml
55
population:
66
type: Population
7-
path: ./test_output/simulation/execute_3_links_single_part_from_url/1-agent-full-leg.binpb
7+
path: ./test_output/simulation/execute_3_links_single_part_from_url/1-agent-full-leg.xml
88
vehicles:
99
type: Vehicles
10-
path: ./test_output/simulation/execute_3_links_single_part_from_url/vehicles.binpb
10+
path: ./test_output/simulation/execute_3_links_single_part_from_url/vehicles.xml
1111
ids:
1212
type: Ids
13-
path: ./test_output/simulation/execute_3_links_single_part_from_url/ids.binpb
13+
path: ./test_output/simulation/execute_3_links_single_part_from_url/ids.xml
1414
partitioning:
1515
type: Partitioning
1616
num_parts: 1

rust_qsim/tests/resources/3-links/3-links-config-1.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
modules:
22
network:
33
type: Network
4-
path: ./test_output/simulation/execute_3_links_single_part/3-links-network.binpb
4+
path: ./test_output/simulation/execute_3_links_single_part/3-links-network.xml
55
population:
66
type: Population
7-
path: ./test_output/simulation/execute_3_links_single_part/1-agent-full-leg.binpb
7+
path: ./test_output/simulation/execute_3_links_single_part/1-agent-full-leg.xml
88
vehicles:
99
type: Vehicles
10-
path: ./test_output/simulation/execute_3_links_single_part/vehicles.binpb
10+
path: ./test_output/simulation/execute_3_links_single_part/vehicles.xml
1111
ids:
1212
type: Ids
13-
path: ./test_output/simulation/execute_3_links_single_part/ids.binpb
13+
path: ./test_output/simulation/execute_3_links_single_part/ids.xml
1414
partitioning:
1515
type: Partitioning
1616
num_parts: 1

rust_qsim/tests/resources/3-links/3-links-config-2.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
modules:
22
network:
33
type: Network
4-
path: ./test_output/simulation/execute_3_links_2_parts/3-links-network.binpb
4+
path: ./test_output/simulation/execute_3_links_2_parts/3-links-network.xml
55
population:
66
type: Population
7-
path: ./test_output/simulation/execute_3_links_2_parts/1-agent-full-leg.binpb
7+
path: ./test_output/simulation/execute_3_links_2_parts/1-agent-full-leg.xml
88
vehicles:
99
type: Vehicles
10-
path: ./test_output/simulation/execute_3_links_2_parts/vehicles.binpb
10+
path: ./test_output/simulation/execute_3_links_2_parts/vehicles.xml
1111
ids:
1212
type: Ids
13-
path: ./test_output/simulation/execute_3_links_2_parts/ids.binpb
13+
path: ./test_output/simulation/execute_3_links_2_parts/ids.xml
1414
partitioning:
1515
type: Partitioning
1616
num_parts: 2

rust_qsim/tests/resources/equil/equil-config-1-adaptive.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
modules:
22
network:
33
type: Network
4-
path: ./test_output/simulation/equil_single_part_adaptive/equil-network.binpb
4+
path: ./test_output/simulation/equil_single_part_adaptive/equil-network.xml
55
population:
66
type: Population
7-
path: ./test_output/simulation/equil_single_part_adaptive/equil-1-plan.binpb
7+
path: ./test_output/simulation/equil_single_part_adaptive/equil-1-plan.xml
88
vehicles:
99
type: Vehicles
10-
path: ./test_output/simulation/equil_single_part_adaptive/equil-vehicles.binpb
10+
path: ./test_output/simulation/equil_single_part_adaptive/equil-vehicles.xml
1111
ids:
1212
type: Ids
13-
path: ./test_output/simulation/equil_single_part_adaptive/ids.binpb
13+
path: ./test_output/simulation/equil_single_part_adaptive/ids.xml
1414
partitioning:
1515
type: Partitioning
1616
num_parts: 1

rust_qsim/tests/resources/equil/equil-config-1.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
modules:
22
network:
33
type: Network
4-
path: ./test_output/simulation/equil_single_part/equil-network.binpb
4+
path: ./test_output/simulation/equil_single_part/equil-network.xml
55
population:
66
type: Population
7-
path: ./test_output/simulation/equil_single_part/equil-1-plan.binpb
7+
path: ./test_output/simulation/equil_single_part/equil-1-plan.xml
88
vehicles:
99
type: Vehicles
10-
path: ./test_output/simulation/equil_single_part/equil-vehicles.binpb
10+
path: ./test_output/simulation/equil_single_part/equil-vehicles.xml
1111
ids:
1212
type: Ids
13-
path: ./test_output/simulation/equil_single_part/ids.binpb
13+
path: ./test_output/simulation/equil_single_part/ids.xml
1414
partitioning:
1515
type: Partitioning
1616
num_parts: 1

rust_qsim/tests/resources/equil/equil-config-2-adaptive.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
modules:
22
network:
33
type: Network
4-
path: ./test_output/simulation/equil_with_channels-adaptive/equil-network.binpb
4+
path: ./test_output/simulation/equil_with_channels-adaptive/equil-network.xml
55
population:
66
type: Population
7-
path: ./test_output/simulation/equil_with_channels-adaptive/equil-1-plan.binpb
7+
path: ./test_output/simulation/equil_with_channels-adaptive/equil-1-plan.xml
88
vehicles:
99
type: Vehicles
10-
path: ./test_output/simulation/equil_with_channels-adaptive/equil-vehicles.binpb
10+
path: ./test_output/simulation/equil_with_channels-adaptive/equil-vehicles.xml
1111
ids:
1212
type: Ids
13-
path: ./test_output/simulation/equil_with_channels-adaptive/ids.binpb
13+
path: ./test_output/simulation/equil_with_channels-adaptive/ids.xml
1414
partitioning:
1515
type: Partitioning
1616
num_parts: 2

rust_qsim/tests/resources/equil/equil-config-2.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
modules:
22
network:
33
type: Network
4-
path: ./test_output/simulation/equil_with_channels/equil-network.binpb
4+
path: ./test_output/simulation/equil_with_channels/equil-network.xml
55
population:
66
type: Population
7-
path: ./test_output/simulation/equil_with_channels/equil-1-plan.binpb
7+
path: ./test_output/simulation/equil_with_channels/equil-1-plan.xml
88
vehicles:
99
type: Vehicles
10-
path: ./test_output/simulation/equil_with_channels/equil-vehicles.binpb
10+
path: ./test_output/simulation/equil_with_channels/equil-vehicles.xml
1111
ids:
1212
type: Ids
13-
path: ./test_output/simulation/equil_with_channels/ids.binpb
13+
path: ./test_output/simulation/equil_with_channels/ids.xml
1414
partitioning:
1515
type: Partitioning
1616
num_parts: 2

rust_qsim/tests/resources/equil/equil-config-simulate-generic-route-panics.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
modules:
22
network:
33
type: Network
4-
path: "./test_output/simulation/output-simulate-generic-route-panics/equil.network.binpb"
4+
path: ./test_output/simulation/output-simulate-generic-route-panics/equil.network.xml
55
population:
66
type: Population
7-
path: "./test_output/simulation/output-simulate-generic-route-panics/equil.population.binpb"
7+
path: ./test_output/simulation/output-simulate-generic-route-panics/equil.population.xml
88
vehicles:
99
type: Vehicles
10-
path: "./test_output/simulation/output-simulate-generic-route-panics/equil.vehicles.binpb"
10+
path: ./test_output/simulation/output-simulate-generic-route-panics/equil.vehicles.xml
1111
ids:
1212
type: Ids
13-
path: "./test_output/simulation/output-simulate-generic-route-panics/equil.ids.binpb"
13+
path: ./test_output/simulation/output-simulate-generic-route-panics/equil.ids.xml
1414
partitioning:
1515
type: Partitioning
1616
num_parts: 1

0 commit comments

Comments
 (0)