Hello, new question about an issue i have. I'm try...
# ask-community
s
Hello, new question about an issue i have. I'm trying to store a dict which contains keys integers in a SecretDict, however, as soon as i get the secret value, integers keys are casted to string. Here is the code example :
Copy code
from prefect.blocks.core import Block, SecretDict

class Custom(Block):
    my_secret_dict: SecretDict

my_dict_with_int_keys={
    0: 'field0',
    2: 'field2'
}
print(my_dict_with_int_keys)
# prints: {0: 'field0', 2: 'field2'}

my_block = Custom(my_secret_dict=my_dict_with_int_keys)
my_block.save(name='blockname')

my_new_block = Custom.load('blockname')
print(my_new_block.my_secret_dict.get_secret_value())
# prints: {'0': 'field0', '2': 'field2'}
Is it normal or i have to use something particular ? Thank you
1
Hello, some piece of advice ?
Should I fill an issue for my problem ?
1
j
Hi Serial. That is behaving as expected. If you use the
dict()
method, you will get back the obfuscated values:
Copy code
print(my_new_block.my_secret_dict.dict())
outputs;
Copy code
{'0': '**********', '2': '**********'}
Here’s the source code:
Copy code
def get_secret_value(self) -> Dict[str, Any]:
        return self._secret_value

    def dict(self) -> Dict:
        return {key: "**********" for key in self.get_secret_value().keys()}
s
Ok, thank you for your answer. I will find a workaround.