Skip to content

Commit 32e4d39

Browse files
committed
fixing handler to read from directory not matching experiment name
1 parent 9a38ff6 commit 32e4d39

File tree

7 files changed

+13
-11
lines changed

7 files changed

+13
-11
lines changed

libtokamap/examples/simple_mapper/mappings/example/globals.json renamed to libtokamap/examples/simple_mapper/mappings/example_v1/globals.json

File renamed without changes.

libtokamap/examples/simple_mapper/mappings/example/magnetics/40/globals.json renamed to libtokamap/examples/simple_mapper/mappings/example_v1/magnetics/40/globals.json

File renamed without changes.

libtokamap/examples/simple_mapper/mappings/example/magnetics/40/mappings.json renamed to libtokamap/examples/simple_mapper/mappings/example_v1/magnetics/40/mappings.json

File renamed without changes.

libtokamap/examples/simple_mapper/mappings/example/mappings.cfg.json renamed to libtokamap/examples/simple_mapper/mappings/example_v1/mappings.cfg.json

File renamed without changes.

libtokamap/schemas/globals.schema.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
"$id": "/schemas/toplevel",
44
"description": "JSON Schema for v1.0 of mapping globals",
55
"type": "object",
6-
"patternProperties": {
7-
"^((?!DATA_SOURCE_CONFIG).)*$": {
8-
"type": "string"
9-
},
10-
"^DATA_SOURCE_CONFIG$": {
6+
"properties": {
7+
"DATA_SOURCE_CONFIG": {
118
"type": "object",
129
"patternProperties": {
1310
"^.*$": {
@@ -16,7 +13,7 @@
1613
}
1714
}
1815
},
19-
"additionalProperties": false,
16+
"additionalProperties": true,
2017
"$defs": {
2118
"args": {
2219
"patternProperties": {

libtokamap/src/handlers/mapping_handler.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ load_mapping_config(const std::filesystem::path& mapping_dir, const valijson::Sc
138138
auto partition_list = mapping_config["partitions"].get<std::vector<libtokamap::MappingPartition>>();
139139
auto groups = mapping_config["groups"].get<std::vector<libtokamap::GroupName>>();
140140

141-
libtokamap::ExperimentMappings experiment_mappings{partition_list, groups};
141+
libtokamap::ExperimentMappings experiment_mappings{partition_list, groups, mapping_dir};
142142
return {metadata.experiment, std::move(experiment_mappings)};
143143
}
144144

@@ -441,14 +441,16 @@ void libtokamap::MappingHandler::load_experiment(const ExperimentName& experimen
441441

442442
auto& experiment_mapping = m_experiment_register[experiment];
443443

444-
auto top_level_globals = load_json(m_mapping_dir / experiment / "globals.json", m_globals_schema);
444+
const auto& mapping_dir = experiment_mapping.root_path;
445+
446+
auto top_level_globals = load_json(mapping_dir / "globals.json", m_globals_schema);
445447
validate(top_level_globals, m_globals_schema);
446448
experiment_mapping.top_level_globals = top_level_globals;
447449

448450
auto& partition_list = experiment_mapping.partition_list;
449451

450452
for (const auto& group_name : experiment_mapping.groups) {
451-
auto group_directory = m_mapping_dir / experiment / group_name;
453+
auto group_directory = mapping_dir / group_name;
452454
auto partition_directory = find_partition_directory(group_directory, partition_list, attributes);
453455
auto partition_attributes = find_partition_attributes(partition_list, attributes);
454456

libtokamap/src/utils/types.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ struct ExperimentMappings {
7373
std::vector<GroupName> groups;
7474
GroupMappings group_mappings;
7575
nlohmann::json top_level_globals;
76+
std::filesystem::path root_path;
7677

7778
ExperimentMappings() = default;
78-
ExperimentMappings(PartitionList partition_list, std::vector<GroupName> groups)
79-
: partition_list(std::move(partition_list)), groups(std::move(groups))
79+
ExperimentMappings(PartitionList partition_list, std::vector<GroupName> groups, std::filesystem::path root_path)
80+
: partition_list(std::move(partition_list)), groups(std::move(groups)), root_path(std::move(root_path))
8081
{
8182
}
8283
ExperimentMappings(const ExperimentMappings& other) = delete;
@@ -88,6 +89,7 @@ struct ExperimentMappings {
8889
std::swap(groups, other.groups);
8990
std::swap(group_mappings, other.group_mappings);
9091
std::swap(top_level_globals, other.top_level_globals);
92+
std::swap(root_path, other.root_path);
9193
}
9294
ExperimentMappings& operator=(ExperimentMappings&& other) noexcept
9395
{
@@ -96,6 +98,7 @@ struct ExperimentMappings {
9698
std::swap(groups, other.groups);
9799
std::swap(group_mappings, other.group_mappings);
98100
std::swap(top_level_globals, other.top_level_globals);
101+
std::swap(root_path, other.root_path);
99102
return *this;
100103
}
101104
~ExperimentMappings() = default;

0 commit comments

Comments
 (0)