magicclass.ext.dask package¶
Submodules¶
magicclass.ext.dask.progress module¶
- class magicclass.ext.dask.progress.DaskProgressBar(max: int = 100, minimum: float = 0.5, dt: float = 0.1)[source]¶
Bases:
magicgui.widgets._bases.widget.Widget
,magicgui.widgets._bases.mixins._OrientationMixin
,MutableSequence
[magicgui.widgets._bases.widget.Widget
]A progress bar widget for dask computation.
- computed¶
Declares a signal emitter on a class.
This is class implements the [descriptor protocol](https://docs.python.org/3/howto/descriptor.html#descriptorhowto) and is designed to be used as a class attribute, with the supported signature types provided in the contructor:
```python from psygnal import Signal
- class MyEmitter:
changed = Signal(int)
- def receiver(arg: int):
print("new value:", arg)
emitter = MyEmitter() emitter.changed.connect(receiver) emitter.changed.emit(1) # prints 'new value: 1' ```
!!! note
in the example above, MyEmitter.changed is an instance of Signal, and emitter.changed is an instance of SignalInstance. See the documentation on [SignalInstance][psygnal.SignalInstance] for details on how to connect to and/or emit a signal on an instance of an object that has a Signal.
- Parameters
*types (Union[Type[Any], Signature]) -- A sequence of individual types, or a single [inspect.Signature][] object.
description (str) -- Optional descriptive text for the signal. (not used internally).
name (Optional[str]) -- Optional name of the signal. If it is not specified then the name of the class attribute that is bound to the signal will be used. default None
check_nargs_on_connect (bool) -- Whether to check the number of positional args against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_nargs=True). By default, True.
check_types_on_connect (bool) -- Whether to check the callback parameter types against signature when connecting a new callback. This can also be provided at connection time using .connect(..., check_types=True). By default, False.
- class magicclass.ext.dask.progress.dask_thread_worker(f: Callable | None = None, *, ignore_errors: bool = False, progress: ProgressDict | bool | None = True)[source]¶
Bases:
magicclass.utils.qthreading.thread_worker
Create a dask's worker in a superqt/napari style.
This thread worker class can monitor the progress of dask computation. Callback function connected to
computed
signal will get called when any one of the tasks are finished. The returned value of the task will be sent to the callback argument. The returned value is useful if delayed functions are computed but it is not always meaningful when dask mapping functions such asmap_blocks
is used. Unlike standardthread_worker
, you should not specifytotal
parameter since dask progress bar knows it.Examples
@magicclass class A: @dask_thread_worker def func(self): arr = da.random.random((30000, 30000)) da.mean(arr).compute() @func.computed.connect def _on_computed(self, _=None): print("computed")
- property computed: magicclass.utils.qthreading.CallbackList[Any]¶