MetaModel

class MetaModel()

Bases: QObject

Abstract base class for models.

Public Methods

Abstract Methods

These methods must be implemented by subclasses.

(none)

Concrete Methods

MetaModel.cache_plot_data(data: List[ndarray], labels: List[str]) None
MetaModel.discard_generator(channel: int, key: str) None

Clear the run state for one (key, channel) once its worker thread has finished.

Formerly reset_lock, which reset no lock - it clears the thread_running flag, which is what allows set_generator() to stage a new run for this key and channel, and drops the spent generator.

The generator is explicitly closed before being dropped. A plugin that declares serial channel operations holds its own lock across the generator’s yields, and that lock is released when the generator is exhausted or closed; relying on the reference count falling to zero to finalize it would make release depend on garbage-collection timing, and a stranded lock here is a silent hang rather than an error. close() is a harmless no-op on a generator that already ran to completion.

The finished Worker/WorkerThread pair is also popped out of self.workers/self.threads and scheduled for deletion here, for the same reason: leaving them in the dicts kept every generator closure and the channel data it touched alive for the rest of the session, and made stop_workers/handle_kill_worker log “Stopping worker for channel N” for runs that had finished hours earlier. Both are QObject``s created on (and never moved from) this thread, so ``deleteLater() is the correct way to release them rather than waiting on Python’s reference counting.

Parameters:
  • channel (int) – the channel whose run has finished

  • key (str) – the plugin key whose run has finished

MetaModel.emit_progress_update(progress: float, identifier: str) None

Emit the progress update signal

MetaModel.emit_text_to_display(text: str, identifier: str) None

Relay a worker’s message to the status panel.

Workers run on their own thread and report an early stop this way rather than by raising it as an ERROR record, which QtHandler would turn into a modal dialog.

Parameters:
  • text (str) – The message to show the user.

  • identifier (str) – The reporting worker’s key/channel identifier.

MetaModel.format_cache_data() DataFrame | None
MetaModel.generate_report(channel: int, key: str) None
MetaModel.run_generators(key: str) None

Start one worker thread per channel for which a generator has been staged under this key.

Serialization is not decided here. A plugin that declares force_serial_channel_operations() now takes its own lock inside its generator (see serialize_channels()), so this method no longer asks the plugin anything and no longer hands the worker a lock. It used to emit global_signal for that answer and read it back off self.serial_ops on the next statement, which worked only because every hop in that chain was a same-thread automatic connection Qt resolves as a direct call - one Qt.QueuedConnection anywhere in it would have silently degraded the lock to None, with no error and no log line.

Parameters:

key (str) – the plugin key whose staged generators should be run

MetaModel.set_generator(generator: Generator[float, bool | None, None], channel: int, key: str, metaclass: str) None

Add generator and set it to be run by a QThread.

MetaModel.stop_workers(key: str | None = None, channel: int | None = None, exiting: bool = False) None

Stop workers based on specified key and/or channel.

MetaModel.update_available_plugins(available_plugins: Dict[str, List[str]]) None

Called whenever a new plugin is instantiated elsewhere in the app, to keep an up to date list of possible data sources for use by this plugin.

Parameters:

available_plugins (Dict[str, List[str]]) – dict of lists keyed by MetaClass, listing the identifiers of all instantiated plugins throughout the app.

Private Methods

Abstract Methods

These methods must be implemented by subclasses.

abstractmethod MetaModel._init() None

Perform additional initialization specific to the algorithm being implemented. Must be implemented by subclasses.

This function is called at the end of the class constructor to perform additional initialization specific to the algorithm being implemented. kwargs provided to the base class constructor are available as class attributes.

Concrete Methods

MetaModel.__init__(**kwargs: Any) None

Initialize the MetaModel

Parameters:

**kwargs (Any) – Additional parameters to set as attributes on the instance