Skip to content

Commit

Permalink
Add dict property to Params class
Browse files Browse the repository at this point in the history
This property returns the data in the form of a dictionary that is
acceptable by the `ConfigTemplate.render` method
  • Loading branch information
dileep-kishore committed Oct 8, 2018
1 parent f27e4a9 commit 63e973e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions mindpipe/config/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,24 @@ def verify_io(self) -> None:
if not elem.location.is_absolute():
raise ValueError("All the output objects do not have absolute paths")

@property
def dict(self) -> Dict[str, Any]:
"""
Return data as a dictionary
Returns
-------
Dict[str, Any]
The data stored return as a dictionary
"""
self.verify_io()
data: Dict[str, Any] = dict()
data["input"] = {elem.datatype: str(elem.location) for elem in self.input}
data["output"] = {elem.datatype: str(elem.location) for elem in self.output}
data["output_dir"] = self.output_location
for process_params in self.parameters:
data[process_params.process] = process_params.params
return data


class ParamsSet(collections.Set):
Expand Down

0 comments on commit 63e973e

Please sign in to comment.