cubevis 0.5.18__py3-none-any.whl → 0.5.19__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 cubevis might be problematic. Click here for more details.
- cubevis/__version__.py +1 -1
- cubevis/private/apps/_createmask.py +2 -2
- cubevis/private/apps/_createregion.py +2 -2
- cubevis/private/apps/_interactiveclean.mustache +13 -4
- cubevis/private/apps/_interactiveclean.py +13 -4
- cubevis/toolbox/_cube.py +2 -2
- cubevis/utils/__init__.py +1 -14
- cubevis/utils/_jupyter.py +92 -0
- {cubevis-0.5.18.dist-info → cubevis-0.5.19.dist-info}/METADATA +1 -1
- {cubevis-0.5.18.dist-info → cubevis-0.5.19.dist-info}/RECORD +12 -11
- {cubevis-0.5.18.dist-info → cubevis-0.5.19.dist-info}/WHEEL +0 -0
- {cubevis-0.5.18.dist-info → cubevis-0.5.19.dist-info}/licenses/LICENSE +0 -0
cubevis/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.5.
|
|
1
|
+
__version__ = '0.5.19'
|
|
@@ -41,7 +41,7 @@ from bokeh.io import reset_output as reset_bokeh_output
|
|
|
41
41
|
from bokeh.io import output_notebook
|
|
42
42
|
from bokeh.models.dom import HTML
|
|
43
43
|
from bokeh.models.ui.tooltips import Tooltip
|
|
44
|
-
from cubevis.utils import resource_manager, reset_resource_manager,
|
|
44
|
+
from cubevis.utils import resource_manager, reset_resource_manager, is_interactive_jupyter
|
|
45
45
|
from cubevis.data import casaimage
|
|
46
46
|
from cubevis.bokeh.models import TipButton, Tip
|
|
47
47
|
from cubevis.utils import ContextMgrChain as CMC
|
|
@@ -395,7 +395,7 @@ class CreateMask:
|
|
|
395
395
|
itergroups[document._casa_image_name].active = document._casa_last_control_tab''' ) )
|
|
396
396
|
|
|
397
397
|
# Change display type depending on runtime environment
|
|
398
|
-
if
|
|
398
|
+
if is_interactive_jupyter( ):
|
|
399
399
|
output_notebook()
|
|
400
400
|
else:
|
|
401
401
|
### Directory is created when an HTTP server is running
|
|
@@ -41,7 +41,7 @@ from bokeh.io import curdoc
|
|
|
41
41
|
from bokeh.io import reset_output as reset_bokeh_output
|
|
42
42
|
from bokeh.models.dom import HTML
|
|
43
43
|
from bokeh.models.ui.tooltips import Tooltip
|
|
44
|
-
from cubevis.utils import resource_manager, reset_resource_manager,
|
|
44
|
+
from cubevis.utils import resource_manager, reset_resource_manager, is_interactive_jupyter
|
|
45
45
|
from cubevis.data import casaimage
|
|
46
46
|
from cubevis.bokeh.models import TipButton, Tip
|
|
47
47
|
from cubevis.utils import ContextMgrChain as CMC
|
|
@@ -448,7 +448,7 @@ class CreateRegion:
|
|
|
448
448
|
itergroups[document._casa_image_name].active = document._casa_last_control_tab''' ) )
|
|
449
449
|
|
|
450
450
|
# Change display type depending on runtime environment
|
|
451
|
-
if
|
|
451
|
+
if is_interactive_jupyter( ):
|
|
452
452
|
output_notebook()
|
|
453
453
|
else:
|
|
454
454
|
### Directory is created when an HTTP server is running
|
|
@@ -54,7 +54,7 @@ from bokeh.models.dom import HTML
|
|
|
54
54
|
|
|
55
55
|
from bokeh.models.ui.tooltips import Tooltip
|
|
56
56
|
from cubevis.bokeh.models import TipButton, Tip, EvTextInput
|
|
57
|
-
from cubevis.utils import resource_manager, reset_resource_manager,
|
|
57
|
+
from cubevis.utils import resource_manager, reset_resource_manager, is_interactive_jupyter, find_pkg, load_pkg
|
|
58
58
|
from cubevis.utils import ContextMgrChain as CMC
|
|
59
59
|
|
|
60
60
|
# pylint: disable=no-name-in-module
|
|
@@ -106,6 +106,12 @@ class InteractiveClean:
|
|
|
106
106
|
###
|
|
107
107
|
self._error_result = None
|
|
108
108
|
|
|
109
|
+
###
|
|
110
|
+
### iclean results
|
|
111
|
+
###
|
|
112
|
+
self.__result = None
|
|
113
|
+
self.__result_from_gui = None
|
|
114
|
+
|
|
109
115
|
'''
|
|
110
116
|
_gen_port_fwd_cmd()
|
|
111
117
|
|
|
@@ -193,7 +199,7 @@ class InteractiveClean:
|
|
|
193
199
|
###
|
|
194
200
|
### whether or not the session is being run from a jupyter notebook or script
|
|
195
201
|
###
|
|
196
|
-
self._is_notebook =
|
|
202
|
+
self._is_notebook = is_interactive_jupyter()
|
|
197
203
|
|
|
198
204
|
##
|
|
199
205
|
## the http port for serving GUI in webpage if not running in script
|
|
@@ -1152,9 +1158,12 @@ class InteractiveClean:
|
|
|
1152
1158
|
if self.__result_future is None:
|
|
1153
1159
|
raise RuntimeError( 'no interactive clean result is available' )
|
|
1154
1160
|
|
|
1155
|
-
self.
|
|
1161
|
+
if self.__result is None:
|
|
1162
|
+
### restore returns full return dictionary
|
|
1163
|
+
self.__result_from_gui = self.__result_future.result( )
|
|
1164
|
+
self.__result = self._clean['gclean'].restore( )
|
|
1156
1165
|
|
|
1157
|
-
return self.
|
|
1166
|
+
return self.__result
|
|
1158
1167
|
|
|
1159
1168
|
def masks( self ):
|
|
1160
1169
|
'''Retrieves the masks which were used with interactive clean.
|
|
@@ -53,7 +53,7 @@ from bokeh.models.dom import HTML
|
|
|
53
53
|
|
|
54
54
|
from bokeh.models.ui.tooltips import Tooltip
|
|
55
55
|
from cubevis.bokeh.models import TipButton, Tip, EvTextInput
|
|
56
|
-
from cubevis.utils import resource_manager, reset_resource_manager,
|
|
56
|
+
from cubevis.utils import resource_manager, reset_resource_manager, is_interactive_jupyter, find_pkg, load_pkg
|
|
57
57
|
from cubevis.utils import ContextMgrChain as CMC
|
|
58
58
|
|
|
59
59
|
# pylint: disable=no-name-in-module
|
|
@@ -1868,6 +1868,12 @@ class InteractiveClean:
|
|
|
1868
1868
|
###
|
|
1869
1869
|
self._error_result = None
|
|
1870
1870
|
|
|
1871
|
+
###
|
|
1872
|
+
### iclean results
|
|
1873
|
+
###
|
|
1874
|
+
self.__result = None
|
|
1875
|
+
self.__result_from_gui = None
|
|
1876
|
+
|
|
1871
1877
|
'''
|
|
1872
1878
|
_gen_port_fwd_cmd()
|
|
1873
1879
|
|
|
@@ -1955,7 +1961,7 @@ class InteractiveClean:
|
|
|
1955
1961
|
###
|
|
1956
1962
|
### whether or not the session is being run from a jupyter notebook or script
|
|
1957
1963
|
###
|
|
1958
|
-
self._is_notebook =
|
|
1964
|
+
self._is_notebook = is_interactive_jupyter()
|
|
1959
1965
|
|
|
1960
1966
|
##
|
|
1961
1967
|
## the http port for serving GUI in webpage if not running in script
|
|
@@ -2914,9 +2920,12 @@ class InteractiveClean:
|
|
|
2914
2920
|
if self.__result_future is None:
|
|
2915
2921
|
raise RuntimeError( 'no interactive clean result is available' )
|
|
2916
2922
|
|
|
2917
|
-
self.
|
|
2923
|
+
if self.__result is None:
|
|
2924
|
+
### restore returns full return dictionary
|
|
2925
|
+
self.__result_from_gui = self.__result_future.result( )
|
|
2926
|
+
self.__result = self._clean['gclean'].restore( )
|
|
2918
2927
|
|
|
2919
|
-
return self.
|
|
2928
|
+
return self.__result
|
|
2920
2929
|
|
|
2921
2930
|
def masks( self ):
|
|
2922
2931
|
'''Retrieves the masks which were used with interactive clean.
|
cubevis/toolbox/_cube.py
CHANGED
|
@@ -54,7 +54,7 @@ from cubevis.bokeh.sources import ImageDataSource, ImagePipe, DataPipe
|
|
|
54
54
|
from cubevis.bokeh.format import WcsTicks
|
|
55
55
|
from cubevis.bokeh.models import EditSpan
|
|
56
56
|
from ..data import casaimage
|
|
57
|
-
from ..utils import pack_arrays, find_ws_address, set_attributes, resource_manager, polygon_indexes,
|
|
57
|
+
from ..utils import pack_arrays, find_ws_address, set_attributes, resource_manager, polygon_indexes, is_interactive_jupyter
|
|
58
58
|
from ..bokeh.models import EvTextInput
|
|
59
59
|
from ..bokeh.tools import CBResetTool
|
|
60
60
|
from ..bokeh.state import available_palettes, find_palette, default_palette
|
|
@@ -100,7 +100,7 @@ class CubeMask:
|
|
|
100
100
|
self.COUNT = 1
|
|
101
101
|
self.CCOUNT = 1
|
|
102
102
|
|
|
103
|
-
self._is_notebook =
|
|
103
|
+
self._is_notebook = is_interactive_jupyter()
|
|
104
104
|
#self._color = '#00FF00' # anti-green user feedback (issue #40 2024-05-02 13:08:32)
|
|
105
105
|
self._region_style=dict( fill_alpha=0, hover_fill_alpha=0.3,
|
|
106
106
|
fill_color='white', hover_fill_color='white',
|
cubevis/utils/__init__.py
CHANGED
|
@@ -43,6 +43,7 @@ from ._regions import polygon_indexes
|
|
|
43
43
|
from ._docenum import DocEnum
|
|
44
44
|
from ._copydoc import copydoc
|
|
45
45
|
from ._pkgs import find_pkg, load_pkg
|
|
46
|
+
from ._jupyter import is_interactive_jupyter
|
|
46
47
|
|
|
47
48
|
from astropy import units
|
|
48
49
|
from regions import PixCoord
|
|
@@ -604,17 +605,3 @@ def set_attributes(obj, **kw):
|
|
|
604
605
|
return obj
|
|
605
606
|
|
|
606
607
|
|
|
607
|
-
def is_notebook() -> bool:
|
|
608
|
-
try:
|
|
609
|
-
shell = get_ipython().__class__.__name__
|
|
610
|
-
if shell == 'ZMQInteractiveShell':
|
|
611
|
-
return True # Jupyter notebook or qtconsole
|
|
612
|
-
elif shell == 'TerminalInteractiveShell':
|
|
613
|
-
return False # Terminal running IPython
|
|
614
|
-
else:
|
|
615
|
-
if get_ipython().__class__.__module__ == 'google.colab._shell':
|
|
616
|
-
return True # Google Colab
|
|
617
|
-
else:
|
|
618
|
-
return False # Other type (?)
|
|
619
|
-
except NameError:
|
|
620
|
-
return False
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
|
|
2
|
+
#def is_notebook() -> bool:
|
|
3
|
+
# try:
|
|
4
|
+
# shell = get_ipython().__class__.__name__
|
|
5
|
+
# if shell == 'ZMQInteractiveShell':
|
|
6
|
+
# return True # Jupyter notebook or qtconsole
|
|
7
|
+
# elif shell == 'TerminalInteractiveShell':
|
|
8
|
+
# return False # Terminal running IPython
|
|
9
|
+
# else:
|
|
10
|
+
# if get_ipython().__class__.__module__ == 'google.colab._shell':
|
|
11
|
+
# return True # Google Colab
|
|
12
|
+
# else:
|
|
13
|
+
# return False # Other type (?)
|
|
14
|
+
# except NameError:
|
|
15
|
+
# return False
|
|
16
|
+
|
|
17
|
+
def is_interactive_jupyter( ) -> bool:
|
|
18
|
+
"""
|
|
19
|
+
Detect if running in an interactive Jupyter notebook with frontend connection.
|
|
20
|
+
|
|
21
|
+
This function distinguishes between:
|
|
22
|
+
- Interactive Jupyter notebook/lab with frontend (returns True)
|
|
23
|
+
- Standalone Jupyter kernel without frontend (returns False)
|
|
24
|
+
- Regular Python interpreter (returns False)
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
bool: True if running in interactive Jupyter with frontend, False otherwise
|
|
28
|
+
"""
|
|
29
|
+
try:
|
|
30
|
+
from IPython import get_ipython
|
|
31
|
+
ipython = get_ipython()
|
|
32
|
+
|
|
33
|
+
if ipython is None:
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
# Check if we're in a ZMQ-based shell (kernel)
|
|
37
|
+
if ipython.__class__.__name__ != 'ZMQInteractiveShell':
|
|
38
|
+
return False
|
|
39
|
+
|
|
40
|
+
# Check for active frontend connection
|
|
41
|
+
if hasattr(ipython, 'kernel') and ipython.kernel is not None:
|
|
42
|
+
kernel = ipython.kernel
|
|
43
|
+
|
|
44
|
+
# Method 1: Check if there are active connections
|
|
45
|
+
if hasattr(kernel, 'shell_socket') and kernel.shell_socket is not None:
|
|
46
|
+
# For newer Jupyter versions, check connection count
|
|
47
|
+
if hasattr(kernel, 'connection_count'):
|
|
48
|
+
return kernel.connection_count > 0
|
|
49
|
+
|
|
50
|
+
# For older versions, check if socket is connected
|
|
51
|
+
try:
|
|
52
|
+
# Try to get socket state - if it fails, likely no frontend
|
|
53
|
+
socket_state = kernel.shell_socket.closed
|
|
54
|
+
return not socket_state
|
|
55
|
+
except AttributeError:
|
|
56
|
+
pass
|
|
57
|
+
|
|
58
|
+
# Method 2: Check parent message (indicates interactive execution)
|
|
59
|
+
if hasattr(kernel, 'get_parent') and callable(kernel.get_parent):
|
|
60
|
+
try:
|
|
61
|
+
parent = kernel.get_parent()
|
|
62
|
+
# If there's a parent message, we're likely in interactive mode
|
|
63
|
+
return parent is not None and len(parent) > 0
|
|
64
|
+
except Exception:
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
# Method 3: Check for execution context
|
|
68
|
+
if hasattr(kernel, '_parent_ident') and kernel._parent_ident:
|
|
69
|
+
return True
|
|
70
|
+
|
|
71
|
+
# Fallback: Check for common Jupyter notebook environment indicators
|
|
72
|
+
# This catches cases where kernel introspection doesn't work
|
|
73
|
+
import os
|
|
74
|
+
jupyter_indicators = [
|
|
75
|
+
'JPY_PARENT_PID', # JupyterLab/Notebook sets this
|
|
76
|
+
'JUPYTER_RUNTIME_DIR',
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
for indicator in jupyter_indicators:
|
|
80
|
+
if indicator in os.environ:
|
|
81
|
+
# Additional check: see if we can import notebook-specific modules
|
|
82
|
+
try:
|
|
83
|
+
import IPython.display
|
|
84
|
+
# If we can import display and have env indicators, likely interactive
|
|
85
|
+
return True
|
|
86
|
+
except ImportError:
|
|
87
|
+
pass
|
|
88
|
+
|
|
89
|
+
return False
|
|
90
|
+
|
|
91
|
+
except ImportError:
|
|
92
|
+
return False
|
|
@@ -71,10 +71,10 @@ cubevis/data/__init__.py,sha256=_j5cRA9l9Nl0ycL_SsbeLP1Uil_q1ldiVKJk5IeRFx8,77
|
|
|
71
71
|
cubevis/data/casaimage/__init__.py,sha256=55ebo9hReK8DdnVDiFK25wYDGizQoRvjcKCIQCdgEck,3606
|
|
72
72
|
cubevis/private/_gclean.py,sha256=ExdR6cRxSa6Xne2veGNKhbTtx-tXUIWr2htzEmEZ9Z4,41107
|
|
73
73
|
cubevis/private/apps/__init__.py,sha256=NIC0XCfjInbAmteORFWtohMvq3Nf8EZ5bsvvUpDYSig,2679
|
|
74
|
-
cubevis/private/apps/_createmask.py,sha256=
|
|
75
|
-
cubevis/private/apps/_createregion.py,sha256=
|
|
76
|
-
cubevis/private/apps/_interactiveclean.mustache,sha256=
|
|
77
|
-
cubevis/private/apps/_interactiveclean.py,sha256=
|
|
74
|
+
cubevis/private/apps/_createmask.py,sha256=kLwb138M3CyZWG2MIv0-1jdpxjpelmroY_85KlSJptA,23592
|
|
75
|
+
cubevis/private/apps/_createregion.py,sha256=OHZzTUaQ8Ofl5xt2mCrhXEDkfED-B3TxL-TCi7EXVeo,26724
|
|
76
|
+
cubevis/private/apps/_interactiveclean.mustache,sha256=i6fMwFJvv-fnXCLTVCgP51tE_CxWOnc2n-qkAcSTF5I,104179
|
|
77
|
+
cubevis/private/apps/_interactiveclean.py,sha256=frQd4HGwed-HHS1jsRUroTbGs54fi9zpjOj2_ui3FzA,241830
|
|
78
78
|
cubevis/private/apps/_interactiveclean_wrappers.py,sha256=XqyCGz33CMDhszTxnwZ_3-64GszUK1XYnGKUOxl9sas,5071
|
|
79
79
|
cubevis/private/apps/_plotants.py,sha256=top6VWVd_sE48IVPH_sIg3_sQeDl5tadi5DL7r5tUEI,10823
|
|
80
80
|
cubevis/private/apps/_plotbandpass.py,sha256=NwOgKSRnpLw9Pt3KIdBpoV78q1OnjCvj6lWFqeyICt8,185
|
|
@@ -91,22 +91,23 @@ cubevis/remote/_local.py,sha256=PcPCFcwttTFZd3O33-5pqDuGKQKK6CA0gz1MTIkTiNI,1032
|
|
|
91
91
|
cubevis/remote/_remote_kernel.py,sha256=wfu7ZzKn-oCxZxzDIkC5puBvGf8WbCLYL3CzM56_FNc,2652
|
|
92
92
|
cubevis/toolbox/__init__.py,sha256=VqxO5Izv0nEjhPbqTUH1jo8SQoyj5YrSbs7m42N8Rm0,1433
|
|
93
93
|
cubevis/toolbox/_app_context.py,sha256=0tRY2SSbSCM6RKLFs_T707_ehWkJXPvnLlE1P9cLXJY,3024
|
|
94
|
-
cubevis/toolbox/_cube.py,sha256=
|
|
94
|
+
cubevis/toolbox/_cube.py,sha256=Thq7hZkcIjhlBf8nlYajyt-JZU1kkVG51VPTO1bHiqQ,294209
|
|
95
95
|
cubevis/toolbox/_region_list.py,sha256=_1RvnXwqMoaAq8CPy-6IyhabLi_snXqO566onehI2y0,8957
|
|
96
96
|
cubevis/utils/_ResourceManager.py,sha256=SaaR29etabRiKxmUK-aWvAm4v_OPFJH8CX7bNFm0Lgo,3410
|
|
97
|
-
cubevis/utils/__init__.py,sha256=
|
|
97
|
+
cubevis/utils/__init__.py,sha256=B_2a0yTCurZWiZfg8dUprcNsqNh205thg7KmpcPRNfE,22705
|
|
98
98
|
cubevis/utils/_contextmgrchain.py,sha256=r5SrCBdgQIVH7zXKOmq5oWhDUSeHaZpgsIfWFHvb3cQ,2859
|
|
99
99
|
cubevis/utils/_conversion.py,sha256=SziCU8sOGtG7djlY766-MeOvnQgvT9C737FEfJ4aYsE,3262
|
|
100
100
|
cubevis/utils/_copydoc.py,sha256=SI9DOUoTNg9M-Y4J1oci2Ba1jebGHsx_pFX24RSNg3o,1915
|
|
101
101
|
cubevis/utils/_docenum.py,sha256=D79BvxwW18DPUlIhBx5DnpZh76pDURC1Hqt1DfS7kG0,877
|
|
102
102
|
cubevis/utils/_import_protected_module.py,sha256=AIISHPdiSzwgVzLXqHSWSHT-L7lcMWbYrsMlGlTFafE,1482
|
|
103
|
+
cubevis/utils/_jupyter.py,sha256=-vYl7UPdSIhrsRrM4ZOi7pY0IEF7Fkm7nAwNOvugU10,3487
|
|
103
104
|
cubevis/utils/_logging.py,sha256=HqyoTib7QSuAUbzicPVMdhFtxWKo-Dv4GgD0AYDDXIY,2348
|
|
104
105
|
cubevis/utils/_pkgs.py,sha256=mu2CCzndmJZYP81UkFhxveW_CisWLUvagJVolHOEVgM,2294
|
|
105
106
|
cubevis/utils/_regions.py,sha256=TdAg4ZUUyhg3nFmX9_KLboqmc0LkyOdEW8M1WDR5Udk,1669
|
|
106
107
|
cubevis/utils/_static.py,sha256=rN-sqXNqQ5R2M3wmPHU1GPP5OTyyWQlUPRuimCrht-g,2347
|
|
107
108
|
cubevis/utils/_tiles.py,sha256=A9W1X61VOhBMTOKXVajzOIoiV2FBdO5N2SFB9SUpDOo,7336
|
|
108
|
-
cubevis/__version__.py,sha256=
|
|
109
|
-
cubevis-0.5.
|
|
110
|
-
cubevis-0.5.
|
|
111
|
-
cubevis-0.5.
|
|
112
|
-
cubevis-0.5.
|
|
109
|
+
cubevis/__version__.py,sha256=6Hymy5UWHVwqDeg7hv37CPePOtMP7gvK91kRL5s9EuU,22
|
|
110
|
+
cubevis-0.5.19.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
|
|
111
|
+
cubevis-0.5.19.dist-info/METADATA,sha256=Xmn1KxiwOtU54OH62tKcHzwKcT0eDpUg5QVPXbR37ZM,2629
|
|
112
|
+
cubevis-0.5.19.dist-info/licenses/LICENSE,sha256=IMF9i4xIpgCADf0U-V1cuf9HBmqWQd3qtI3FSuyW4zE,26526
|
|
113
|
+
cubevis-0.5.19.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|