cdapython 2.0.10__tar.gz → 2.0.12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,7 @@
1
+ 2025-10-31: 2.0.12: standardize debug-layer SQL echo; adjust column\_values() to handle known pathologies
2
+
3
+ 2025-10-27: 2.0.11: _cough_ bugfix for previous
4
+
1
5
  2025-10-27: 2.0.10: integrate column\_values() parameter validation with shared validation library; expand support for column\_values( data\_source ) to accept list values in addition to single strings
2
6
 
3
7
  2025-10-22: 2.0.9: parametrize data\_source check in column\_values()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdapython
3
- Version: 2.0.10
3
+ Version: 2.0.12
4
4
  Summary: NCI CRDC CDA front-end user interface library
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.9,<4.0
@@ -885,6 +885,16 @@ def column_values(
885
885
  # Normalize sort_by case. Also, ':asc' is redundant: remove it (politely).
886
886
  sort_by = re.sub( r':asc$', r'', sort_by ).lower()
887
887
 
888
+ # Set default sort_by value.
889
+ if sort_by == '':
890
+ if return_data_as in [ '', 'dataframe', 'tsv' ]:
891
+ sort_by = 'count'
892
+ elif return_data_as in [ 'list' ]:
893
+ sort_by = 'value'
894
+ else:
895
+ log.error( f"Cannot identify default `sort_by` value for unexpected `return_data_as` value '{return_data_as}': please notify the CDA devs of this event." )
896
+ return
897
+
888
898
  #############################################################################################################################
889
899
  # Check in advance for columns flagged as high-overhead.
890
900
 
@@ -824,13 +824,15 @@ def get_data(
824
824
 
825
825
  next_result_batch = pd.json_normalize( api_response_object.to_dict()['result'] )
826
826
 
827
+ log.debug( f"/data/{table} endpoint query SQL:\n{api_response_object.to_dict()['query_sql']}" )
828
+
827
829
  # Add data from this page to our full result set.
828
830
 
829
831
  if not result_dataframe.empty and not next_result_batch.empty:
830
832
 
831
833
  # Silence a future deprecation warning about pd.concat and empty DataFrame columns.
832
834
  #
833
- # Possiby relevant note: never fill in missing numeric values with 0!
835
+ # Possibly relevant note: never fill in missing numeric values with 0!
834
836
 
835
837
  next_result_batch = next_result_batch.astype( result_dataframe.dtypes )
836
838
  result_dataframe = pd.concat( [result_dataframe, next_result_batch] )
@@ -634,13 +634,16 @@ def validate_parameter_values(
634
634
  'list': {
635
635
  '',
636
636
  'value',
637
+ 'value:asc',
637
638
  'value:desc'
638
639
  },
639
640
  'dataframe_or_tsv': {
640
641
  '',
641
642
  'count',
643
+ 'count:asc',
642
644
  'count:desc',
643
645
  'value',
646
+ 'value:asc',
644
647
  'value:desc'
645
648
  }
646
649
  }
@@ -653,13 +656,13 @@ def validate_parameter_values(
653
656
  # Restrict sorting options for lists.
654
657
  if sort_by == '':
655
658
  sort_by = 'value'
656
- elif sort_by not in allowed_sort_by_options['list']:
659
+ elif sort_by.lower() not in allowed_sort_by_options['list']:
657
660
  raise RuntimeError( f"return_data_as='list' can only be processed with sort_by='value' or sort_by='value:desc' (or omitting sort_by altogether). Please modify unsupported sort_by directive '{sort_by}' and try again." )
658
661
  else:
659
662
  # For TSV output files and DataFrames, we support more user-configurable options (defaulting to sort_by='count:desc'):
660
663
  if sort_by == '':
661
664
  sort_by = 'count:desc'
662
- elif sort_by not in allowed_sort_by_options['dataframe_or_tsv']:
665
+ elif sort_by.lower() not in allowed_sort_by_options['dataframe_or_tsv']:
663
666
  raise RuntimeError( f"unrecognized sort_by '{sort_by}'. Please use one of 'count', 'value', 'count:desc', 'value:desc', 'count:asc' or 'value:asc' (or omit the sort_by parameter altogether)." )
664
667
 
665
668
  elif sort_by is not None:
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "cdapython"
3
- version = "2.0.10"
3
+ version = "2.0.12"
4
4
  description = "NCI CRDC CDA front-end user interface library"
5
5
  authors = []
6
6
  readme = "README.md"
File without changes
File without changes