msticpy.config.query_editor module

Query Editor.

class msticpy.config.query_editor.CustomChange(new)

Bases: object

Dummy ipywidgets change event.

Parameters:

new (Any)

new: Any
class msticpy.config.query_editor.IPyDisplayMixin(*args, **kwargs)

Bases: LayoutProperties

IPython display mixin class.

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

Any

display()

Display the interactive widgets.

Parameters:

self (Self)

Return type:

None

class msticpy.config.query_editor.MetadataEditWidget(*args, **kwargs)

Bases: IPyDisplayMixin

A class for editing Metadata properties.

Initialize a MetadataEditWidget object.

Parameters:

metadata (Metadata) – A Metadata object.

property changed_data: bool

Return True if data has changed.

cluster_groups_widget: widgets.Textarea
cluster_widget: widgets.Text
clusters_widget: widgets.Textarea
data_env_widget: widgets.SelectMultiple
data_families_widget: widgets.Textarea
data_source_widget: widgets.Text
database_widget: widgets.Text
description_widget: widgets.Text
display()

Display the GUI widget.

Parameters:

self (Self)

Return type:

None

layout: widgets.VBox
metadata: QueryMetadata
populate_widgets()

Populate the widgets with the metadata of the Metadata object.

Parameters:

self (Self)

Return type:

None

reset_changed_data()

Reset changed data flag.

Parameters:

self (Self)

Return type:

None

save_metadata(button)

Save the values to the Metadata object.

Parameters:
  • self (Self)

  • button (ipywidgets.Button)

Return type:

None

save_metadata_widget: widgets.Button
set_metadata(metadata)

Set the metadata object.

Parameters:
Return type:

None

tags_widget: widgets.Text
version_widget: widgets.IntText
class msticpy.config.query_editor.QueryEditWidget(*args, **kwargs)

Bases: IPyDisplayMixin

A class for editing queries.

Initialize a QueryEditWidget object.

Parameters:

query_collection (QueryCollection) – A collection of queries.

add_query(button)

Add a new query.

Parameters:
  • button (Button) – The button object.

  • self (Self)

Return type:

None

add_query_button: widgets.Button
property changed_data: bool

Return True if data has changed.

delete_query(button)

Delete a query.

Parameters:
  • button (Button) – The button object.

  • self (Self)

Return type:

None

delete_query_button: widgets.Button
description_widget: widgets.Text
display()

Display the interactive widgets.

Parameters:

self (Self)

Return type:

None

layout: widgets.VBox
metadata_widget: widgets.Textarea
name_widget: widgets.Text
parameters: QueryParameterEditWidget | None
populate_query_dropdown(change)

Populate the query dropdown widget.

Parameters:
  • change (Any) – The change event.

  • self (Self)

Return type:

None

populate_widgets(change)

Populate the query widgets with the data of a query.

Parameters:
  • change (Any) – The change event.

  • self (Self)

Return type:

None

queries_widget: widgets.VBox
query_collection: QueryCollection
query_opts_widget: widgets.Accordion
query_select_widget: widgets.Select
query_text_widget: widgets.Textarea
reset_changed_data()

Reset changed data flag.

Parameters:

self (Self)

Return type:

None

save_query(button)

Save the data of a query.

Parameters:
  • button (Button) – The button object.

  • self (Self)

Return type:

None

save_query_button: widgets.Button
set_query_collection(query_collection)

Set the query collection.

Parameters:
Return type:

None

class msticpy.config.query_editor.QueryEditor(*args, **kwargs)

Bases: IPyDisplayMixin

Query template editor.

Initialize the QueryEditor.

Parameters:

query_file (Union[QueryCollection, Path, str, None], optional) – The query collection to edit, can be a string or pathlib Path object for a file to load, or a QueryCollection object. By default None

collection_accordion: widgets.Accordion
property current_file: str

Return the current file name.

default_param_editor: QueryParameterEditWidget
display()

Display the interactive widgets.

Parameters:

self (Self)

Return type:

None

filename_widget: widgets.Text
ignore_changes: widgets.Checkbox
layout: widgets.VBox
metadata_editor: MetadataEditWidget
new_button: widgets.Button
open_button: widgets.Button
query_collection: QueryCollection
query_editor: QueryEditWidget
save_button: widgets.Button
class msticpy.config.query_editor.QueryParameterEditWidget(*args, **kwargs)

Bases: IPyDisplayMixin

Class to manage editing of query parameters.

This class provides a graphical user interface for editing query parameters. It allows users to add, modify, and delete parameters, as well as specify their names, descriptions, types, default values, and whether they are mandatory.

