terra_ui_components 0.0.103__py3-none-any.whl → 0.0.114__py3-none-any.whl

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.

Potentially problematic release.


This version of terra_ui_components might be problematic. Click here for more details.

@@ -10,4 +10,7 @@ from .data_subsetter import TerraDataSubsetter
10
10
  from .data_subsetter_history import TerraDataSubsetterHistory
11
11
  from .time_average_map import TerraTimeAverageMap
12
12
  from .plot_toolbar import TerraPlotToolbar
13
- __all__ = ["TerraBaseWidget", "TerraDateRangeSlider", "TerraTimeSeries", "TerraLogin", "TerraDialog", "TerraDatePicker", "TerraDataRods", "TerraAccordion", "TerraDataSubsetter", "TerraDataSubsetterHistory", "TerraTimeAverageMap", "TerraPlotToolbar"]
13
+ from .data_access import TerraDataAccess
14
+ from .slider import TerraSlider
15
+ from .input import TerraInput
16
+ __all__ = ["TerraBaseWidget", "TerraDateRangeSlider", "TerraTimeSeries", "TerraLogin", "TerraDialog", "TerraDatePicker", "TerraDataRods", "TerraAccordion", "TerraDataSubsetter", "TerraDataSubsetterHistory", "TerraTimeAverageMap", "TerraPlotToolbar", "TerraDataAccess", "TerraSlider", "TerraInput"]
@@ -16,12 +16,12 @@ class TerraBaseWidget(anywidget.AnyWidget):
16
16
  return f"""
17
17
  const terraStyles = document.createElement('link')
18
18
  terraStyles.rel = 'stylesheet'
19
- terraStyles.href = 'https://cdn.jsdelivr.net/npm/@nasa-terra/components@0.0.103/cdn/themes/horizon.css'
19
+ terraStyles.href = 'https://cdn.jsdelivr.net/npm/@nasa-terra/components@0.0.114/cdn/themes/horizon.css'
20
20
  //terraStyles.href = "https://localhost:4000/dist/themes/horizon.css"
21
21
  document.head.appendChild(terraStyles)
22
22
 
23
23
  const terraAutoloader = document.createElement('script')
24
- terraAutoloader.src = "https://cdn.jsdelivr.net/npm/@nasa-terra/components@0.0.103/cdn/terra-ui-components-autoloader.js"
24
+ terraAutoloader.src = "https://cdn.jsdelivr.net/npm/@nasa-terra/components@0.0.114/cdn/terra-ui-components-autoloader.js"
25
25
  //terraAutoloader.src = "https://localhost:4000/dist/terra-ui-components-autoloader.js"
26
26
  terraAutoloader.type = 'module'
27
27
  document.head.appendChild(terraAutoloader)
@@ -0,0 +1,3 @@
1
+ from .data_access import TerraDataAccess
2
+
3
+ __all__ = ["TerraDataAccess"]
@@ -0,0 +1,50 @@
1
+ import importlib.metadata
2
+ import traitlets
3
+ from ..base import TerraBaseWidget
4
+
5
+ try:
6
+ __version__ = importlib.metadata.version("terra_data_access")
7
+ except importlib.metadata.PackageNotFoundError:
8
+ __version__ = "unknown"
9
+
10
+
11
+ class TerraDataAccess(TerraBaseWidget):
12
+ _esm = TerraBaseWidget.get_autoloader() + """
13
+ function render({ model, el }) {
14
+ // create an instance of the component
15
+ let component = document.createElement('terra-data-access')
16
+
17
+ /**
18
+ * Set initial property values
19
+ * NOTE: In reality, we won't need to have the ability to set EVERY property in a Jupyter Notebook, feel free to remove the ones that don't make sense
20
+ *
21
+ * model.get() pulls from the Jupyter notebooks state. We'll use the state to set the initial value for each property
22
+ */
23
+ component.attr = model.get('attr')
24
+
25
+ /**
26
+ * add the component to the cell
27
+ * it should now be visible in the notebook!
28
+ */
29
+ el.appendChild(component)
30
+
31
+
32
+ /**
33
+ * Set up property change handlers
34
+ * This way if someone in the Jupyter Notebook changes the property externally, we reflect the change
35
+ * back to the component.
36
+ *
37
+ * If this isn't here, the component can't be changed after it's initial render
38
+ */
39
+ model.on('change:attr', () => {
40
+ component.attr = model.get('attr')
41
+ })
42
+ }
43
+
44
+ export default { render };
45
+ """
46
+
47
+ # Component properties
48
+ # While we have properties in the component, we also need to tell Python about them as well.
49
+ # Again, you don't technically need all these. If Jupyter Notebooks don't need access to them, you can remove them from here
50
+ attr = traitlets.Unicode('').tag(sync=True)
@@ -0,0 +1,3 @@
1
+ from .input import TerraInput
2
+
3
+ __all__ = ["TerraInput"]
@@ -0,0 +1,50 @@
1
+ import importlib.metadata
2
+ import traitlets
3
+ from ..base import TerraBaseWidget
4
+
5
+ try:
6
+ __version__ = importlib.metadata.version("terra_input")
7
+ except importlib.metadata.PackageNotFoundError:
8
+ __version__ = "unknown"
9
+
10
+
11
+ class TerraInput(TerraBaseWidget):
12
+ _esm = TerraBaseWidget.get_autoloader() + """
13
+ function render({ model, el }) {
14
+ // create an instance of the component
15
+ let component = document.createElement('terra-input')
16
+
17
+ /**
18
+ * Set initial property values
19
+ * NOTE: In reality, we won't need to have the ability to set EVERY property in a Jupyter Notebook, feel free to remove the ones that don't make sense
20
+ *
21
+ * model.get() pulls from the Jupyter notebooks state. We'll use the state to set the initial value for each property
22
+ */
23
+ component.attr = model.get('attr')
24
+
25
+ /**
26
+ * add the component to the cell
27
+ * it should now be visible in the notebook!
28
+ */
29
+ el.appendChild(component)
30
+
31
+
32
+ /**
33
+ * Set up property change handlers
34
+ * This way if someone in the Jupyter Notebook changes the property externally, we reflect the change
35
+ * back to the component.
36
+ *
37
+ * If this isn't here, the component can't be changed after it's initial render
38
+ */
39
+ model.on('change:attr', () => {
40
+ component.attr = model.get('attr')
41
+ })
42
+ }
43
+
44
+ export default { render };
45
+ """
46
+
47
+ # Component properties
48
+ # While we have properties in the component, we also need to tell Python about them as well.
49
+ # Again, you don't technically need all these. If Jupyter Notebooks don't need access to them, you can remove them from here
50
+ attr = traitlets.Unicode('').tag(sync=True)
@@ -0,0 +1,3 @@
1
+ from .slider import TerraSlider
2
+
3
+ __all__ = ["TerraSlider"]
@@ -0,0 +1,50 @@
1
+ import importlib.metadata
2
+ import traitlets
3
+ from ..base import TerraBaseWidget
4
+
5
+ try:
6
+ __version__ = importlib.metadata.version("terra_slider")
7
+ except importlib.metadata.PackageNotFoundError:
8
+ __version__ = "unknown"
9
+
10
+
11
+ class TerraSlider(TerraBaseWidget):
12
+ _esm = TerraBaseWidget.get_autoloader() + """
13
+ function render({ model, el }) {
14
+ // create an instance of the component
15
+ let component = document.createElement('terra-slider')
16
+
17
+ /**
18
+ * Set initial property values
19
+ * NOTE: In reality, we won't need to have the ability to set EVERY property in a Jupyter Notebook, feel free to remove the ones that don't make sense
20
+ *
21
+ * model.get() pulls from the Jupyter notebooks state. We'll use the state to set the initial value for each property
22
+ */
23
+ component.attr = model.get('attr')
24
+
25
+ /**
26
+ * add the component to the cell
27
+ * it should now be visible in the notebook!
28
+ */
29
+ el.appendChild(component)
30
+
31
+
32
+ /**
33
+ * Set up property change handlers
34
+ * This way if someone in the Jupyter Notebook changes the property externally, we reflect the change
35
+ * back to the component.
36
+ *
37
+ * If this isn't here, the component can't be changed after it's initial render
38
+ */
39
+ model.on('change:attr', () => {
40
+ component.attr = model.get('attr')
41
+ })
42
+ }
43
+
44
+ export default { render };
45
+ """
46
+
47
+ # Component properties
48
+ # While we have properties in the component, we also need to tell Python about them as well.
49
+ # Again, you don't technically need all these. If Jupyter Notebooks don't need access to them, you can remove them from here
50
+ attr = traitlets.Unicode('').tag(sync=True)
@@ -1,4 +1,5 @@
1
1
  import importlib.metadata
2
+ import base64
2
3
  import traitlets
3
4
  from ..base import TerraBaseWidget
4
5
 
@@ -25,6 +26,7 @@ class TerraTimeAverageMap(TerraBaseWidget):
25
26
  component.startDate = model.get('startDate')
26
27
  component.endDate = model.get('endDate')
27
28
  component.location = model.get('location')
29
+ component.bearerToken = model.get('bearerToken')
28
30
  component.long_name = model.get('long_name')
29
31
 
30
32
  /**
@@ -56,6 +58,9 @@ class TerraTimeAverageMap(TerraBaseWidget):
56
58
  model.on('change:location', () => {
57
59
  component.location = model.get('location')
58
60
  })
61
+ model.on('change:bearerToken', () => {
62
+ component.bearerToken = model.get('bearerToken')
63
+ })
59
64
  model.on('change:long_name', () => {
60
65
  component.long_name = model.get('long_name')
61
66
  })
@@ -64,7 +69,7 @@ class TerraTimeAverageMap(TerraBaseWidget):
64
69
  * Add event listeners.
65
70
  * These are used to communicate back to the Jupyter notebook
66
71
  */
67
- component.addEventListener('terra-time-average-map-data-change', (e) => {
72
+ component.addEventListener('terra-time-average-map-data-change', async (e) => {
68
73
  // hide the loading overlay, if it exists
69
74
  const loadingOverlay = document.getElementById('jupyterlite-loading-overlay')
70
75
 
@@ -72,9 +77,34 @@ class TerraTimeAverageMap(TerraBaseWidget):
72
77
  loadingOverlay.remove()
73
78
  }
74
79
 
75
- console.log('caught the event!! ', e)
80
+ console.log('time-average-map: finished mapping GeoTIFF. Sending GeoTIFF to Python... ', e)
81
+
82
+ // We can't send a JS Blob to Python, so we'll instead need to convert it to bytes
83
+ const blob = e.detail.data
84
+
85
+ if (blob instanceof Blob) {
86
+ const arrayBuffer = await blob.arrayBuffer()
87
+ const uint8Array = new Uint8Array(arrayBuffer)
88
+
89
+ // Convert to base64 string for transmission to Python
90
+ // Use chunked conversion to avoid "Maximum call stack size exceeded" for large files
91
+ const chunkSize = 8192
92
+ let binaryString = ''
93
+
94
+ for (let i = 0; i < uint8Array.length; i += chunkSize) {
95
+ const chunk = uint8Array.subarray(i, i + chunkSize)
96
+ binaryString += String.fromCharCode(...chunk)
97
+ }
76
98
 
77
- model.set('data', e.detail.data.data)
99
+ const base64String = btoa(binaryString)
100
+ model.set('_data_base64', base64String)
101
+
102
+ console.log('time-average-map: sent base64 encoded GeoTIFF to Python ', base64String)
103
+ } else {
104
+ console.error('time-average-map: failed to send GeoTIFF to Python. Unknown data type', blob)
105
+ model.set('_data_base64', '')
106
+ }
107
+
78
108
  model.save_changes()
79
109
  })
80
110
  }
@@ -90,6 +120,16 @@ class TerraTimeAverageMap(TerraBaseWidget):
90
120
  startDate = traitlets.Unicode('').tag(sync=True)
91
121
  endDate = traitlets.Unicode('').tag(sync=True)
92
122
  location = traitlets.Unicode('').tag(sync=True)
123
+ bearerToken = traitlets.Unicode('').tag(sync=True)
93
124
  long_name = traitlets.Unicode('').tag(sync=True)
94
- data = traitlets.List(trait=traitlets.Dict(),
95
- default_value=[]).tag(sync=True)
125
+ _data_base64 = traitlets.Unicode('').tag(sync=True)
126
+
127
+ @property
128
+ def data(self):
129
+ """Get the binary data as bytes, decoded from base64."""
130
+ if not self._data_base64:
131
+ return b''
132
+ try:
133
+ return base64.b64decode(self._data_base64)
134
+ except Exception:
135
+ return b''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: terra_ui_components
3
- Version: 0.0.103
3
+ Version: 0.0.114
4
4
  Summary: NASA Terra UI Components Library
5
5
  License-File: LICENSE.md
6
6
  Requires-Python: >=3.8
@@ -1,10 +1,12 @@
1
1
  terra_ui_components/README.md,sha256=lBRXP8aio8W0AqDiXL9hkgGlPKfPTELiXZflujVT6BY,198
2
- terra_ui_components/__init__.py,sha256=Af9Hf6jOQBv2IBFJX8ZUVTKmzpAKCcz0oT3XIF7yCN8,757
3
- terra_ui_components/base.py,sha256=6Ibaqda0xzPDOdMcMMUNnjubyI2fJLEIxfFiNw_QZg0,1226
2
+ terra_ui_components/__init__.py,sha256=wrNVE-uJ_UEvl8bkdbaqYN_c7dAZ_IEi5j0r5IMWbAo,908
3
+ terra_ui_components/base.py,sha256=tFhX2ezbfVSCCQcIh7-uhFcoWxBs-Z1SJHE_i6e-WYE,1226
4
4
  terra_ui_components/accordion/__init__.py,sha256=xruOtrVmmzFKacs2B_lKpEnDh2PbBq-HUKCdceRNboU,67
5
5
  terra_ui_components/accordion/accordion.py,sha256=3duUmiJ5DTMYfzMJmra8pt0CXXcOkcbY-aAb7-PVCIs,1789
6
6
  terra_ui_components/browse_variables/__init__.py,sha256=JfrTDLSbAecttohBx_OuEC1qT-LoqGO4egStvlJY1Os,86
7
7
  terra_ui_components/browse_variables/browse_variables.py,sha256=x5DwenujlHrfzBLB29bq-b6iJtWq1AG1wOhPrDyFtIQ,1827
8
+ terra_ui_components/data_access/__init__.py,sha256=MGAx9TqVj5ydGNY_ZMrboGqBobPKbQ7kfjurotE4JtA,71
9
+ terra_ui_components/data_access/data_access.py,sha256=FOqsMhyXiff6F2aZ0SKrl2FQMZxSJdmDuZ0t-C_GwwI,1794
8
10
  terra_ui_components/data_rods/__init__.py,sha256=lr-Y19evMVuC88Slu7P2sOUvsSq-BA7WUC_u_iB0V3A,65
9
11
  terra_ui_components/data_rods/data_rods.py,sha256=Ot7TJQk6JgCkCoERle27RIq4lOgpfmHJNkqBgo8bbAA,1788
10
12
  terra_ui_components/data_subsetter/__init__.py,sha256=iBX8RRg_T5Qix4hWgfrHcnjkx3i11xWgYAlj2g6wfx8,80
@@ -17,17 +19,21 @@ terra_ui_components/date_range_slider/__init__.py,sha256=8rFfB6ilThf7fvuGsFZ8w4n
17
19
  terra_ui_components/date_range_slider/date_range_slider.py,sha256=kE3vMFV-CZ45n8F48qE0Vrs3taPClxSrZRy8ffOEbp0,3511
18
20
  terra_ui_components/dialog/__init__.py,sha256=6H2fOO3FawjPtowliaCxyneITsS4MXZy1YJYWgVKFCY,58
19
21
  terra_ui_components/dialog/dialog.py,sha256=GRKktKwUpkSAE7gl8-ivZ5O18iK9oHEb2m7vKjxJIR0,1780
22
+ terra_ui_components/input/__init__.py,sha256=UIEQqNyGMwv-BkeGqVjD_A_nXhiS5Tpv6WxBD7aZibk,55
23
+ terra_ui_components/input/input.py,sha256=JTsFjXMO9jifhisaQ2fLz7OFsTxrv_4U4AIMIXbxewU,1777
20
24
  terra_ui_components/login/__init__.py,sha256=R9Rn-D770XK5bIsVdQ4EwiafuISYUxYpq15zxJeyk-A,55
21
25
  terra_ui_components/login/login.py,sha256=VkFUwoLKsoPq6yab5pF2Dir_NBh3oETQlnkFFCTAGyo,2682
22
26
  terra_ui_components/plot_toolbar/__init__.py,sha256=rlk9bxXuNo75bIfZu91dDJupiFVOUpPzuUrMJZ5318E,74
23
27
  terra_ui_components/plot_toolbar/plot_toolbar.py,sha256=VCKKZi3hD0qDAG6-exoU1hasWyG4r3A2yPo3TQ8PVoI,1797
28
+ terra_ui_components/slider/__init__.py,sha256=owsrHpY0ClCzEYWwhEnF3DFz1iKdCZ9GDKaoYV-zRb0,58
29
+ terra_ui_components/slider/slider.py,sha256=gw8jim8aBlXZgQ0l_lF4ng79KJuseyBAFmAn9JIubyo,1780
24
30
  terra_ui_components/time_average_map/__init__.py,sha256=l3UBuLYIj-5-HQcugO8pRtTynkhLTD1ZlxM_Gf84t5o,84
25
- terra_ui_components/time_average_map/time_average_map.py,sha256=r-yK4Gh2vEL9tVQE6t6gBisa0pWTjyvodKjmOK-wu_Q,3611
31
+ terra_ui_components/time_average_map/time_average_map.py,sha256=EOcUeV57tmeHlEcmMm1mPmEJeYXEGzACL3J6bDaWjFQ,5318
26
32
  terra_ui_components/time_series/__init__.py,sha256=uXQun39vOajxJjfOIPC4W-909Sb8QpIwatr86B8iDMA,71
27
33
  terra_ui_components/time_series/time_series.py,sha256=M29nbYf-wmsxyu7WgeQu-pejF598zXuBd9MwAEIW704,3833
28
34
  terra_ui_components/variable_keyword_search/__init__.py,sha256=yjNToGluREKDD4UbkIOROSdlCC4jO6sgHA741OEwVdk,107
29
35
  terra_ui_components/variable_keyword_search/variable_keyword_search.py,sha256=D_jT-FAu0fubKsC0ttK_XF80ExehLnwLyvSLpVVik_o,3677
30
- terra_ui_components-0.0.103.dist-info/METADATA,sha256=BT5nYCtmrM8XOzdPwwk-lnhD3wgvz-_jqfUCsjCUQ1Y,3091
31
- terra_ui_components-0.0.103.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
32
- terra_ui_components-0.0.103.dist-info/licenses/LICENSE.md,sha256=rJ_6y_yHe29CU6SBs8DtutDAGaw1BqO1FBWzNvSgwFQ,1065
33
- terra_ui_components-0.0.103.dist-info/RECORD,,
36
+ terra_ui_components-0.0.114.dist-info/METADATA,sha256=9oOQQ9gXk2uTiHta5JRjomVl-_3QKUkQwGs9FZC24sA,3091
37
+ terra_ui_components-0.0.114.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ terra_ui_components-0.0.114.dist-info/licenses/LICENSE.md,sha256=rJ_6y_yHe29CU6SBs8DtutDAGaw1BqO1FBWzNvSgwFQ,1065
39
+ terra_ui_components-0.0.114.dist-info/RECORD,,