hi @all, im trying to use a PrefectSecret from the...
# ask-community
l
hi @all, im trying to use a PrefectSecret from the UI as kwargs for a config, but im getting an error with the following code, does anybody know?
Copy code
ok, i tried with the following:

@task(log_stdout=True)
def create_engine(snowflake_salesforce):
    config = configparser.ConfigParser()
    engine=create_engine(URL(**config[snowflake_salesforce]))
with Flow('UWG-Mail') as flow:
    snowflake_credentials=PrefectSecret("Snowflake_Salesforce")
    connection=create_engine(snowflake_salesforce=snowflake_credentials)
error:
Copy code
Unexpected error: TypeError("unhashable type: 'dict'")
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/runner.py", line 48, in inner
    new_state = method(self, state, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/prefect/engine/task_runner.py", line 863, in get_task_run_state
    value = prefect.utilities.executors.run_task_with_timeout(
  File "/usr/local/lib/python3.8/site-packages/prefect/utilities/executors.py", line 298, in run_task_with_timeout
    return task.run(*args, **kwargs)  # type: ignore
  File "<input>", line 36, in create_engine
  File "/usr/local/lib/python3.8/configparser.py", line 959, in __getitem__
    if key != self.default_section and not self.has_section(key):
  File "/usr/local/lib/python3.8/configparser.py", line 668, in has_section
    return section in self._sections
TypeError: unhashable type: 'dict'
1
s
My guess is that the
snowflake_salesforce
var is a
dict
instead of a
str
.
👍 1
l
thanks! maybe you can give me an example on how this could look like when putting string secrets to the ui with more than one value
s
I don't have any experience using PrefectSecrets unfortunately. I created my own Secret task for interfacing with pre-existing secret management. I suppose you could expand a bit on what you're trying to do with this approach. Typically you'd pass the secret as your argument:
engine=create_engine(URL(**snowflake_salesforce))
l
thanks, yes youre right