string
string.deserialize
                                                                                
 Documentation                                                                  
                          -- n/a --                                             
                                                                                
 Origin                                                                         
                          Authors   Markus Binsteiner (markus@frkl.io)          
                                                                                
 Context                                                                        
                          Tags         core                                     
                          Labels       package: kiara_modules.core              
                          References   source_repo:                             
                                       https://github.com/DHARPA-Project/kia…   
                                       documentation:                           
                                       https://dharpa.org/kiara_modules.core/   
                                       module_doc:                              
                                       https://dharpa.org/kiara_modules.core…   
                                       source_url:                              
                                       https://github.com/DHARPA-Project/kia…   
                                                                                
 Module config                                                                  
                          Field            Type     Description      Required   
                         ─────────────────────────────────────────────────────  
                          constants        object   Value            no         
                                                    constants for               
                                                    this module.                
                          defaults         object   Value defaults   no         
                                                    for this                    
                                                    module.                     
                          serialization…   string   The              yes        
                                                    serialization               
                                                    type that was               
                                                    used to                     
                                                    serialize the               
                                                    value.                      
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    DeserializeStringModule                 
                          module_name   kiara_modules.core.string               
                          full_name     kiara_modules.core.string.Deserializ…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              serialization_type = self.get_config_value("se…   
                              if serialization_type not in ["json"]:            
                                  raise KiaraProcessingException(               
                                      f"Can't deserialize string: serialisat…   
                                  )                                             
                                                                                
                              serialized = inputs.get_value_data("serialized…   
                              outputs.set_value("value_item", serialized)       
                                                                                
                         ─────────────────────────────────────────────────────  
                                                                                
string.match_regex
                                                                                
 Documentation                                                                  
                          Match a string using a regular expression.            
                                                                                
 Origin                                                                         
                          Authors   Markus Binsteiner (markus@frkl.io)          
                                                                                
 Context                                                                        
                          Tags         core                                     
                          Labels       package: kiara_modules.core              
                          References   source_repo:                             
                                       https://github.com/DHARPA-Project/kia…   
                                       documentation:                           
                                       https://dharpa.org/kiara_modules.core/   
                                       module_doc:                              
                                       https://dharpa.org/kiara_modules.core…   
                                       source_url:                              
                                       https://github.com/DHARPA-Project/kia…   
                                                                                
 Module config                                                                  
                          Field            Type      Description     Required   
                         ─────────────────────────────────────────────────────  
                          constants        object    Value           no         
                                                     constants for              
                                                     this module.               
                          defaults         object    Value           no         
                                                     defaults for               
                                                     this module.               
                          regex            string    The regex to    yes        
                                                     apply.                     
                          only_first_ma…   boolean   Whether to      no         
                                                     only return                
                                                     the first                  
                                                     match, or all              
                                                     matches.                   
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    RegexModule                             
                          module_name   kiara_modules.core.string               
                          full_name     kiara_modules.core.string.RegexModule   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              text = inputs.get_value_data("text")              
                              regex = self.get_config_value("regex")            
                              matches = re.findall(regex, text)                 
                                                                                
                              if not matches:                                   
                                  raise KiaraProcessingException(f"No match …   
                                                                                
                              if self.get_config_value("only_first_match"):     
                                  result = matches[0]                           
                              else:                                             
                                  result = matches                              
                                                                                
                              outputs.set_value("text", result)                 
                                                                                
                         ─────────────────────────────────────────────────────  
                                                                                
string.replace
                                                                                
 Documentation                                                                  
                          Replace a string if it matches a key in a mapping     
                          dictionary.                                           
                                                                                
 Origin                                                                         
                          Authors   Markus Binsteiner (markus@frkl.io)          
                                                                                
 Context                                                                        
                          Tags         core                                     
                          Labels       package: kiara_modules.core              
                          References   source_repo:                             
                                       https://github.com/DHARPA-Project/kia…   
                                       documentation:                           
                                       https://dharpa.org/kiara_modules.core/   
                                       module_doc:                              
                                       https://dharpa.org/kiara_modules.core…   
                                       source_url:                              
                                       https://github.com/DHARPA-Project/kia…   
                                                                                
 Module config                                                                  
                          Field            Type     Description      Required   
                         ─────────────────────────────────────────────────────  
                          constants        object   Value            no         
                                                    constants for               
                                                    this module.                
                          defaults         object   Value defaults   no         
                                                    for this                    
                                                    module.                     
                          replacement_m…   object   A map,           yes        
                                                    containing the              
                                                    strings to be               
                                                    replaced as                 
                                                    keys, and the               
                                                    replacements                
                                                    as values.                  
                          default_value    string   The default      no         
                                                    value to use                
                                                    if the string               
                                                    to be replaced              
                                                    is not in the               
                                                    replacement                 
                                                    map. By                     
                                                    default, this               
                                                    just returns                
                                                    the string                  
                                                    itself.                     
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    ReplaceStringModule                     
                          module_name   kiara_modules.core.string               
                          full_name     kiara_modules.core.string.ReplaceStr…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              text = inputs.get_value_data("text")              
                              repl_map = self.get_config_value("replacement_…   
                              default = self.get_config_value("default_value…   
                                                                                
                              if text not in repl_map.keys():                   
                                  if default is None:                           
                                      result = text                             
                                  else:                                         
                                      result = default                          
                              else:                                             
                                  result = repl_map[text]                       
                                                                                
                              outputs.set_value("text", result)                 
                                                                                
                         ─────────────────────────────────────────────────────  
                                                                                
string.serialize
                                                                                
 Documentation                                                                  
                          -- n/a --                                             
                                                                                
 Origin                                                                         
                          Authors   Markus Binsteiner (markus@frkl.io)          
                                                                                
 Context                                                                        
                          Tags         core                                     
                          Labels       package: kiara_modules.core              
                          References   source_repo:                             
                                       https://github.com/DHARPA-Project/kia…   
                                       documentation:                           
                                       https://dharpa.org/kiara_modules.core/   
                                       module_doc:                              
                                       https://dharpa.org/kiara_modules.core…   
                                       source_url:                              
                                       https://github.com/DHARPA-Project/kia…   
                                                                                
 Module config                                                                  
                          Field            Type     Description      Required   
                         ─────────────────────────────────────────────────────  
                          constants        object   Value            no         
                                                    constants for               
                                                    this module.                
                          defaults         object   Value defaults   no         
                                                    for this                    
                                                    module.                     
                          value_type       string   The type of      yes        
                                                    the source                  
                                                    value.                      
                          serialization…   string   The type of      yes        
                                                    the converted               
                                                    value.                      
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    SerializeStringModule                   
                          module_name   kiara_modules.core.string               
                          full_name     kiara_modules.core.string.SerializeS…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              value_type: str = self.get_config_value("value…   
                                                                                
                              value_obj = inputs.get_value_obj("value_item")    
                                                                                
                              serialization_type = self.get_config_value("se…   
                                                                                
                              if value_type != value_obj.type_name:             
                                  raise KiaraProcessingException(               
                                      f"Invalid type ({value_obj.type_name})…   
                                  )                                             
                                                                                
                              if not hasattr(self, f"to_{serialization_type}…   
                                  # this can never happen, I think              
                                  raise Exception(                              
                                      f"Module '{self._module_type_id}' can'…   
                                  )                                             
                                                                                
                              func = getattr(self, f"to_{serialization_type}…   
                                                                                
                              serialized = func(value_obj)                      
                                                                                
                              if isinstance(serialized, typing.Mapping):        
                                  serialized = DeserializeConfig(**serialize…   
                                                                                
                              if not isinstance(serialized, DeserializeConfi…   
                                  raise KiaraProcessingException(               
                                      f"Invalid serialization result type: {…   
                                  )                                             
                                                                                
                              outputs.set_values(                               
                                  deserialize_config=serialized, value_info=…   
                              )                                                 
                                                                                
                         ─────────────────────────────────────────────────────