runmanager.__main__.RunManager

class runmanager.__main__.RunManager[source]

Bases: object

__init__()[source]

Methods

__init__()

add_item_to_axes_model(expansion_name, shuffle)

check_child_exited(timeout_time[, kill])

check_output_folder_update()

Do a single check of whether the output folder needs updating.

close_current_tab()

close_globals_file(globals_file[, confirm])

close_group(globals_file, group_name)

compile_loop()

connect_signals()

copy_group(source_globals_file, ...[, ...])

This function copys a group of globals with the name source_group_name from the file source_globals_file to a new file dest_globals_file.

delete_group(globals_file, group_name[, confirm])

do_model_sort()

get_active_groups([interactive])

Returns active groups in the format {group_name: globals_file}.

get_default_output_folder()

Returns what the default output folder would be right now, based on the current date and selected labscript file.

get_group_item_by_name(globals_file, ...[, ...])

Returns an item from the row representing a globals group in the groups model.

get_save_data()

globals_changed()

Called from either self, a GroupTab, or the RemoteServer to inform runmanager that something about globals has changed, and that they need parsing again.

guess_expansion_modes(active_groups, ...)

This function is designed to be called iteratively.

load_configuration(filename)

make_group_row(group_name)

Returns a new row representing one group in the groups tab, ready to be inserted into the model.

make_h5_files(labscript_file, output_folder, ...)

new_group(globals_file, group_name)

on_abort_clicked()

on_axes_check_selected_triggered(*args)

on_axes_item_changed(item)

on_axes_uncheck_selected_triggered(*args)

on_axis_down_clicked(checked)

on_axis_to_bottom_clicked(checked)

on_axis_to_top_clicked(checked)

on_axis_up_clicked(checked)

on_close_event()

on_diff_globals_file_clicked()

on_edit_labscript_file_clicked(checked)

on_engage_clicked()

on_groups_close_selected_files_triggered()

on_groups_close_selected_groups_triggered()

on_groups_copy_selected_groups_triggered([...])

on_groups_delete_selected_triggered()

on_groups_model_active_changed(item)

Sets the sort data for the item in response to its check state changing.

on_groups_model_item_changed(item)

This function is for responding to data changes in the model.

on_groups_model_name_changed(item)

Handles group renaming and creation of new groups due to the user editing the <click to add group> item

on_groups_model_openclose_changed(item)

Sets item sort data and icon in response to the open/close state of a group changing.

on_groups_open_selected_triggered()

on_groups_set_selection_active_triggered(...)

on_labscript_file_text_changed(text)

on_load_configuration_triggered()

on_master_shuffle_clicked(state)

on_new_globals_file_clicked()

on_open_globals_file_clicked()

on_output_popout_button_clicked()

on_reset_shot_output_folder_clicked(checked)

on_restart_subprocess_clicked()

on_revert_configuration_triggered()

on_save_configuration_as_triggered()

on_save_configuration_triggered()

on_select_labscript_file_clicked(checked)

on_select_shot_output_folder_clicked(checked)

on_shot_output_folder_text_changed(text)

on_tabCloseRequested(index)

on_treeView_axes_context_menu_requested(point)

on_treeView_groups_context_menu_requested(point)

on_treeView_groups_doubleLeftClicked(index)

on_treeView_groups_leftClicked(index)

Here we respond to user clicks on the treeview.

open_globals_file(globals_file)

open_group(globals_file, group_name[, ...])

parse_globals(active_groups[, ...])

preparse_globals()

preparse_globals_loop()

Runs in a thread, waiting on a threading.Event that tells us when some globals have changed, and calls parse_globals to evaluate them all before feeding the results back to the relevant tabs to be displayed.

rename_group(globals_file, ...)

rollover_shot_output_folder()

Runs in a thread, checking every 30 seconds if the default output folder has changed, likely because the date has changed, but also possible because another instance of runmanager has incremented the sequence index.

save_configuration(save_file)

send_to_BLACS(run_file, BLACS_hostname)

send_to_runviewer(run_file)

setup_axes_tab()

setup_config()

setup_groups_tab()

switch_tabs(change)

update_axes_indentation()

update_axes_tab(expansions, dimensions)

update_global_shuffle_state(*args, **kwargs)

update_tabs_parsing_indication(...)

wait_until_preparse_complete()

Block until the preparse loop has finished pending work

Attributes

AXES_COL_LENGTH

AXES_COL_NAME

AXES_COL_SHUFFLE

AXES_ROLE_NAME

GROUPS_COL_ACTIVE

