22from urllib .parse import quote_plus
33import json
44import sys
5-
6- # Widget dependencies
7- import anywidget
8- from traitlets import Unicode , Dict , List , Int , Bool
95import time
106import uuid
7+ import anywidget
8+ from traitlets import Unicode , Dict , List , Int , Bool
119
12- # Server dependencies
13- from uvicorn import Config , Server
14-
15- from starlette .applications import Starlette
16- from starlette .middleware import Middleware
17- from starlette .middleware .cors import CORSMiddleware
18- from threading import Thread
19- import socket
2010
2111MAX_PORT_TRIES = 1000
2212DEFAULT_PORT = 8000
2515class BackgroundServer :
2616 # Reference: https://github.com/gosling-lang/gos/blob/main/gosling/data/_background_server.py#L10
2717 def __init__ (self , routes ):
18+ from starlette .applications import Starlette
19+ from starlette .middleware import Middleware
20+ from starlette .middleware .cors import CORSMiddleware
21+
2822 middleware = [
2923 Middleware (CORSMiddleware , allow_origins = [
3024 '*' ], allow_methods = ["OPTIONS" , "GET" ], allow_headers = ['Range' ])
@@ -47,6 +41,9 @@ def stop(self):
4741 return self
4842
4943 def start (self , port = None , timeout = 1 , daemon = True , log_level = "warning" ):
44+ from uvicorn import Config , Server
45+ from threading import Thread
46+
5047 if self .thread is not None :
5148 return self
5249
@@ -87,6 +84,7 @@ def register(self, config):
8784
8885
8986def is_port_in_use (port ):
87+ import socket
9088 with socket .socket (socket .AF_INET , socket .SOCK_STREAM ) as s :
9189 return s .connect_ex (('localhost' , port )) == 0
9290
@@ -602,7 +600,7 @@ class VitessceWidget(anywidget.AnyWidget):
602600
603601 next_port = DEFAULT_PORT
604602
605- js_package_version = Unicode ('3.6.2 ' ).tag (sync = True )
603+ js_package_version = Unicode ('3.6.3 ' ).tag (sync = True )
606604 js_dev_mode = Bool (False ).tag (sync = True )
607605 custom_js_url = Unicode ('' ).tag (sync = True )
608606 plugin_esm = List (trait = Unicode ('' ), default_value = []).tag (sync = True )
@@ -614,7 +612,7 @@ class VitessceWidget(anywidget.AnyWidget):
614612
615613 store_urls = List (trait = Unicode ('' ), default_value = []).tag (sync = True )
616614
617- def __init__ (self , config , height = 600 , theme = 'auto' , uid = None , port = None , proxy = False , js_package_version = '3.6.2 ' , js_dev_mode = False , custom_js_url = '' , plugins = None , remount_on_uid_change = True , prefer_local = True , invoke_timeout = 300000 , invoke_batched = True , page_mode = False , page_esm = None ):
615+ def __init__ (self , config , height = 600 , theme = 'auto' , uid = None , port = None , proxy = False , js_package_version = '3.6.3 ' , js_dev_mode = False , custom_js_url = '' , plugins = None , remount_on_uid_change = True , prefer_local = True , invoke_timeout = 300000 , invoke_batched = True , page_mode = False , page_esm = None ):
618616 """
619617 Construct a new Vitessce widget.
620618
@@ -749,7 +747,7 @@ def _plugin_command(self, params, buffers):
749747# Launch Vitessce using plain HTML representation (no ipywidgets)
750748
751749
752- def ipython_display (config , height = 600 , theme = 'auto' , base_url = None , host_name = None , uid = None , port = None , proxy = False , js_package_version = '3.6.2 ' , js_dev_mode = False , custom_js_url = '' , plugins = None , remount_on_uid_change = True , page_mode = False , page_esm = None ):
750+ def ipython_display (config , height = 600 , theme = 'auto' , base_url = None , host_name = None , uid = None , port = None , proxy = False , js_package_version = '3.6.3 ' , js_dev_mode = False , custom_js_url = '' , plugins = None , remount_on_uid_change = True , page_mode = False , page_esm = None ):
753751 from IPython .display import display , HTML
754752 uid_str = "vitessce" + get_uid_str (uid )
755753
0 commit comments