I am having an issue with the prefect client/acces...
# prefect-community
r
I am having an issue with the prefect client/accessing flow runs. When I run
Copy code
import prefect
pc = prefect.get_client()
await pc.read_flow_runs()
it returns a cloudpickle error
TypeError: __init__() missing 1 required positional argument: 'path'
(see comments for full stack trace). Previously I was using python 3.7 and was getting another cloudpickle error about version 5 not working. Other prefect client functions work (including
read_flow_run
and
read_flow_run_states
) version stuff:
Copy code
$ prefect version
Version:             2.1.1
API version:         0.8.0
Python version:      3.9.12
Git commit:          dc2ba222
Built:               Thu, Aug 18, 2022 10:18 AM
OS/Arch:             darwin/x86_64
Profile:             goodkiwi
Server type:         hosted

$ python --version
Python 3.9.12
Any thoughts on how to fix?
Copy code
TypeError                                 Traceback (most recent call last)
File ~/opt/anaconda3/envs/goodkiwi_env/lib/python3.9/site-packages/IPython/core/formatters.py:707, in PlainTextFormatter.__call__(self, obj)
    700 stream = StringIO()
    701 printer = pretty.RepresentationPrinter(stream, self.verbose,
    702     self.max_width, self.newline,
    703     max_seq_length=self.max_seq_length,
    704     singleton_pprinters=self.singleton_printers,
    705     type_pprinters=self.type_printers,
    706     deferred_pprinters=self.deferred_printers)
--> 707 printer.pretty(obj)
    708 printer.flush()
    709 return stream.getvalue()

File ~/opt/anaconda3/envs/goodkiwi_env/lib/python3.9/site-packages/IPython/lib/pretty.py:393, in RepresentationPrinter.pretty(self, obj)
    390 for cls in _get_mro(obj_class):
    391     if cls in self.type_pprinters:
    392         # printer registered in self.type_pprinters
--> 393         return self.type_pprinters[cls](obj, self, cycle)
    394     else:
    395         # deferred printer
    396         printer = self._in_deferred_types(cls)

File ~/opt/anaconda3/envs/goodkiwi_env/lib/python3.9/site-packages/IPython/lib/pretty.py:640, in _seq_pprinter_factory.<locals>.inner(obj, p, cycle)
    638         p.text(',')
...
     63 @staticmethod
     64 def loads(blob: bytes) -> Any:
---> 65     return cloudpickle.loads(base64.decodebytes(blob))

TypeError: __init__() missing 1 required positional argument: 'path'
Additionally - any documentation you can point me to on how to authenticate using the REST API? I think for 1.0 bearer tokens worked based on stuff I’ve seen however I get 401 errors when I try stuff like:
Copy code
import requests
import prefect
pc = prefect.get_client()

response = <http://requests.post|requests.post>(
    url=str(pc.api_url),
    json={'name':{"any_": ["flow_name"]}},
    headers = {"Authorization": "Bearer <token>"}
)
j
r
Thanks @Joao Moniz