atomiq.tools.atomiq_component_creator module

A helper program to create components for the components db dictionary.

main screen
atomiq.tools.atomiq_component_creator.import_components(modules)[source]

Imports all submodules from a module to make components inside that module visible to the component creator tool.

Parameters:

modules (List) -- List of modules, can be either strings or the modules itself

Return type:

None

atomiq.tools.atomiq_component_creator.class_from_name_only(sstr)[source]

Inferes a type from a name string by searching in all imported modules for the class name sstr If multiple types are found, the most likely one is chosen based on an assesment of the parent module. If no type with the given name is found returns None.

Parameters:

sstr (str) -- name of the class to search for

Return type:

Type | None

atomiq.tools.atomiq_component_creator.class_from_full_string(sstr)[source]

Generate a class Type from a full string.

Parameters:

sstr (str) -- a full class path like e.g. "atomiq.components.sinara.suservo.SUServoModulatedLaser"

Return type:

Type

atomiq.tools.atomiq_component_creator.get_inheritors(klass)[source]

Recursively gets all loaded classes which are abstracting from class klass

Parameters:

klass (Type)

Return type:

List[Type]

atomiq.tools.atomiq_component_creator.get_recursive_args(klass, kwargs_modifications=None, optionals=False)[source]

Analyzes the call signature of the __init__ function of klass to find which arguments are mandatory. This is performed recursively through all base classes.

Parameters:
  • kwargs_modifications (List | None) -- List of kwargs defined in an __init__ function which are passed down to parent classes

  • optionals (bool) -- If True return optional args, if false return mandatory args

  • klass (Type)

Return type:

List

atomiq.tools.atomiq_component_creator.editable_default_input(prompt, default)[source]

Helper function to generate a cli prompt with default input which can be edited by the user

Parameters:
  • prompt (str) -- Non-editable text to show

  • default (str) -- Editable default value

Return type:

str

Helper function to generate a link to the atomiq gitlab pages documentation of a given class target_class. Returns None if the class does not belong to atomiq.

Parameters:

target_class (Type)

Return type:

str | None

class atomiq.tools.atomiq_component_creator.ComponentEntry(name, target_class)[source]

Bases: object

Class representing a component configured in the components dictionary

Parameters:
  • name (str) -- name of the component as in the components dict

  • target_class (Type) -- type of the target class

static init_from_template_dict(name, component_dict)[source]

Initializes a component from a single component dictionary entry as saved in the components database or a template.

Parameters:
  • name (str) -- name of the component

  • component_dict (dict[str, Any]) -- single component component dict entry

Return type:

ComponentEntry

populate_from_template_dict(component_dict)[source]

Populate a component recursively from a component dictionary as saved in the components database or a template

Parameters:

component_dict (dict[str, Any]) -- full component dict

Return type:

None

property configured

Returns true if all required arguments of this and all its subcomponents are set

generate_component_dict(component_dict)[source]

Generate a component dict entry for this component and all child components recursively. The entry is directly added to the dict passed in component_dict.

Parameters:

component_dict (dict[str, Any]) -- dictionary this component is added to

Return type:

None

get_undefined_args()[source]

Returns a list of all required arguments of this and all its subcomponents which are not yet defined/set

Return type:

List

get_fixed_args()[source]

Returns a list of all arguments of this and all its subcomponents which are defined by a fixed value (not a subcomponent)

Return type:

List

get_modified_args()[source]

Returns all arguments which are either required or kwargs which differ from their default value

Return type:

List

set_base_name(old_value, new_value)[source]

Set the base name of this component and all its subcomponents

Parameters:
  • old_value (str) -- old base name used to identify the base name in the full name

  • new_value (str) -- new base name with which the string old_value is replaced

Return type:

None

class atomiq.tools.atomiq_component_creator.ArgumentEntry(arg, parent)[source]

Bases: object

This class represents an argument of a component init function.

Parameters:
  • arg (inspect.Parameter) -- argument of a component as given by introspection of the component

  • parent (ComponentEntry) -- the component this argument is part of

unit = None
default = None
optional = False
property configured

Is true if the set value is not None or, if the value is a subcomponent, this component is fully configured

property value

Current set value of the argument. When setting this argument, the value is automatically cast to the correct type as required by this argument"

get_print_value()[source]

Get a nice representation of the argument value usable with the rich module and in correct representation for writing to a components dict

Return type:

PrettyValue

get_print_default()[source]

Get a nice representation of the default argument value usable with the rich module and in correct representation for writing to a components dict

Return type:

PrettyValue

class atomiq.tools.atomiq_component_creator.PrettyValue(value, unit)[source]

Bases: object

Pretty printable value which implements a rich representation and a representation compatible with the components dict syntax

atomiq.tools.atomiq_component_creator.selection_gui(func)[source]

Decorator function for interactive screens allowing for going back a screen, auto clearing the console on screen change and going back a screen on error.

Parameters:

func (Callable)

Return type:

Callable

class atomiq.tools.atomiq_component_creator.InteractiveBuilder(config)[source]

Bases: object

Implements an interactive cli builder for configuring components and getting information on the current configuration status. The implementation uses the rich package to print to the command line

Parameters:

config (dict[str, Any]) -- parsed atomiq tool config dictionary as defined in atomiq_tools.toml

base_name

base name string of the root component which is added to all subcomponents

Type:

str

base_component

Type of the root component (e.q. atomiq.components.sinara.suservo.SUServoModulatedLaser)

Type:

Type

base_name: str
base_component: Type
start_from_class(target_class, name)[source]

Start the cli tool from a single, non configured component

Parameters:
  • target_class (Type) -- Type of the target component class

  • name (str) -- name of the root component, used as a base name for all subcomponents

Return type:

None

go_back(index=-2)[source]

Go back by index steps in the cli screen history.

Parameters:

index (int) -- determines how far to go back in screen history. The default of -2 corresponds to the last screen, since -1 is the current screen

Return type:

None

generate_name(component_type)[source]

Generate a component name based on its class of the form {class_name}_{base_name}. If an abbreviation is found in the config["abbreviations"] dict, the abbreviation is used as name prefix

Parameters:

component_type (str) -- name of the component class type

Return type:

str

save_template(f_name)[source]

Save the current component dict as a template as a python file

Parameters:

f_name (str) -- Name of the output file

Return type:

None

load_template(f_name)[source]

Start the cli by loading and populating components from a template file

Parameters:

f_name (str) -- Name of the imput template file

Return type:

None

generate_component_dict()[source]

Generate a component dict by recursively gathering all configured component entries

get_undefined_args()[source]

Returns a list of all required arguments of all configured components which are not yet defined/set

Return type:

list

get_fixed_args()[source]

Returns a list of all arguments of all configured components which are either set to a excplicit value or are optional args differing from their default value

Return type:

list

set_base_name(value)[source]

Recursively set the base name of all configured components

Parameters:

value (str)

Return type:

None

print_class_selection(*args, **kwargs)[source]
print_arg_possibilities(*args, **kwargs)[source]
tree_view(*args, **kwargs)[source]
print_undefined_args(*args, **kwargs)[source]
print_fixed_args(*args, **kwargs)[source]
atomiq.tools.atomiq_component_creator.get_argparser()[source]
Return type:

ArgumentParser

atomiq.tools.atomiq_component_creator.main()[source]