From 07aa7f7a05bd7e80213a316d22ecbb76644f86dd Mon Sep 17 00:00:00 2001 From: Sebastian Spreizer Date: Fri, 11 Oct 2019 14:38:14 +0200 Subject: [PATCH] Add get_data, get_input_data, get_output_data --- sumatra/projects.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/sumatra/projects.py b/sumatra/projects.py index 5c730c5a..36e4b6c9 100644 --- a/sumatra/projects.py +++ b/sumatra/projects.py @@ -316,7 +316,28 @@ def find_records(self, tags=None, reverse=False, parameters=None, *args, **kwarg records = [rec for rec in records if len(rec.parameters.diff(parameters)[-1]) == 0] return records - # def find_data() here? + def find_input_data(self, *args, **kwargs): + records = self.find_records(*args, **kwargs) + if len(records) == 0: return [] + input_data = [] + for record in records: + for input_file in record.input_data: + input_data.append(input_file) + return input_data + + def find_output_data(self, *args, **kwargs): + records = self.find_records(*args, **kwargs) + if (records) == 0: return [] + output_data = [] + for record in records: + for output_file in record.output_data: + output_data.append(output_file) + return output_data + + def find_data(self, *args, **kwargs): + input_data = self.find_input_data(*args, **kwargs) + output_data = self.find_output_data(*args, **kwargs) + return {'input_data': input_data, 'output_data': output_data} def format_records(self, format='text', mode='short', tags=None, reverse=False, *args, **kwargs): if format=='text' and mode=='short' and ('parameters' not in kwargs.keys()):