A couple things: Is there some lag between editing...
# ask-community
m
A couple things: Is there some lag between editing
config.toml
and secrets added to it becoming available when doing local testing? That appears to be the case, since a missing local secret error went away seemingly magically, as I was preparing to ask about it. Alternatively, I had added the secret to cloud first, so maybe there was a (longer) lag before it found it there, and it's still not using my local-secrets? Also, SlackTask doesn't work when supplying 'message' at runtime (or directly to run); I get
TypeError: run() got multiple values for argument 'message'
- something to do with that defaults_from_attrs magic?
k
Hey @Michael Warnock, there shouldn’t be a lag. It should populate upon the next
.flow.run()
, I think adding a secret to cloud should be quick for the most part as well. About the SlackTask, supplying the message at runtime should work, could you share how you used it?
m
Copy code
>>> from prefect.tasks.notifications import SlackTask
>>> st = SlackTask()
>>> st.run('foo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/momerath/python-venvs/ford-prefect/lib/python3.8/site-packages/prefect/utilities/tasks.py", line 441, in method
    return run_method(self, *args, **kwargs)
TypeError: run() got multiple values for argument 'message'
>>> st = SlackTask('wtf')
>>> st.run()
>>>
I'm not doing a .flow.run - testing a task outside a flow; I guess that's it?
k
This error is normally when Python is confused between kwargs and other variables. In this case, I guess it might be caused by the
default_from_attrs
but it can be fixed by supplying the keyword like:
Copy code
st = SlackTask()
st.run(message='foo')

with Flow('test') as flow:
    st("foo")

flow.run()
Just tested and both of these work. (Was able to replicate also)
👍 1
m
I wrote my own anyway (started by subclassing) because I want the response value (so I can put all the subsequent notifications for the flow in a thread under the first)
👍 1
k
Definitely. A lot of users do this as the task library doesn’t fit their use case immediately off the shelf.