create
database.create
                                                                                
 Documentation                                                                  
                          Create a database from files, file_bundles, etc.      
                                                                                
 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.               
                          source_profile   string    The profile     yes        
                                                     of the source              
                                                     value.                     
                          target_type      string    The type of     yes        
                                                     the value to               
                                                     convert to.                
                          allow_none_in…   boolean   Whether to      no         
                                                     allow 'none'               
                                                     source                     
                                                     values, if                 
                                                     one is                     
                                                     encountered                
                                                     'none' is                  
                                                     returned.                  
                          ignore_errors    boolean   Whether to      no         
                                                     ignore                     
                                                     convert                    
                                                     errors and                 
                                                     omit the                   
                                                     failed items.              
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    ConvertToDatabaseModule                 
                          module_name   kiara_modules.core.database             
                          full_name     kiara_modules.core.database.ConvertT…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              source_profile: str = self.get_config_value("s…   
                              source_config: typing.Mapping[                    
                                  str, typing.Mapping[str, typing.Any]          
                              ] = self._kiara.type_mgmt.get_type_config_for_…   
                              source_type = source_config["type"]               
                                                                                
                              target_type: str = self.get_config_value("targ…   
                                                                                
                              allow_none: bool = self.get_config_value("allo…   
                                                                                
                              source: Value = inputs.get_value_obj(source_pr…   
                              if source_type != source.type_name:               
                                  raise KiaraProcessingException(               
                                      f"Invalid type ({source.type_name}) of…   
                                  )                                             
                                                                                
                              if not source.is_set or source.is_none:           
                                  if allow_none:                                
                                      outputs.set_value("value_item", None)     
                                      return                                    
                                  else:                                         
                                      raise KiaraProcessingException("No sou…   
                                                                                
                              if not hasattr(self, f"from_{source_profile}"):   
                                  raise Exception(                              
                                      f"Module '{self._module_type_id}' can'…   
                                  )                                             
                                                                                
                              func = getattr(self, f"from_{source_profile}")    
                                                                                
                              converted = func(source)                          
                              outputs.set_value(target_type, converted)         
                                                                                
                         ─────────────────────────────────────────────────────