msgpack
bytes.msgpack.from_value
                                                                                
 Documentation                                                                  
                          -- n/a --                                             
                                                                                
 Origin                                                                         
                          Authors   Markus Binsteiner (markus@frkl.io)          
                                                                                
 Context                                                                        
                          Tags         bytes, msgpack, serialization, 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 constants      no         
                                                for this module.                
                          defaults     object   Value defaults for   no         
                                                this module.                    
                          value_type   string   The value type to    yes        
                                                serialize/deseria…              
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    SerializeToMsgPackModule                
                          module_name   kiara_modules.core.bytes.msgpack        
                          full_name     kiara_modules.core.bytes.msgpack.Ser…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              import msgpack                                    
                                                                                
                              type_name: str = self.get_config_value("value_…   
                                                                                
                              if not hasattr(self, f"from_{type_name}"):        
                                  raise KiaraProcessingException(               
                                      f"Value type not supported for msgpack…   
                                  )                                             
                                                                                
                              func = getattr(self, f"from_{type_name}")         
                                                                                
                              value = inputs.get_value_obj("value_item")        
                                                                                
                              metadata = value.get_metadata(also_return_sche…   
                                                                                
                              msg = func(value=value)                           
                              data = {"value_type": value.type_name, "metada…   
                                                                                
                              msg = msgpack.packb(data, use_bin_type=True)      
                                                                                
                              outputs.set_value("bytes", msg)                   
                                                                                
                         ─────────────────────────────────────────────────────  
                                                                                
bytes.msgpack.to_value
                                                                                
 Documentation                                                                  
                          -- n/a --                                             
                                                                                
 Origin                                                                         
                          Authors   Markus Binsteiner (markus@frkl.io)          
                                                                                
 Context                                                                        
                          Tags         bytes, msgpack, serialization, 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 constants      no         
                                                for this module.                
                          defaults     object   Value defaults for   no         
                                                this module.                    
                          value_type   string   The value type to    yes        
                                                serialize/deseria…              
                                                                                
 Module config          -- no config --                                         
 Python class                                                                   
                          class_name    DeserializeFromMsgPackModule            
                          module_name   kiara_modules.core.bytes.msgpack        
                          full_name     kiara_modules.core.bytes.msgpack.Des…   
                                                                                
 Processing source code  ─────────────────────────────────────────────────────  
                          def process(self, inputs: ValueSet, outputs: Value…   
                                                                                
                              import msgpack                                    
                                                                                
                              msg = inputs.get_value_data("bytes")              
                                                                                
                              unpacked = msgpack.unpackb(msg, raw=False)        
                                                                                
                              value_type = unpacked["value_type"]               
                              outputs.set_value("value_type", value_type)       
                                                                                
                              metadata = unpacked["metadata"]                   
                              outputs.set_value("value_metadata", metadata)     
                                                                                
                              new_data = unpacked["data"]                       
                                                                                
                              if not hasattr(self, f"to_{value_type}"):         
                                  raise KiaraProcessingException(               
                                      f"Value type not supported for msgpack…   
                                  )                                             
                                                                                
                              func = getattr(self, f"to_{value_type}")          
                              obj = func(data=new_data)                         
                              outputs.set_value("value_data", obj)              
                                                                                
                         ─────────────────────────────────────────────────────