Coverage for src/metador_core/widget/jupyter/__init__.py: 0%

15 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-11-02 09:33 +0000

1"""Functionality to make widgets and dashboard work stand-alone in Jupyter.""" 

2 

3import wrapt 

4 

5from ...container import MetadorContainer 

6from . import standalone 

7 

8 

9class Previewable(wrapt.ObjectProxy): 

10 """Wrapper to be used around MetadorContainer inside Jupyter. 

11 

12 Will ensure that widgets can work in the notebook. 

13 """ 

14 

15 def __init__(self, container: MetadorContainer): 

16 super().__init__(container) 

17 

18 if not standalone.running(): 

19 standalone.run() 

20 

21 if provider := standalone.container_provider(): 

22 provider[str(self.metador.container_uuid)] = self 

23 

24 def close(self, *args, **kwargs): 

25 if provider := standalone.container_provider(): 

26 del provider[str(self.metador.container_uuid)] 

27 

28 self.__wrapped__.close(*args, **kwargs) 

29 

30 

31__all__ = ["Previewable"]