GROUPS_COL_DELETE

GROUPS_COL_NAME

GROUPS_COL_OPENCLOSE

GROUPS_DUMMY_ROW_TEXT

GROUPS_ROLE_GROUP_IS_OPEN

GROUPS_ROLE_IS_DUMMY_ROW

GROUPS_ROLE_PREVIOUS_NAME

GROUPS_ROLE_SORT_DATA

AXES_COL_LENGTH = 1
AXES_COL_NAME = 0
AXES_COL_SHUFFLE = 2
AXES_ROLE_NAME = 257
GROUPS_COL_ACTIVE = 1
GROUPS_COL_DELETE = 2
GROUPS_COL_NAME = 0
GROUPS_COL_OPENCLOSE = 3
GROUPS_DUMMY_ROW_TEXT = '<Click to add group>'
GROUPS_ROLE_GROUP_IS_OPEN = 260
GROUPS_ROLE_IS_DUMMY_ROW = 257
GROUPS_ROLE_PREVIOUS_NAME = 258
GROUPS_ROLE_SORT_DATA = 259
add_item_to_axes_model(expansion_name, shuffle, dimensions=None)[source]
check_child_exited(timeout_time, kill=False)[source]
check_output_folder_update()[source]

Do a single check of whether the output folder needs updating. This is implemented as a separate function to the above loop so that the whole check happens at once in the Qt main thread and hence is atomic and can’t be interfered with by other Qt calls in the program.

close_current_tab()[source]
close_globals_file(globals_file, confirm=True)[source]
close_group(globals_file, group_name)[source]
compile_loop()[source]
connect_signals()[source]
copy_group(source_globals_file, source_group_name, dest_globals_file=None, delete_source_group=False)[source]

This function copys a group of globals with the name source_group_name from the file source_globals_file to a new file dest_globals_file. If delete_source_group is True the source group is deleted after copying

delete_group(globals_file, group_name, confirm=True)[source]
do_model_sort()[source]
get_active_groups(interactive=True)[source]

Returns active groups in the format {group_name: globals_file}. Displays an error dialog and returns None if multiple groups of the same name are selected, this is invalid - selected groups must be uniquely named. If interactive=False, raises the exception instead.

get_default_output_folder()[source]

Returns what the default output folder would be right now, based on the current date and selected labscript file. Returns empty string if no labscript file is selected. Does not create the default output folder, does not check if it exists.

get_group_item_by_name(globals_file, group_name, column, previous_name=None)[source]

Returns an item from the row representing a globals group in the groups model. Which item is returned is set by the column argument.

get_save_data()[source]
globals_changed()[source]

Called from either self, a GroupTab, or the RemoteServer to inform runmanager that something about globals has changed, and that they need parsing again.

guess_expansion_modes(active_groups, evaled_globals, global_hierarchy, expansions)[source]

This function is designed to be called iteratively. It changes the expansion type of globals that reference other globals - such that globals referencing an iterable global will be zipped with it, rather than outer producted. Each time this method is called, self.parse_globals should also be called, so that the globals are evaluated with their new expansion modes, if they changed. This should be performed repeatedly until there are no more changes. Note that this method does not return what expansion types it thinks globals should have - it actually writes them to the globals HDF5 file. So it is up to later code to ensure it re-reads the expansion mode from the HDF5 file before proceeding. At present this method is only called from self.preparse_globals(), so see there to see how it fits in with everything else. This method uses four instance attributes to store state: self.previous_evaled_globals, self.previous_global_hierarchy, self.previous_expansion_types and self.previous_expansions. This is neccesary so that it can detect changes.

load_configuration(filename)[source]
make_group_row(group_name)[source]

Returns a new row representing one group in the groups tab, ready to be inserted into the model.

make_h5_files(labscript_file, output_folder, sequence_globals, shots, shuffle)[source]
new_group(globals_file, group_name)[source]
on_abort_clicked()[source]
on_axes_check_selected_triggered(*args)[source]
on_axes_item_changed(item)[source]
on_axes_uncheck_selected_triggered(*args)[source]
on_axis_down_clicked(checked)[source]
on_axis_to_bottom_clicked(checked)[source]
on_axis_to_top_clicked(checked)[source]
on_axis_up_clicked(checked)[source]
on_close_event()[source]
on_diff_globals_file_clicked()[source]
on_edit_labscript_file_clicked(checked)[source]
on_engage_clicked()[source]
on_groups_close_selected_files_triggered()[source]
on_groups_close_selected_groups_triggered()[source]
on_groups_copy_selected_groups_triggered(dest_globals_file=None, delete_source_group=False)[source]
on_groups_delete_selected_triggered()[source]
on_groups_model_active_changed(item)[source]

