nomad_camels package

Subpackages

Submodules

nomad_camels.CAMELS_start module

class nomad_camels.CAMELS_start.ImportThread(package_list=None)

Bases: QThread

A thread dedicated to importing packages required by the main application.

This thread emits progress updates and loading messages via signals while importing each package.

run()

Execute the thread to import the specified packages.

This method iterates over the package list, emitting progress updates and messages. If an import error occurs (ModuleNotFoundError or AttributeError), it is silently ignored. Finally, it imports the main application module.

staticMetaObject = PySide6.QtCore.QMetaObject("ImportThread" inherits "QThread": Methods:   #12 type=Signal, signature=update_progress(int), parameters=int   #13 type=Signal, signature=update_text(QString), parameters=QString )
update_progress
update_text
class nomad_camels.CAMELS_start.LoadingScreen

Bases: QDialog

A loading screen dialog that is displayed while the main application is starting up.

This screen shows an image, a loading text label, and a progress bar that updates as packages are imported and the application loads.

set_progress(value)

Update the progress bar with the given value.

Parameters:

value (int) – The new value for the progress bar (typically 0 to 100).

set_text(text)

Update the loading text displayed on the screen.

Parameters:

text (str) – The new text to display in the label.

staticMetaObject = PySide6.QtCore.QMetaObject("LoadingScreen" inherits "QDialog": )
nomad_camels.CAMELS_start.start_camels(start_proxy_bool=True)

Launch the NOMAD CAMELS application with a loading screen.

This function performs the following steps:
  1. Checks if a QCoreApplication instance exists and creates one if needed.

  2. Displays the loading screen.

  3. Reads the list of startup packages from a file (if available).

  4. Starts a separate thread to import the packages with progress updates.

  5. Processes application events until the import thread completes.

  6. Saves the currently loaded modules to the startup package file.

  7. Sets up the main window and exception hook.

  8. Launches the main application event loop.

nomad_camels.MainApp_v2 module

The main window of the program. It contains all the other classes and is the main interface for the user.

class nomad_camels.MainApp_v2.MainWindow(parent=None, start_proxy_bool=True)

Bases: Ui_MainWindow, QMainWindow

Main window for the NOMAD CAMELS application.

This class connects to all the other components and handles user interactions, protocol execution, device management, and various settings/preferences.

add_button_to_manuals(name, tab='')

Add a button for a manual control in the manual controls area.

Parameters:
  • name (str) – The name of the manual control.

  • tab (str, optional) – The tab where the button should be added. Defaults to the active tab.

add_button_to_meas(name, tab='')

Add a button for a measurement protocol to the measurement controls area.

Parameters:
  • name (str) – The name of the protocol.

  • tab (str, optional) – The tab to add the button to; defaults to the active tab.

add_functions_to_manual_button(button, name)

Connect functions to a manual control button.

Functions include opening configuration, starting, deleting, and moving the manual control.

Parameters:
  • button (Options_Run_Button) – The button to update.

  • name (str) – The name of the manual control.

add_functions_to_meas_button(button, name)

Connect functions to a measurement protocol button.

Functions include configuration, running, building, opening, data path access, deletion, moving, and queuing the protocol.

Parameters:
  • button (Options_Run_Button) – The protocol button to update.

  • name (str) – The name of the protocol.

add_manual_control()

Open a dialog to add a new manual control.

On acceptance, adds the control data to the manual controls.

add_manual_control_to_data(control_data)

Add a manual control using the provided control data.

Parameters:

control_data (dict) – Data for the manual control to add.

add_measurement_protocol()

Open an empty protocol configuration dialog.

On acceptance, the protocol is added to the protocols data.

add_prot_to_data(protocol)

Add a measurement protocol to the protocols dictionary.

Also adds a corresponding button to the measurement controls area.

Parameters:

protocol (Measurement_Protocol) – The protocol to add.

add_subs_and_plots_from_dict(dictionary)

Recursively add subscriptions and plots from a dictionary.

The dictionary may contain keys ‘subs’ and ‘plots’ or nested dictionaries.

Parameters:

dictionary (dict) – Dictionary containing subscriptions and plots.

add_tag()

Add a tag from the line edit to the flow layout.

Reads the text from the tag line edit, creates a TagWidget if the text is not empty, adds it to the layout, and clears the line edit.

add_to_open_windows(window)

Add a window to the list of open windows.

Connects the window’s closing signal to remove it from the list when closed.

Parameters:

window (QWidget) – The window to add.

add_to_plots(plot)

Add a plot to the list of open plots and to the list of open windows.

Connects signals so that when the plot is closed or reopened, the lists are updated.

Parameters:

plot (QWidget) – The plot to add.

bluesky_setup()

Set up the Bluesky RunEngine and databroker catalog.

This method is called when the first protocol is run and configures the run engine with callbacks, loads the databroker catalog, and subscribes to events.

build_protocol(protocol_name, ask_file=True, variables=None)

Build the protocol file for the specified protocol.

Calls the protocol builder to export the protocol as a Python file.

Parameters:
  • protocol_name (str) – The name of the protocol.

  • ask_file (bool, optional) – Whether to prompt for a file location. Defaults to True.

  • variables (Optional[dict], optional) – Optional variables to override protocol defaults. Defaults to None.

change_catalog_name()

Change the name of the databroker catalog.

If the catalog does not exist, a temporary catalog is used.

change_preferences()

Open the settings dialog to change preferences.

On acceptance, updates the preferences dictionary, saves it, and updates the dependent settings.

change_preset(preset)

Save the current preset and load a new one.

Parameters:

preset (str) – The name of the new preset to load.

change_theme()

Change the graphic theme of the application based on the current preferences.

change_user()

Update the active user when the user selection changes.

Also refreshes the samples shown.

change_user_type()

Adjust UI elements based on the selected user type.

For example, shows NOMAD login button if NOMAD user is selected.

change_variables_queued_protocol(protocol_name, variables, index)

Update variables of an already queued protocol (called by the API).

Parameters:
  • protocol_name (str) – The protocol name.

  • variables (dict) – The updated variables.

  • index (int) – The index of the protocol in the queue.

check_password_protection()

Check for password protection and prompt for a password if enabled.

Returns:

True if there is no password protection or if the entered password is correct, False otherwise.

Return type:

bool

clear_fastapi_thread(*args)

Clear the FastAPI server thread if an error occurs.

Also displays a warning popup indicating the server failed to start.

close() bool

Overwrite the close method to save state when closing the window.

Returns:

The result of the parent’s close() method.

Return type:

bool

closeEvent(a0)

Handle the close event by closing all open windows, stopping the API server, and saving the state if autosave is enabled.

Parameters:

a0 (QCloseEvent) – The close event.

close_manual_control(control, name)

Handle the closing of a manual control.

Removes the control from the list of open windows and re-enables its button.

Parameters:
  • control (Manual_Control) – The control that is closing.

  • name (str) – The name of the manual control.

close_old_queue_devices()

Close devices from previously queued protocols that are not used in the current protocol.

close_plots()

Close all currently open plots and reset plot placement variables.

close_unused_instantiated_devices()

Close devices that were instantiated but are no longer in use.

Called after stopping protocols that were queued.

edit_sample_info()

Open a dialog to edit sample information.

The dialog displays sample data such as name, identifier, and description. On acceptance, updates the sample data.

edit_user_info()

Open a dialog to edit user information.

The dialog displays user data such as name, email, affiliation, ORCID, phone number etc. On acceptance, updates the user data.

fake_signal
get_sample_name_data()

Retrieve the current sample name and associated data.

Returns:

A tuple containing the sample name and sample data dictionary.

Return type:

tuple

get_user_name_data()

Retrieve the current user name and associated data.

Returns:

A tuple containing the user name and user data dictionary.

Return type:

tuple

import_measurement_protocol()

Import a protocol from a file.

Opens a file dialog to select a protocol file (.cprot), then loads and opens its configuration dialog.

launch_data_exporter()

Launch the data exporter dialog.

Opens a dialog to assist in exporting data from the databroker.

launch_device_builder()

Launch the device driver builder dialog.

Opens a dialog to assist in building device drivers.

launch_epics_builder()

Launch the EPICS driver builder dialog.

Opens a dialog to assist in building EPICS drivers.

launch_hdf5_exporter()

Launch the HDF5 exporter dialog.

Opens a dialog to assist in exporting HDF5 files.

load_backup_preset()

Load a preset from the backup folder via a file dialog.

If a backup is selected, the current preset is first saved, then the backup is loaded.

load_extensions()

Load extensions as specified in the preferences.

If no extensions are specified, defaults are added. Paths are added to sys.path and each extension is imported and instantiated with the required contexts.

load_preferences()

Load application preferences.

Those may contain: - autosave: turn on / off autosave on closing the program. - dark_mode: turning dark-mode on / off. - number_format: the number format for display, can be either “mixed”, “plain” or “scientific”. - mixed_from: the exponent from where to switch to scientific format, if number_format is “mixed”. - n_decimals: the number of displayed decimals of a number. - py_files_path: the path, where python files (e.g. protocols) are created. - meas_files_path: the path, where measurement data is stored. - device_driver_path: the path, where NOMAD CAMELS can find the installed devices. - databroker_catalog_name: the name of the databroker catalog After loading, the dependent settings are updated.

load_preset(preset)

Load the specified preset from file.

Resets active instruments, protocols, manual controls, and updates the UI accordingly.

Parameters:

preset (str) – The name or path of the preset to load.

load_sample_data()

Load sample data from a JSON file.

Sets the active sample and updates the sample data dictionary.

load_state()

Load the most recent preset.

If the most recent preset fails to load, attempts to load the second most recent preset.

load_user_data()

Load user data from a JSON file.

Sets the active user and updates the user data dictionary.

login_logout_nomad()

Handle logging in/out of NOMAD when the corresponding button is clicked.

Depending on the current state, either logs out or initiates the login process.

login_nomad()

Handle the login process to NOMAD.

If login is successful, updates the UI to reflect NOMAD-related controls.

make_save_dict()

Create the dictionary to be saved for the current preset.

This includes active instruments, protocols, manual controls, and tabs.

manage_extensions()

Open the extension manager dialog.

Requires password protection if enabled. On successful changes, prompts for a restart.

manage_instruments()

Open the instrument manager dialog.

Allows users to add or remove instruments. After the dialog, the active instruments are updated.

move_manual_control(control_name)

Move a manual control to another tab.

Opens a dialog to select a new tab, and if different from the current tab, moves the control.

Parameters:

control_name (str) – The name of the manual control to move.

move_protocol(protocol_name)

Move a protocol to a different tab.

Opens a move dialog to choose a new tab and moves the protocol button accordingly.

Parameters:

protocol_name (str) – The name of the protocol to move.

new_preset()

Create a new, empty device preset via a file dialog.

Saves the new preset and reloads the state.

next_queued_protocol(protocol_name, variables, api_uuid=None)

Run the next queued protocol if the run engine is idle.

Parameters:
  • protocol_name (str) – The name of the protocol.

  • variables (dict) – The variables for the protocol.

  • api_uuid (Optional[str]) – The API unique identifier, defaults to None.

open_data_path(protocol_name)

Open the data path for a protocol in the file explorer.

Parameters:

protocol_name (str) – The name of the protocol.

open_manual_control_config(control_name)

Open the configuration dialog for a manual control.

If the dialog is accepted, updates the manual control data accordingly.

Parameters:

control_name (str) – The name of the manual control to configure.

open_protocol(protocol_name)

Open the protocol file in the default editor.

If the protocol file does not exist, it is built first.

Parameters:

protocol_name (str) – The name of the protocol to open.

open_protocol_config(prot_name)

Open the configuration dialog for a protocol.

If the dialog is accepted, updates the protocol data.

Parameters:

prot_name (str) – The name of the protocol to configure.

open_watchdog_definition()

Open the watchdog definition dialog.

Disconnects active watchdog signals, shows the dialog, and then updates watchdogs.

pause_protocol()

Pause the currently running protocol.

Requests the run engine to pause and updates the UI buttons accordingly.

play_finished_sound()
populate_manuals_buttons()

Populate the manual controls area with buttons for each manual control.

Clears the area and then adds buttons according to the current manual controls data.

populate_meas_buttons()

Populate the measurement protocols area with buttons.

Clears the area and then adds buttons for each protocol.

propagate_exception(exception)

Handle exceptions raised during device instantiation.

Calls protocol_finished and then raises the exception.

Parameters:

exception (Exception) – The exception that was raised.

protocol_finished(*args)

Handle the end of protocol execution.

Removes subscriptions, cleans up devices, checks if a queued protocol should be run next, and performs final UI updates.

protocol_finished_part_2()
protocol_finished_signal
protocol_stepper_signal
queue_protocol(protocol_name, api_uuid=None)

Add a protocol to the execution queue.

Updates the run queue widget and makes it visible.

Parameters:
  • protocol_name (str) – The name of the protocol to queue.

  • api_uuid (Optional[str], optional) – The API unique identifier, defaults to None.

queue_protocol_with_variables_signal(protocol_name, variables, index, api_uuid)

Update variables for a queued protocol (called by the API).

Parameters:
  • protocol_name (str) – The name of the protocol.

  • variables (dict) – The variables to update.

  • index (int) – The index in the queue.

  • api_uuid (str) – The API unique identifier.

remove_manual_control(control_name)

Remove a manual control from the manual controls list and update the UI.

Parameters:

control_name (str) – The name of the manual control to remove.

remove_protocol(prot_name)

Remove a protocol from the protocols dictionary and update the UI.

Parameters:

prot_name (str) – The name of the protocol to remove.

remove_queue_protocol(protocol_name)

Remove a protocol from the run queue (called by the API).

Parameters:

protocol_name (str) – The name of the protocol to remove.

resume_protocol()

Resume a paused protocol.

Updates the UI buttons and instructs the run engine to resume.

run_done_file_signal
run_protocol(protocol_name, api_uuid=None, variables=None)

Run a measurement protocol.

Builds and imports the protocol file, instantiates required devices, and executes the protocol. Manages UI updates and handles NOMAD uploads if applicable.

Parameters:
  • protocol_name (str) – The name of the protocol to run.

  • api_uuid (Optional[str]) – The API unique identifier, defaults to None.

  • variables (Optional[dict]) – Variables for the protocol, defaults to None.

run_protocol_part2(api_uuid=None)

Continue running the protocol after devices are instantiated.

Executes the main protocol steps, sets up live windows and subscriptions, and handles NOMAD uploads if applicable.

Parameters:

api_uuid (Optional[str]) – The API unique identifier, defaults to None.

save_preset_as()

Save the current preset under a new name via a file dialog.

A backup/autosave is performed automatically.

save_sample_data()

Save the current sample data to a JSON file.

The active sample is saved along with the complete sample data dictionary.

save_state(fromload=False, do_backup=True)

Save the current application state.

Saves the device preset along with user and sample data. Optionally creates a backup.

Parameters:
  • fromload (bool, optional) – Indicates if the save is triggered from a load operation. Defaults to False.

  • do_backup (bool, optional) – Indicates whether to perform a backup. Defaults to True.

save_user_data()

Save the current user data to a JSON file.

The active user is saved along with the complete user data dictionary.

select_nomad_sample()

Open a dialog to select a sample from NOMAD.

Updates the NOMAD sample and updates the corresponding UI elements.

set_checkbox(protocol_name)

Check the checkbox of a protocol in the run queue (called by the API).

Parameters:

protocol_name (str) – The name of the protocol whose checkbox is to be set.

set_sample(sample_name)

Set the active sample to the specified sample name (called by the API).

Parameters:

sample_name (str) – The name of the sample to set.

Raises:

ValueError – If the given sample does not exist in the sample data.

set_session(session_name)

Set the active session name (called by the API).

Parameters:

session_name (str) – The session name to set.

set_user(user_name)

Set the active user to the specified user name (called by the API).

Parameters:

user_name (str) – The name of the user to set.

Raises:

ValueError – If the given user does not exist in the user data.

show_hide_log()

Toggle the visibility of the console log and clear log button.

If the log is hidden, it becomes visible, and vice versa. Also updates the text of the show/hide button.

show_nomad_sample()

Show or hide NOMAD sample settings based on user selection and NOMAD login status.

Updates the sample widget display and enables/disables the NOMAD sample selection button.

show_nomad_upload()

Show or hide NOMAD upload settings based on whether a NOMAD user is logged in.

Updates UI elements related to uploading data to NOMAD.

start_API_server(api_port)

Start the FastAPI server on the specified port.

This method initializes and starts a FastAPI thread for remote API control, and connects its signals to various slot functions in the main window. The API emits signals to the main app to perform most of the tasks like queuing and starting protocols. You can enable the API and set the port in the Settings Window of CAMELS.

Parameters:

api_port (int) – The port number on which to start the API server.

start_manual_control(name)

Start a manual control.

Instantiates the control class and opens it in a new window. Also disables the single-run button.

Parameters:

name (str) – The name of the manual control to start.

start_timer_signal
staticMetaObject = PySide6.QtCore.QMetaObject("MainWindow" inherits "QMainWindow": Methods:   #39 type=Signal, signature=protocol_stepper_signal(int), parameters=int   #40 type=Signal, signature=run_done_file_signal(QString), parameters=QString   #41 type=Signal, signature=fake_signal(int), parameters=int   #42 type=Signal, signature=protocol_finished_signal()   #43 type=Signal, signature=start_timer_signal() )
stop_API_server()

Stop the FastAPI server if it is running.

stop_protocol()

Stop the currently running protocol.

Aborts the run engine, and if necessary, runs the end protocol. Also handles cleanup of device threads.

toggle_dark_mode()

Toggle dark mode on or off based on the preferences.

update_channels()

Update the channels information from the active instruments.

Clears existing channels in variables_handling and updates with channels from each active device.

update_live_variables(variables)

Update live variables during protocol execution.

Parameters:

variables (dict) – The new values for the live variables.

update_man_cont_data(control_data, old_name)

Update data for a manual control.

Removes the old entry and updates it with the new control data, renaming buttons accordingly.

Parameters:
  • control_data (dict) – The updated manual control data.

  • old_name (str) – The previous name of the manual control.

update_preference_settings()

Update settings that depend on the preferences.

This includes number formatting, device driver path, databroker catalog name, and graphic theme.

update_prot_data(protocol, old_name)

Update the data of a protocol.

Removes the old protocol entry and replaces it with the updated one, renaming buttons accordingly.

Parameters:
  • protocol (Measurement_Protocol) – The updated protocol.

  • old_name (str) – The old name of the protocol.

update_shown_samples()

Refresh the sample combobox with samples that are owned by the active user or have no owner.

update_watchdogs()

Update watchdogs by connecting their condition_met signals to the watchdog_triggered slot.

watchdog_triggered(watchdog)

Handle a triggered watchdog condition.

Pauses the protocol, executes the watchdog protocol if defined, and shows a warning popup.

Parameters:

watchdog (Watchdog) – The triggered watchdog object.

with_or_without_instruments()

Check if active instruments are available and update the UI accordingly.

Hides protocol and manual controls if no instruments are active.

Module contents