From e644a74ee525987c5543bc4f86de0cf2a9be50b6 Mon Sep 17 00:00:00 2001 From: Denys SAVCHENKO Date: Tue, 27 Aug 2024 11:13:07 +0200 Subject: [PATCH] do not string-encode parameter list --- cdci_data_analysis/analysis/instrument.py | 6 +++--- cdci_data_analysis/analysis/queries.py | 8 ++++---- cdci_data_analysis/flask_app/dispatcher_query.py | 6 +++--- .../plugins/dummy_plugin/data_server_dispatcher.py | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cdci_data_analysis/analysis/instrument.py b/cdci_data_analysis/analysis/instrument.py index 619c70f4..ebf8ce2b 100644 --- a/cdci_data_analysis/analysis/instrument.py +++ b/cdci_data_analysis/analysis/instrument.py @@ -435,7 +435,7 @@ def run_query(self, product_type, job.set_done() if query_out.status_dictionary['status'] == 0: query_out.set_done(message='dry-run',job_status=job.status) - query_out.set_instrument_parameters(self.get_parameters_list_as_json(prod_name=product_type)) + query_out.set_instrument_parameters(self.get_parameters_list_jsonifiable(prod_name=product_type)) else: if query_out.status_dictionary['status'] == 0: query_out = QueryOutput() @@ -593,7 +593,7 @@ def show_parameters_list(self): _query.show_parameters_list() print("-------------") - def get_parameters_list_as_json(self, add_src_query=True, add_instr_query=True, prod_name=None): + def get_parameters_list_jsonifiable(self, add_src_query=True, add_instr_query=True, prod_name=None): l=[{'instrumet':self.name}] l.append({'prod_dict':self.query_dictionary}) @@ -608,7 +608,7 @@ def get_parameters_list_as_json(self, add_src_query=True, add_instr_query=True, if isinstance(_query, ProductQuery) and prod_name is not None and _query.name!=self.query_dictionary[prod_name]: continue - l.append(_query.get_parameters_list_as_json(prod_dict=self.query_dictionary)) + l.append(_query.get_parameters_list_jsonifiable(prod_dict=self.query_dictionary)) return l diff --git a/cdci_data_analysis/analysis/queries.py b/cdci_data_analysis/analysis/queries.py index 8db31212..5a368b62 100644 --- a/cdci_data_analysis/analysis/queries.py +++ b/cdci_data_analysis/analysis/queries.py @@ -275,13 +275,13 @@ def print_form_dictionary_list(self,l): else: return l - def get_parameters_list_as_json(self,**kwargs): + def get_parameters_list_jsonifiable(self,**kwargs): l=[ {'query_name':self.name}] for par in self._parameters_list: l.extend(par.reprJSONifiable()) l1 = self._remove_duplicates_from_par_list(l) - return json.dumps(l1) + return l1 # Check if the given query cn be executed given a list of roles extracted from the token def check_query_roles(self, roles, par_dic): @@ -385,7 +385,7 @@ def get_data_server_query(self,instrument,config=None,**kwargs): traceback.print_stack() raise RuntimeError(f'{self}: get_data_server_query needs to be implemented in derived class') - def get_parameters_list_as_json(self, prod_dict=None): + def get_parameters_list_jsonifiable(self, prod_dict=None): l=[ {'query_name':self.name}] prod_name=None @@ -402,7 +402,7 @@ def get_parameters_list_as_json(self, prod_dict=None): l.extend(par.reprJSONifiable()) l1 = self._remove_duplicates_from_par_list(l) - return json.dumps(l1) + return l1 def get_prod_by_name(self,name): return self.query_prod_list.get_prod_by_name(name) diff --git a/cdci_data_analysis/flask_app/dispatcher_query.py b/cdci_data_analysis/flask_app/dispatcher_query.py index cfdf533e..2fa03cc0 100644 --- a/cdci_data_analysis/flask_app/dispatcher_query.py +++ b/cdci_data_analysis/flask_app/dispatcher_query.py @@ -1161,17 +1161,17 @@ def get_meta_data(self, meta_name=None): else: prod_name = None if hasattr(self, 'instrument'): - l.append(self.instrument.get_parameters_list_as_json(prod_name=prod_name)) + l.append(self.instrument.get_parameters_list_jsonifiable(prod_name=prod_name)) src_query.show_parameters_list() else: l = ['instrument not recognized'] if meta_name == 'src_query': - l = [src_query.get_parameters_list_as_json()] + l = [src_query.get_parameters_list_jsonifiable()] src_query.show_parameters_list() if meta_name == 'instrument': - l = [self.instrument.get_parameters_list_as_json()] + l = [self.instrument.get_parameters_list_jsonifiable()] self.instrument.show_parameters_list() return jsonify(l) diff --git a/cdci_data_analysis/plugins/dummy_plugin/data_server_dispatcher.py b/cdci_data_analysis/plugins/dummy_plugin/data_server_dispatcher.py index cce154b8..63dbcf9a 100644 --- a/cdci_data_analysis/plugins/dummy_plugin/data_server_dispatcher.py +++ b/cdci_data_analysis/plugins/dummy_plugin/data_server_dispatcher.py @@ -422,7 +422,7 @@ def get_dummy_products(self, instrument, config=None, **kwargs): # create dummy NumpyDataProduct meta_data = {'product': 'mosaic', 'instrument': 'empty', 'src_name': '', - 'query_parameters': self.get_parameters_list_as_json()} + 'query_parameters': self.get_parameters_list_jsonifiable()} ima = NumpyDataUnit(np.zeros((100, 100)), hdu_type='image') data = NumpyDataProduct(data_unit=ima)