Sets the sort data for the item in response to its check state changing. Also, if this is the first time this function has been called on the stack, that is, the change was initiated externally instead of via recursion from this function itself, then set the check state of other items for consistency. This entails checking/unchecking all group rows in response to the file row’s check state changing, or changing the file row’s check state to reflect the check state of the child group rows. That’s why we need to keep track of the recursion depth - so that those changes we make don’t in turn cause further changes. But we don’t disconnect the on_changed signal altogether, because we still want to do the update of the sort data, and anything else that might be added in future.

on_groups_model_item_changed(item)[source]

This function is for responding to data changes in the model. The methods for responding to changes different columns do different things. Mostly they make other data changes for model consistency, but also group creation and renaming is handled in response to changes to the ‘name’ column. When we change things elsewhere, we prefer to only change one thing, and the rest of the changes are triggered here. So here we do the following:

Be careful not to recurse unsafely into this method - changing something that itself triggers further changes is fine so long as they peter out and don’t get stuck in a loop. If recursion needs to be stopped, one can disconnect the signal temporarily with the context manager self.groups_model_item_changed_disconnected. But use this sparingly, otherwise there’s the risk that some required data updates will be forgotten about and won’t happen.

on_groups_model_name_changed(item)[source]

Handles group renaming and creation of new groups due to the user editing the <click to add group> item

on_groups_model_openclose_changed(item)[source]

Sets item sort data and icon in response to the open/close state of a group changing.

on_groups_open_selected_triggered()[source]
on_groups_set_selection_active_triggered(checked_state)[source]
on_labscript_file_text_changed(text)[source]
on_load_configuration_triggered()[source]
on_master_shuffle_clicked(state)[source]
on_new_globals_file_clicked()[source]
on_open_globals_file_clicked()[source]
on_output_popout_button_clicked()[source]
on_reset_shot_output_folder_clicked(checked)[source]
on_restart_subprocess_clicked()[source]
on_revert_configuration_triggered()[source]
on_save_configuration_as_triggered()[source]
on_save_configuration_triggered()[source]
on_select_labscript_file_clicked(checked)[source]
on_select_shot_output_folder_clicked(checked)[source]
on_shot_output_folder_text_changed(text)[source]
on_tabCloseRequested(index)[source]
on_treeView_axes_context_menu_requested(point)[source]
on_treeView_groups_context_menu_requested(point)[source]
on_treeView_groups_doubleLeftClicked(index)[source]
on_treeView_groups_leftClicked(index)[source]

Here we respond to user clicks on the treeview. We do the following:

  • If the user clicks on the <click to add group> dummy row, we go into edit mode on it so they can enter the name of the new group they want.

  • If the user clicks on the icon to open or close a globals file or a group, we call the appropriate open and close methods and update the open/close data role on the model.

  • If the user clicks delete on a globals group, we call a delete method, which deletes it after confirmation, and closes it if it was open.

open_globals_file(globals_file)[source]
open_group(globals_file, group_name, trigger_preparse=True)[source]
parse_globals(active_groups, raise_exceptions=True, expand_globals=True, expansion_order=None, return_dimensions=False)[source]
preparse_globals()[source]
preparse_globals_loop()[source]

Runs in a thread, waiting on a threading.Event that tells us when some globals have changed, and calls parse_globals to evaluate them all before feeding the results back to the relevant tabs to be displayed.

rename_group(globals_file, previous_group_name, new_group_name)[source]
rollover_shot_output_folder()[source]

Runs in a thread, checking every 30 seconds if the default output folder has changed, likely because the date has changed, but also possible because another instance of runmanager has incremented the sequence index. If the defaulr output folder has changed, and if runmanager is configured to use the default output folder, sets the folder in which compiled shots will be put. Does not create the folder if it does not already exist, this will be done at compile-time.

save_configuration(save_file)[source]
send_to_BLACS(run_file, BLACS_hostname)[source]
send_to_runviewer(run_file)[source]
setup_axes_tab()[source]
setup_config()[source]
setup_groups_tab()[source]
switch_tabs(change)[source]
update_axes_indentation()[source]
update_axes_tab(expansions, dimensions)[source]
update_global_shuffle_state(*args, **kwargs)[source]
update_tabs_parsing_indication(active_groups, sequence_globals, evaled_globals, n_shots)[source]
wait_until_preparse_complete()[source]

Block until the preparse loop has finished pending work