File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
library/configuration/ftrack/library/configuration/helper Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change 11import base64
2- import pickle
2+ import yaml
33
44from typing import Self
55from pathlib import Path
@@ -46,21 +46,21 @@ def __eq__(self, other):
4646
4747 def config_as_base64 (self ) -> str :
4848 # Serialize the object to a pickle byte stream
49- pickled_data = pickle .dumps (self .configuration )
50- # Encode the byte stream to a base64 string
51- base64_encoded = base64 .b64encode (pickled_data ).decode ("utf-8" )
52- # Convert the base64 string to a hexdump
53- hexdump = base64_encoded .encode ("utf-8" ).hex ()
49+ encoded_bytes = bytes (OmegaConf .to_yaml (self .configuration ).encode ("utf-8" ))
50+ # Encode the byte stream to a base64 string and dump as hex
51+ hexdump = base64 .b64encode (encoded_bytes ).hex ()
5452 return hexdump
5553
5654 @staticmethod
5755 def config_from_base64 (hexdump : str ) -> DictConfig :
5856 # Convert the hexdump back to a base64 string
5957 base64_encoded = bytes .fromhex (hexdump ).decode ("utf-8" )
6058 # Decode the base64 string to a pickle byte stream
61- pickled_data = base64 .b64decode (base64_encoded )
62- # Deserialize the pickle byte stream to an object
63- configuration = pickle .loads (pickled_data )
59+ decoded_string = base64 .b64decode (base64_encoded )
60+ # Load the string as yaml and convert it to an OmegaConf Configuration
61+ configuration = OmegaConf .create (
62+ yaml .load (decoded_string , Loader = yaml .SafeLoader )
63+ )
6464 return configuration
6565
6666 def to_dict (self ) -> dict :
You can’t perform that action at this time.
0 commit comments