cdapython 2.1.0__tar.gz → 2.2.1__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
+ 2026-10-01: 2.2.1: fix help text typo for `column_values()`
2
+
3
+ 2026-08-25: 2.2.0: add support for harmonized controlled-vocabulary metadata retrieval (slims, synonyms, containing terms); see help text for the `add_extras` flag in the `get_data()` and `summarize()` functions
4
+
1
5
  2026-04-07: 2.1.0: add `search_terms` support; obsolesce `disease_slims` POC in deference to upcoming full version
2
6
 
3
7
  2025-12-09: 2.0.14: add sort postproc to POC `disease_slims` return column
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cdapython
3
- Version: 2.1.0
3
+ Version: 2.2.1
4
4
  Summary: NCI CRDC CDA front-end user interface library
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.9,<4.0
@@ -11,10 +11,11 @@ Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Classifier: Programming Language :: Python :: 3.13
13
13
  Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: Programming Language :: Python :: 3.15
14
15
  Requires-Dist: cda-client (>=2.1.0)
15
16
  Requires-Dist: pandas (>=2.2.3,<3.0.0)
16
17
  Requires-Dist: pyyaml (>=6.0.0)
17
- Requires-Dist: tabulate (>=0.9.0)
18
+ Requires-Dist: tabulate (>=0.10.0)
18
19
  Description-Content-Type: text/markdown
19
20
 
20
21
  # cdapython
@@ -1,5 +1,4 @@
1
- from cdapython.application_utilities import get_api_url, set_api_url
2
- from cdapython.discover import cda_functions, column_values, columns, release_metadata, tables
1
+ from cdapython.discover import cda_extra_metadata_columns, cda_functions, column_values, columns, get_api_url, release_metadata, set_api_url, tables
3
2
  from cdapython.summarize import expand_file_results, expand_subject_results, intersect_file_results, intersect_subject_results, summarize_files, summarize_subjects
4
3
  from cdapython.get_data import get_file_data, get_subject_data
5
4
 
@@ -8,7 +8,6 @@ import cda_client.api.columns.columns_endpoint_columns_get
8
8
  import cda_client.api.release_metadata.release_metadata_endpoint_release_metadata_get
9
9
  import cda_client.api.column_values.column_values_endpoint_column_values_column_post
10
10
 
11
- from cdapython.application_utilities import get_api_url
12
11
  from cda_client.errors import UnexpectedStatus
13
12
  from cdapython.logging_wrappers import get_logger
14
13
 
@@ -22,6 +21,47 @@ from cdapython.logging_wrappers import get_logger
22
21
  #############################################################################################################################
23
22
 
24
23
 
24
+ #############################################################################################################################
25
+ #
26
+ # get_api_url(): Return the current system URL for the CDA REST API.
27
+ #
28
+ #############################################################################################################################
29
+
30
+ def get_api_url():
31
+ """
32
+ Return the currently-set URL pointing to the CDA REST API.
33
+ """
34
+
35
+ # System default.
36
+ default_api_url = 'https://cda.datacommons.cancer.gov'
37
+
38
+ # Has the user set a non-default URL?
39
+ local_api_url = os.environ.get( '__CDA_API_URL' )
40
+
41
+ if local_api_url is not None and len( local_api_url ) > 0:
42
+ return local_api_url
43
+ else:
44
+ return default_api_url
45
+
46
+ #############################################################################################################################
47
+ #
48
+ # set_api_url(): Set the current system URL for the CDA REST API.
49
+ #
50
+ #############################################################################################################################
51
+
52
+ def set_api_url( new_api_url ):
53
+ """
54
+ Set the current system URL for the CDA REST API.
55
+ """
56
+
57
+ # Do some basic sanity checking.
58
+ if re.search( r'^https*:\/\/', new_api_url ) is None:
59
+ raise RuntimeError( 'set_api_url(): Only HTTP and HTTPS URLs are allowed.' )
60
+ elif len( new_api_url ) > 100:
61
+ raise RuntimeError( 'set_api_url(): Whatever that was, it wasn\'t the URL of the CDA REST API.' )
62
+
63
+ os.environ['__CDA_API_URL'] = new_api_url
64
+
25
65
  #############################################################################################################################
26
66
  #
27
67
  # cda_functions(): Return a list of user-facing cdapython functions useful for both scripting and interactive data sessions.
@@ -62,6 +102,7 @@ def cda_functions():
62
102
  'disable_file_logging',
63
103
  'get_api_url',
64
104
  'set_api_url',
105
+ 'cda_extra_metadata_columns',
65
106
  'cda_functions'
66
107
  ]
67
108
 
@@ -71,6 +112,24 @@ def cda_functions():
71
112
  #
72
113
  #############################################################################################################################
73
114
 
115
+ #############################################################################################################################
116
+ #
117
+ # cda_extra_metadata_columns(): Return a list of available metadata annotations that provide context for some harmonized CDA
118
+ # fields.
119
+ #
120
+ #############################################################################################################################
121
+
122
+ def cda_extra_metadata_columns():
123
+ # extra_metadata_columns is enumerated by cda_extra_metadata_columns() in desired column-display order for return_data_as='':
124
+ extra_metadata_columns = [ 'synonym_terms', 'slim_terms', 'containing_terms' ]
125
+ return extra_metadata_columns
126
+
127
+ #############################################################################################################################
128
+ #
129
+ # END cda_extra_metadata_columns()
130
+ #
131
+ #############################################################################################################################
132
+
74
133
  #############################################################################################################################
75
134
  #
76
135
  # tables(): Return a list of all searchable CDA data tables.
@@ -789,7 +848,7 @@ def column_values(
789
848
 
790
849
  data_source ( string; optional ):
791
850
  Restrict returned values to the given upstream data source. Current
792
- valid values are 'GC', 'GDC', 'PDC', 'IDC' and 'ICDC'.
851
+ valid values are 'CTDC', 'GC', 'GDC', 'PDC', 'IDC' and 'ICDC'.
793
852
  Defaults to None (no filter).
794
853
 
795
854
  force( boolean; optional ):
@@ -876,6 +935,7 @@ def column_values(
876
935
  include_external_refs=None,
877
936
  return_data_as=return_data_as,
878
937
  output_file=output_file,
938
+ add_extras=None,
879
939
  sort_by=sort_by,
880
940
  log=log
881
941
  )
@@ -937,7 +997,7 @@ def column_values(
937
997
 
938
998
  # Warn the user if an override hasn't been requested.
939
999
  if not force and column in expensive_columns:
940
- log.warning( f"'{column}' has a very large number of values; retrieval is blocked by default. To perform this query, use column_values( ..., 'force=True' )." )
1000
+ log.warning( f"'{column}' has a very large number of values; retrieval is blocked by default. To perform this query, use column_values( ..., force=True )." )
941
1001
  return
942
1002
 
943
1003
  #############################################################################################################################