Parameters:

container (Query | QueryDefaults)

_changed_data

A flag indicating whether the data has been changed.

Type:

bool

param_container

The container for the query parameters.

Type:

Union[Query, QueryDefaults]

parameter_dropdown

A widget for selecting a parameter to edit.

Type:

ipywidgets.Select

parameter_name_widget

A widget for editing the name of a parameter.

Type:

ipywidgets.Text

description_widget

A widget for editing the description of a parameter.

Type:

ipywidgets.Text

type_widget

A widget for selecting the type of a parameter.

Type:

ipywidgets.Dropdown

default_reqd_widget

A widget for indicating whether a default value is required for a parameter.

Type:

ipywidgets.Checkbox

Initialize the class.

add_parameter(button)

Add a new parameter.

Parameters:
  • self (Self)

  • button (ipywidgets.Button)

Return type:

None

add_parameter_button: widgets.Button
property changed_data: bool

Return True if data has changed.

default_reqd_widget: widgets.Checkbox
default_widget: widgets.Text
delete_parameter(button)

Delete parameter item.

Parameters:
  • self (Self)

  • button (ipywidgets.Button)

Return type:

None

delete_parameter_button: widgets.Button
description_widget: widgets.Text
display()

Display the interactive widgets.

Parameters:

self (Self)

Return type:

None

layout: widgets.VBox
param_container: Query | QueryDefaults
parameter_dropdown: widgets.Select
parameter_name_widget: widgets.Text
populate_widgets(change)

Populate parameter value in widgets.

Parameters:
Return type:

None

reset_changed_data()

Reset changed data flag.

Parameters:

self (Self)

Return type:

None

save_parameter(button)

Save currently edited parameter.

Parameters:
  • self (Self)

  • button (ipywidgets.Button)

Return type:

None

save_parameter_button: widgets.Button
set_param_container(container)

Set the parameter container.

Parameters:
Return type:

None

type_widget: widgets.Dropdown
class msticpy.config.query_editor.YamlLiteralBlockContext(dumper=<class 'yaml.dumper.SafeDumper'>)

Bases: object

Context manager to temporarily force multiline strings to literal style.

Initialize the context manager.

Parameters:

dumper (type[yaml.SafeDumper])

dumper: type[SafeDumper]
old_representer: Callable[[BaseRepresenter, Any], Node] | None
msticpy.config.query_editor.box_layout()

Return a dictionary with layout and style for a box widget.

Returns:

A dictionary with layout and style for a select widget.

Return type:

Dict

msticpy.config.query_editor.load_queries_from_yaml(yaml_file)

Load a YAML file into a QueryCollection.

Parameters:

yaml_file (Union[str, Path]) – The path to the YAML file to load.

Returns:

A QueryCollection object containing the loaded queries.

Return type:

QueryCollection

msticpy.config.query_editor.replace_in_query(param_name, param, src_name, query)

Replace a parameter in a query string with a formatted string.

Parameters:
  • param_name (str) – The name of the parameter to replace.

  • param (Parameter) – The parameter object containing the datatype of the parameter.

  • src_name (str) – The name of the source to replace in the query string.

  • query (str) – The query string to replace the source in.

Returns:

The query string with the source replaced by the formatted parameter string.

Return type:

str

msticpy.config.query_editor.save_queries_to_yaml(query_collection, yaml_file)

Save a QueryCollection to a YAML file.

Parameters:
  • query_collection (QueryCollection) – The QueryCollection object to save to YAML.

  • yaml_file (Union[str, Path]) – The path to the YAML file to save.

Return type:

None

msticpy.config.query_editor.sel_fmt(width='40%', height='150px')

Return a dictionary with layout and style for a select widget.

Parameters:
  • width (str, optional) – The width of the widget, by default “40%”

  • height (str, optional) – The height of the widget, by default “150px”

Returns:

A dictionary with layout and style for a select widget.

Return type:

Dict

msticpy.config.query_editor.txt_fmt(width='70%')

Return a dictionary with layout and style for a text widget.

Parameters:
  • width (str, optional) – The width of the widget, by default “70%”

  • height (str, optional) – The height of the widget, by default “20px”

Returns:

A dictionary with layout and style for a text widget.

Return type:

Dict

msticpy.config.query_editor.txtarea_fmt(width='70%', height='150px')

Return a dictionary with layout and style for a textarea widget.

Parameters:
  • width (str, optional) – The width of the widget, by default “70%”

  • height (str, optional) – The height of the widget, by default “150px”

Returns:

A dictionary with layout and style for a textarea widget.

Return type:

Dict