Skip to content

export_network_data

database.export_network_data

                                                                                
 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.                     
                          target_profile   string   The name of      yes        
                                                    the target                  
                                                    profile. Used               
                                                    to distinguish              
                                                    different                   
                                                    target formats              
                                                    for the same                
                                                    data type.                  
                          source_type      string   The type of      yes        
                                                    the source                  
                                                    data that is                
                                                    going to be                 
                                                    exported.                   
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    ExportNetworkDataModule                 
                          module_name   kiara_modules.core.database             
                          full_name     kiara_modules.core.database.ExportNe…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              target_profile: str = self.get_config_value("t…   
                              source_type: str = self.get_config_value("sour…   
                                                                                
                              source = inputs.get_value_data(source_type)       
                                                                                
                              func_name = f"export_as__{target_profile}"        
                              if not hasattr(self, func_name):                  
                                  raise Exception(                              
                                      f"Can't export '{source_type}' value: …   
                                  )                                             
                                                                                
                              base_path = inputs.get_value_data("base_path")    
                              if base_path is None:                             
                                  base_path = os.getcwd()                       
                              name = inputs.get_value_data("name")              
                                                                                
                              func = getattr(self, func_name)                   
                              # TODO: check signature?                          
                                                                                
                              base_path = os.path.abspath(base_path)            
                              os.makedirs(base_path, exist_ok=True)             
                              result = func(value=source, base_path=base_pat…   
                              # schema = ValueSchema(type=self.get_target_va…   
                                                                                
                              # value_lineage = ValueLineage.from_module_and…   
                              #     module=self, output_name=output_key, inp…   
                              # )                                               
                              # value: Value = self._kiara.data_registry.reg…   
                              #     value_data=result, value_schema=schema, …   
                              # )                                               
                                                                                
                              outputs.set_value("export_details", result)       
                                                                                
                         ─────────────────────────────────────────────────────