@@ -403,7 +403,28 @@ def iter_parse_json_params(
403403 verbose : bool = False ,
404404 ** match_params
405405 ):
406+ """
407+ Iterate over all Records in a DalResult and return parsed json parameters.
408+
409+ Parameters
410+ ----------
411+ colname : str, optional
412+ The column containing JSON to be parsed, by default "cloud_access"
413+ key : str, optional
414+ The key to filter JSON results by, by default "aws"
415+ verbose : bool, optional
416+ Whether to print progress and errors, by default False
417+ **match_params : str, optional
418+ Any further parameters to match on.
406419
420+ Returns
421+ -------
422+ astropy.Table
423+ A table containing the JSON parameters separated into columns, each
424+ row corresponding to a matching JSON entry for each DataLinkRecord
425+ for each row of the original DalResult.
426+
427+ """
407428 for irow , record in enumerate (self ):
408429 access_points = record .parse_json_params (
409430 colname = colname ,
@@ -427,9 +448,55 @@ def iter_get_cloud_params(
427448 verbose : bool = False ,
428449 ** match_params
429450 ):
430- for irow , record in enumerate (self ):
451+ """
452+ Iterate over all Records in a DalResult and return parsed cloud parameters.
453+
454+ Parameters
455+ ----------
456+ colname : str, optional
457+ The column containing JSON to be parsed, by default "cloud_access"
458+ provider : str, optional
459+ The key to filter JSON results by, by default "aws"
460+ verbose : bool, optional
461+ Whether to print progress and errors, by default False
462+ **match_params : str, optional
463+ Any further parameters to match on.
464+
465+ Returns
466+ -------
467+ astropy.Table
468+ A table containing the JSON parameters separated into columns, each
469+ row corresponding to matching JSON entries from each Record.
470+
471+ """
472+ for irow , dl_results in enumerate (self .iter_datalinks ()):
473+
474+ products = dl_results .bysemantics ("#this" )
475+
476+ for jrow , row in enumerate (products ):
477+ # if no colname column, there is nothing to do
478+ try :
479+ access_points = row .parse_json_params (
480+ colname = colname ,
481+ key = provider ,
482+ verbose = verbose ,
483+ ** match_params
484+ )
485+ access_points .add_column ([jrow ]* len (access_points ), name = "datalink_row" , index = 0 )
486+ if jrow == 0 :
487+ new_dl_table = access_points
488+ else :
489+ for row in access_points .iterrows ():
490+ new_dl_table .add_row (row )
491+ except KeyError :
492+ # no json column, continue
493+ if verbose :
494+ print (f'No column { colname } found for row { irow } , datalink { jrow } ' )
495+ new_dl_table = TableElement (VOTableFile ()).to_table ()
496+ continue
497+
431498 # do the json parsing
432- cloud_params = record . get_cloud_params ( colname , provider , verbose , ** match_params )
499+ cloud_params = access_points
433500 cloud_params .add_column ([irow ]* len (cloud_params ), name = "record_row" , index = 0 )
434501 if irow == 0 :
435502 new_table = cloud_params
@@ -498,16 +565,20 @@ def parse_json_params(
498565
499566 Parameters
500567 ----------
501- colname: str
502- name of column to search in
503- provider: str, optional
504- name of data provider: only 'aws' is presently supported.
505- verbose: bool
506- If True, print progress and debug text.
507-
508- Return
509- ------
510- A dict or a list of dict of parameters for every row in products
568+ colname : str, optional
569+ The column containing JSON to be parsed, by default "cloud_access"
570+ key : str, optional
571+ The key to filter JSON results by, by default "aws"
572+ verbose : bool, optional
573+ Whether to print progress and errors, by default False
574+ **match_params : str, optional
575+ Any further parameters to match on.
576+
577+ Returns
578+ -------
579+ astropy.Table
580+ A table containing the JSON parameters separated into columns, each
581+ row representing a matching JSON entry.
511582
512583 """
513584 import json
@@ -548,7 +619,7 @@ def parse_json_params(
548619 return new_table
549620
550621 def get_cloud_params (self , colname = "cloud_access" , provider = "aws" , verbose = False , ** match_params ):
551- """Parse information stored as JSON by key
622+ """Parse cloud information stored as JSON by provider
552623
553624 Parameters
554625 ----------
@@ -558,10 +629,13 @@ def get_cloud_params(self, colname="cloud_access", provider="aws", verbose=False
558629 name of data provider: only 'aws' is presently supported.
559630 verbose: bool
560631 If True, print progress and debug text.
632+ **match_params
561633
562634 Return
563635 ------
564- An astropy Table with parameters for every row in the datalinks
636+ astropy.Table
637+ A table containing the JSON parameters separated into columns,
638+ each row being a unique JSON entry and/or from a different DatalinkRecord.
565639
566640 """
567641 dl_results = self .getdatalink ()
0 commit comments