13.1. The core
¶
Subpackages¶
- Execution:
execution
- base_execution_history
BaseExecutionHistory
BaseExecutionHistory.destroy()
BaseExecutionHistory.feed_consumers()
BaseExecutionHistory.get_last_history_item()
BaseExecutionHistory.push_call_history_item()
BaseExecutionHistory.push_concurrency_history_item()
BaseExecutionHistory.push_return_history_item()
BaseExecutionHistory.push_state_machine_start_history_item()
BaseExecutionHistory.shutdown()
- consumer_manager
ExecutionHistoryConsumerManager
ExecutionHistoryConsumerManager.FILE_SYSTEM_CONSUMER_NAME
ExecutionHistoryConsumerManager.add_history_item_to_queue()
ExecutionHistoryConsumerManager.consumers_exist
ExecutionHistoryConsumerManager.file_system_consumer_exists
ExecutionHistoryConsumerManager.get_file_system_consumer_file_name()
ExecutionHistoryConsumerManager.register_consumer()
ExecutionHistoryConsumerManager.stop_consumers()
ExecutionHistoryConsumerManager.stop_worker_thread()
ExecutionHistoryConsumerManager.unregister_consumer()
- state_machine_execution_engine
- execution_history_factory
- execution_history_items
- execution_status
- in_memory_execution_history
InMemoryExecutionHistory
InMemoryExecutionHistory.destroy()
InMemoryExecutionHistory.get_last_history_item()
InMemoryExecutionHistory.pop_last_item()
InMemoryExecutionHistory.push_call_history_item()
InMemoryExecutionHistory.push_concurrency_history_item()
InMemoryExecutionHistory.push_return_history_item()
InMemoryExecutionHistory.push_state_machine_start_history_item()
InMemoryExecutionHistory.shutdown()
- abstract_execution_history_consumer
- file_system_consumer
- base_execution_history
- StateElements:
state_elements
- States:
states
- barrier_concurrency
- concurrency_state
- container_state
ContainerState
ContainerState.add_data_flow()
ContainerState.add_default_values_of_scoped_variables_to_scoped_data()
ContainerState.add_input_data_to_scoped_data()
ContainerState.add_scoped_variable()
ContainerState.add_state()
ContainerState.add_state_execution_output_to_scoped_data()
ContainerState.add_transition()
ContainerState.change_state_id()
ContainerState.change_state_type()
ContainerState.check_child_validity()
ContainerState.check_data_flow_id()
ContainerState.check_data_port_connection()
ContainerState.check_transition_id()
ContainerState.data_flows
ContainerState.destroy()
ContainerState.from_dict()
ContainerState.get_connections_for_state()
ContainerState.get_connections_for_state_and_scoped_variables()
ContainerState.get_data_port()
ContainerState.get_data_port_by_id()
ContainerState.get_data_port_ids()
ContainerState.get_inputs_for_state()
ContainerState.get_number_of_data_flows()
ContainerState.get_number_of_transitions()
ContainerState.get_outcome()
ContainerState.get_scoped_variable_from_name()
ContainerState.get_start_state()
ContainerState.get_state_for_transition()
ContainerState.get_states_statistics()
ContainerState.get_transition_for_outcome()
ContainerState.group_states()
ContainerState.handle_no_start_state()
ContainerState.handle_no_transition()
ContainerState.is_dummy
ContainerState.missing_library_meta_data
ContainerState.recursively_pause_states()
ContainerState.recursively_preempt_states()
ContainerState.recursively_resume_states()
ContainerState.remove()
ContainerState.remove_data_flow()
ContainerState.remove_data_flows_with_data_port_id()
ContainerState.remove_outcome_hook()
ContainerState.remove_scoped_variable()
ContainerState.remove_state()
ContainerState.remove_transition()
ContainerState.run()
ContainerState.scoped_data
ContainerState.scoped_variables
ContainerState.set_start_state()
ContainerState.setup_run()
ContainerState.start_state_id
ContainerState.state_to_dict()
ContainerState.states
ContainerState.substitute_state()
ContainerState.transitions
ContainerState.ungroup_state()
ContainerState.update_hash()
ContainerState.update_scoped_variables_with_output_dictionary()
ContainerState.write_output_data()
- execution_state
- hierarchy_state
- library_state
LibraryState
LibraryState.add_input_data_port()
LibraryState.add_outcome()
LibraryState.add_output_data_port()
LibraryState.destroy()
LibraryState.from_dict()
LibraryState.get_number_of_data_flows()
LibraryState.get_number_of_transitions()
LibraryState.get_states_statistics()
LibraryState.get_storage_path()
LibraryState.input_data_port_runtime_values
LibraryState.library_hierarchy_depth
LibraryState.library_name
LibraryState.library_path
LibraryState.output_data_port_runtime_values
LibraryState.recursively_pause_states()
LibraryState.recursively_preempt_states()
LibraryState.recursively_resume_states()
LibraryState.remove_input_data_port()
LibraryState.remove_outcome()
LibraryState.remove_output_data_port()
LibraryState.run()
LibraryState.set_input_runtime_value()
LibraryState.set_output_runtime_value()
LibraryState.set_use_input_runtime_value()
LibraryState.set_use_output_runtime_value()
LibraryState.state_copy
LibraryState.state_to_dict()
LibraryState.update_hash()
LibraryState.use_runtime_value_input_data_ports
LibraryState.use_runtime_value_output_data_ports
LibraryState.version
- preemptive_concurrency
- state
State
State.active
State.add_input_data_port()
State.add_outcome()
State.add_output_data_port()
State.add_semantic_data()
State.change_state_id()
State.check_child_validity()
State.check_input_data_type()
State.check_output_data_type()
State.concurrency_queue
State.core_element_id
State.create_output_dictionary_for_state()
State.description
State.destroy()
State.file_system_path
State.final_outcome
State.finalize()
State.from_dict()
State.generate_run_id()
State.get_data_port_by_id()
State.get_data_port_ids()
State.get_default_input_values_for_state()
State.get_io_data_port_id_from_name_and_type()
State.get_next_upper_library_root_state()
State.get_number_of_data_flows()
State.get_number_of_transitions()
State.get_path()
State.get_previously_executed_state()
State.get_semantic_data()
State.get_state_machine()
State.get_states_statistics()
State.get_storage_path()
State.get_temp_file_system_path()
State.get_uppermost_library_root_state()
State.id()
State.income
State.input_data
State.input_data_ports
State.is_root_state
State.is_root_state_of_library
State.join()
State.name
State.outcomes
State.output_data
State.output_data_ports
State.parent
State.paused
State.preempted
State.preemptive_wait()
State.recursively_pause_states()
State.recursively_preempt_states()
State.recursively_resume_states()
State.remove()
State.remove_data_flows_with_data_port_id()
State.remove_income()
State.remove_input_data_port()
State.remove_outcome()
State.remove_outcome_hook()
State.remove_output_data_port()
State.remove_semantic_data()
State.run()
State.run_id
State.semantic_data
State.setup_backward_run()
State.setup_run()
State.start()
State.started
State.state_element_attrs
State.state_execution_status
State.state_id
State.state_to_dict()
State.to_dict()
State.update_hash()
State.wait_for_interruption()
State.wait_for_unpause()
StateExecutionStatus
StateType
- Storage:
storage
- storage (in rafcon.core.storage)
FILE_NAME_META_DATA
clean_path()
clean_path_element()
clean_path_from_deprecated_naming()
find_library_dependencies_via_grep()
get_core_data_path()
get_meta_data_path()
get_storage_id_for_state()
limit_text_max_length()
limit_text_to_be_path_element()
load_data_file()
load_state_recursively()
reconnect_data_flow()
remove_obsolete_folders()
save_script_file_for_state_and_source_path()
save_semantic_data_for_state()
save_state_machine_to_path()
save_state_recursively()
- storage (in rafcon.core.storage)
config¶
- class rafcon.core.config.Config(logger_object=None)¶
Bases:
ObservableConfig
Class to hold and load the global state machine configurations.
- keys_requiring_restart = ()¶
- load(config_file=None, path=None)¶
Loads the configuration from a specific file
- Parameters:
config_file – the name of the config file
path – the path to the config file
- class rafcon.core.config.ObservableConfig(default_config_string, logger_object=None)¶
Bases:
DefaultConfig
,Observable
- as_dict()¶
Returns the configuration as dict
- Returns:
A copy of the whole configuration as dict
- Return type:
- get_config_value(key, default=None)¶
Overwrites the default behavior of the get_config_value method of the DefaultConfig base class It supports the
- Parameters:
key – the key to the configuration value
default – what to return if the key is not found
- Returns:
The value for the given key, if the key was found. Otherwise the default value
- is_config_loaded_from_file()¶
Returns if the configuration values were loaded from a custom file (and are thus not simply initiated from the default config any more).
- Returns:
a flag indicating if the config was loaded from a file
- property keys¶
- keys_requiring_restart = {}¶
- keys_requiring_state_machine_refresh = {}¶
- set_config_value(**kwargs)¶
Get a specific configuration value
- Parameters:
key – the key to the configuration value
value – The new value to be set for the given key
custom_exceptions¶
- exception rafcon.core.custom_exceptions.RecoveryModeException(message, do_delete_item)¶
Bases:
ValueError
- property do_delete_item¶
Property for the do_delete_item field
constants (in rafcon.core)¶
global_variable_manager¶
id_generator¶
- rafcon.core.id_generator.generate_data_flow_id()¶
- rafcon.core.id_generator.generate_data_port_id(used_data_port_ids)¶
Create a new and unique data port id
- rafcon.core.id_generator.generate_outcome_id(used_outcome_ids)¶
- rafcon.core.id_generator.generate_script_id()¶
- rafcon.core.id_generator.generate_semantic_data_key(used_semantic_keys)¶
Create a new and unique semantic data key
- rafcon.core.id_generator.generate_state_machine_id()¶
Generates an id for a state machine. It simply uses a global counter that is increased each time. :return: a new state machine id
- rafcon.core.id_generator.generate_state_name_id()¶
Generates an id for a state
It simply uses a global counter that is increased each time. It is intended for the name of a new state.
- Returns:
a new state machine id
- rafcon.core.id_generator.generate_transition_id()¶
- rafcon.core.id_generator.global_variable_id_generator(size=10, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ')¶
Create a new and unique global variable id
Generates an id for a global variable. It randomly samples from random ascii uppercase letters size times and concatenates them. If the id already exists it draws a new one.
- Parameters:
size – the length of the generated keys
chars – the set of characters a sample draws from
- rafcon.core.id_generator.history_item_id_generator()¶
- rafcon.core.id_generator.run_id_generator()¶
- rafcon.core.id_generator.state_id_generator(size=6, chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ', used_state_ids=None)¶
Create a new and unique state id
Generates an id for a state. It randomly samples from random ascii uppercase letters size times and concatenates them. If the id already exists it draws a new one.
interface¶
- rafcon.core.interface.create_folder_cmd_line(query, default_name=None, default_path=None)¶
Queries the user for a path to be created
- Parameters:
- Returns:
Input path from the user or default_path if nothing is specified or None if directory could ne be created
- Return type:
- rafcon.core.interface.create_folder_func(query, default_name=None, default_path=None)¶
Queries the user for a path to be created
- Parameters:
- Returns:
Input path from the user or default_path if nothing is specified or None if directory could ne be created
- Return type:
- rafcon.core.interface.open_folder_cmd_line(query, default_path=None)¶
Queries the user for a path to open
- rafcon.core.interface.open_folder_func(query, default_path=None)¶
Queries the user for a path to open
- rafcon.core.interface.save_folder_cmd_line(query, default_name=None, default_path=None)¶
Queries the user for a path or file to be saved into
The folder or file has not to be created already and will not be created by this function. The parent directory of folder and file has to exist otherwise the function will return None.
- Parameters:
- Returns:
Input path from the user or default_path if nothing is specified and None if directory does not exist
- Return type:
library_manager¶
script¶
- class rafcon.core.script.Script(path=None, filename=None, parent=None)¶
Bases:
Observable
,YAMLObject
A class for representing the script file for all execution states in a state machine.
It inherits from Observable to make a change of its fields observable.
- Variables:
path – the path where the script resides
filename – the full name of the script file
_compiled_module – the compiled module
_script_id – the id of the script
check_path – a flag to indicate if the path should be checked for existence
- compile_module()¶
Builds a temporary module from the script file
- Raises:
exceptions.IOError – if the compilation of the script module failed
- property compiled_module¶
Return the compiled module
- execute(state, inputs=None, outputs=None, backward_execution=False)¶
Execute the user ‘execute’ function specified in the script
- Parameters:
state (ExecutionState) – the state belonging to the execute function, refers to ‘self’
inputs (dict) – the input data of the script
outputs (dict) – the output data of the script
backward_execution (bool) – Flag whether to run the script in backwards mode
- Returns:
Return value of the execute script
- Return type:
- property filename¶
Property for the _filename field
- property parent¶
Property for the _parent field
- property path¶
- property script¶
- set_script_without_compilation(script_text)¶
singleton (in rafcon.core)¶
state_machine¶
- class rafcon.core.state_machine.StateMachine(root_state=None, version=None, creation_time=None, state_machine_id=None)¶
Bases:
Observable
,JSONObject
,Hashable
A class for to organizing all main components of a state machine
It inherits from Observable to make a change of its fields observable.
- Variables:
- acquire_modification_lock(blocking=True)¶
Acquires the modification lock of the state machine
This must be used for all methods, that perform any modifications on the state machine
- change_root_state_type(**kwargs)¶
- clear_execution_histories(**kwargs)¶
- destroy_execution_histories()¶
- property execution_histories¶
- property file_system_path¶
Property for the _file_system_path field
- classmethod from_dict(dictionary, state_machine_id=None)¶
Abstract method
This method must be implemented by the deriving classes. It must return an object of type cls, created from the parameters defined in dictionary. The type of cls is the type of the class the method is called on.
- Parameters:
dictionary (dict) – A Python dict with all parameters needed for creating an object of type cls
- Returns:
An instance of cls
- Return type:
cls
- get_last_execution_log_filename()¶
- get_modification_lock()¶
- get_state_by_path(path, as_check=False)¶
- join()¶
Wait for root state to finish execution
- property marked_dirty¶
Property for the _marked_dirty field
- modification_lock(blocking=True)¶
Get modification lock in with() statement
- Parameters:
blocking (bool) – When True, block until the lock is unlocked, then set it to locked
- release_modification_lock()¶
Releases the acquired state machine modification lock.
- property root_state¶
Property for the _root_state field
- start()¶
Starts the execution of the root state.
- state_machine_id = None¶
- static state_machine_to_dict(state_machine)¶
- property supports_saving_state_names¶
- to_dict()¶
Abstract method
This method must be implemented by the deriving classes. It must return a Python dict with all parameters of self, which are needed to create a copy of self.
- Returns:
A Python dict with all needed parameters of self
- Return type:
- update_hash(obj_hash)¶
Should be implemented by derived classes to update the hash with their data fields
- Parameters:
obj_hash – The hash object (see Python hashlib)
- version = None¶