Commit 3c0c058b authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Merge branch '268_fix_datasetblock_missing_output_handling' into 'master'

Fix DatasetBlock output handling

Closes #268

See merge request !137
parents 9eb0a690 ce4fa69e
Pipeline #40548 failed with stages
in 11 minutes and 37 seconds
......@@ -103,15 +103,17 @@ class AlgorithmData:
def parse(self, config: dict) -> None:
prefix = config.pop("prefix")
algorithm_name = config.get("algorithm")
if algorithm_name is not None:
if algorithm_name is not None and algorithm_name != "":
algorithm = Asset(prefix, AssetType.ALGORITHM, algorithm_name)
for group in algorithm.declaration["groups"]:
for io_type, type_map in [
("inputs", self.input_type_map),
("outputs", self.output_type_map),
]:
for input_name, input_data in group.get(io_type, {}).items():
type_map[input_name] = input_data["type"]
is_valid, _ = algorithm.is_valid()
if is_valid:
for group in algorithm.declaration["groups"]:
for io_type, type_map in [
("inputs", self.input_type_map),
("outputs", self.output_type_map),
]:
for input_name, input_data in group.get(io_type, {}).items():
type_map[input_name] = input_data["type"]
self.input_mapping = config.get("inputs", {})
self.output_mapping = config.get("outputs", {})
......@@ -227,7 +229,7 @@ class DatasetBlock(ExperimentBlock):
self.output_type_map = set_data.get("outputs", {})
def dataformat_for_endpoint(self, endpoint: str) -> str:
return self.output_type_map[endpoint]
return self.output_type_map.get(endpoint, "")
def __repr__(self) -> str:
return (
......
{
"schema_version": 2,
"blocks": {
"offsetter_for_loop_processor": {
"algorithm": "",
"inputs": {
"in_data": "in"
},
"outputs": {
"out_data": "out"
},
"parameters": {
"offset": 1
}
},
"offsetter_for_loop_evaluator": {
"algorithm": "",
"inputs": {
"in_data": "in"
},
"outputs": {
"out_data": "out"
}
}
},
"loops": {
"loop_super_block": {
"processor_algorithm": "",
"processor_inputs": {
"in": "in"
},
"processor_outputs": {
"out": "out"
},
"processor_parameters": {
"step": 1
},
"evaluator_algorithm": "",
"evaluator_parameters": {
"threshold": 1
},
"evaluator_inputs": {
"in_loop": "in_loop"
},
"evaluator_outputs": {
"out_loop": "out_loop"
}
},
"echo_loop_block": {
"processor_algorithm": "",
"processor_inputs": {
"in": "in"
},
"processor_outputs": {
"out": "out"
},
"evaluator_algorithm": "",
"evaluator_parameters": {
"threshold": 1
},
"evaluator_inputs": {
"in_loop": "in_loop"
},
"evaluator_outputs": {
"out_loop": "out_loop"
}
}
},
"analyzers": {
"analysis": {
"algorithm": "",
"inputs": {
"input": "input"
}
},
"loop_analysis": {
"algorithm": "",
"inputs": {
"input": "input"
}
}
},
"datasets": {
"integers": {
"database": "None/None",
"protocol": null,
"set": null
},
"integers2": {
"database": "None/None",
"protocol": null,
"set": null
}
},
"globals": {
"environment": {
"name": "Python for tests",
"version": "1.3.0"
},
"queue": "queue",
"user/db_input_loop_processor/1" : {
"step": 2
},
"user/db_input_loop_evaluator/1" : {
"threshold": 2
},
"user/block_input_loop_evaluator/1" : {
"threshold": 9
},
"user/integers_offsetter/1": {
"offset": 0
}
}
}
......@@ -64,3 +64,13 @@ class TestExperimentModeling:
error_map = experiment_model.check_all_blocks()
assert len(error_map) > 0
assert BLOCK_TO_CHANGE in error_map
def test_with_empty_blocks(self, test_prefix):
experiment = Asset(
test_prefix, AssetType.EXPERIMENT, "errors/user/two_loops/1/empty_blocks"
)
experiment_model = ExperimentModel()
experiment_model.load_experiment(experiment)
error_map = experiment_model.check_all_blocks()
assert len(error_map) == 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment