stoner_measurement.plugins.command.details.DetailsCommand¶
- class stoner_measurement.plugins.command.details.DetailsCommand(parent=None)[source]¶
Bases:
CommandPluginStore user, sample, project, and notes information for a measurement.
Use this command near the start of a sequence to record the basic details that identify a run: who is performing it, which sample is being measured, which project it belongs to, and any free-form notes. This information is intended to be filled in from the configuration panel and then reused by later steps such as saving or labelling data.
When this command executes in the application, the window title also shows the user, project and sample alongside the sequence filename. The most recently executed Details command supplies these values.
In normal use, fill in User, Sample, and Project before running. These are treated as required fields. The Project field is pre-populated from top-level folders in the configured default data directory, but you can still type your own value. Notes can be used for anything that may help interpret the data later.
For script-oriented use, this plugin behaves a little differently from most command plugins. The generated sequence code does not call
{instance_name}(). Instead it emits four attribute-assignment statements so that the values are set on the plugin instance in the engine namespace:details.user = "Alice" details.sample = "Nb_film_001" details.project = "NbSC" details.notes = "Cooled overnight; base pressure 5e-7 mbar."
The
date,time, andrigattributes are read-only runtime properties rather than configuration fields.dateandtimereturn the current local date and time when accessed, whilerigreads the local rig name from the application configuration.Additional metadata can be configured on the Metadata tab as a name and Python value expression. Generated sequence code evaluates those expressions in the engine namespace and assigns the results as attributes on this instance. For example, a metadata row named
temperaturecan be read by later sequence steps asdetails.temperature(or through the configuredinstance_name). The configured rows themselves are available throughmetadata_expressions.- Variables:
user (str) – Name of the person performing the measurement.
sample (str) – Identifier for the sample under test.
project (str) – Project name. The configuration combo box is pre-populated with the top-level subdirectories of the application default data directory (as configured in the application settings).
notes (str) – Free-form notes about the measurement.
date (str) – Read-only current local date in
YYYYMMDDform.time (str) – Read-only current local time in
HHmmssform.rig (str) – Read-only rig name from the local application configuration.
metadata_expressions (list[dict[str, str]]) – Additional attribute names and value expressions. Each entry has
"name"and"expression"keys; generated code exposes the evaluated value as an attribute named by"name".instance_name (str) – Inherited Python identifier for this instance in the Script tab and QtConsole.
comment (str) – Inherited optional note displayed beside this step.
sequence_engine (SequenceEngine | None) – Inherited owning engine and its live namespace; None while detached.
This design allows later sequence steps and data-saving plugins to read the metadata directly from the instance, for example
details.sampleordetails.project.- Keyword Parameters:
parent (QObject | None) – Optional Qt parent object.
Examples
With an instance named
detailsin the sequence, use the QtConsole to inspect or edit it before running. Substitute your instance name if different; result data reflects completed steps:details.sample = "Nb_film_001" details.project = "Transport" details.date
- config_tabs(parent: QWidget | None = None) list[tuple[str, QWidget]][source]¶
Return General, Metadata, and standard optional About tabs.
- config_widget(parent: QWidget | None = None) QWidget[source]¶
Return a settings widget with user, sample, project, and notes fields.
The widget contains a
QFormLayoutwith:A
QLineEditfor the operator name.A
QLineEditfor the sample identifier.An editable
QComboBoxfor the project name, pre-populated with the top-level subdirectories of the application default data directory.A
QPlainTextEditfor free-form notes.
- Keyword Parameters:
parent (QWidget | None) – Optional Qt parent widget.
- Returns:
The settings widget for the Settings tab.
- Return type:
(QWidget)
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.plugins.command.details import DetailsCommand >>> isinstance(DetailsCommand().config_widget(), QWidget) True
- eval_metadata(expression: str) Any[source]¶
Evaluate a metadata value, treating unknown identifiers as literal text.
Metadata is deliberately more forgiving than other runtime expression fields. A bare unquoted string is valid Python syntax, so the shared
eval()path raisesNameErrorrather than using its syntax-error fallback. For metadata only, warn and retry the original text as a quoted string. The retry still uses the shared evaluator, preserving runtime f-string interpolation for replacement fields.- Parameters:
expression (str) – Stored metadata expression or free-form literal text.
- Returns:
Evaluated expression or literal-string fallback.
- Return type:
(Any)
- generate_action_code(indent: int, sub_steps: list, render_sub_step: Callable) list[str][source]¶
Return attribute-assignment code lines for this plugin.
Instead of a
{instance_name}()call, emits four assignment statements that set the metadata attributes on the plugin instance in the engine namespace. Additional metadata values are assigned througheval_metadata(), which delegates to the shared runtime evaluator so genuine Python expressions use the live engine namespace while syntactically invalid text follows the quoted-string and runtime f-string fallback. Metadata also treats an unknown identifier as likely unquoted literal text after logging a warning. Aconfigure()call and blank separator line follow the assignments.- Parameters:
indent (int) – Number of four-space indentation levels for the emitted lines.
sub_steps (list) – Ignored —
DetailsCommandis always a leaf node.render_sub_step (Callable) – Ignored —
DetailsCommandis always a leaf node.
- Returns:
Four fixed-detail assignments, any evaluated metadata assignments, one
configure()call, and a trailing blank line.- Return type:
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.plugins.command.details import DetailsCommand >>> cmd = DetailsCommand() >>> cmd.user = "Alice" >>> cmd.sample = "Nb_001" >>> cmd.project = "NbSC" >>> cmd.notes = "Test run" >>> lines = cmd.generate_action_code(0, [], lambda s, i: []) >>> lines[0] 'details.user = "Alice"' >>> lines[1] 'details.sample = "Nb_001"' >>> lines[2] 'details.project = "NbSC"' >>> lines[3] 'details.notes = "Test run"' >>> lines[4] 'details.configure()' >>> lines[5] ''
- property name: str¶
Unique display name for the details command.
- Returns:
"Details".- Return type:
(str)
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.plugins.command.details import DetailsCommand >>> DetailsCommand().name 'Details'
- show_validation_error¶
Qt signal.
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal's arguments.
- to_json() dict[str, Any][source]¶
Serialise the details command configuration to a JSON-compatible dict.
- Returns:
Base dict from
to_json()extended with"user","sample","project", and"notes".- Return type:
Examples
>>> from qtpy.QtWidgets import QApplication >>> _ = QApplication.instance() or QApplication([]) >>> from stoner_measurement.plugins.command.details import DetailsCommand >>> d = DetailsCommand().to_json() >>> d["type"] 'command' >>> all(k in d for k in ("user", "sample", "project", "notes")) True