Skip to content

Commit

Permalink
do not string-encode parameter list
Browse files Browse the repository at this point in the history
  • Loading branch information
dsavchenko committed Aug 27, 2024
1 parent e164030 commit e644a74
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions cdci_data_analysis/analysis/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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})
Expand All @@ -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

Expand Down
8 changes: 4 additions & 4 deletions cdci_data_analysis/analysis/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions cdci_data_analysis/flask_app/dispatcher_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e644a74

Please sign in to comment.