Frederick Thomas
02/14/2022, 3:46 PMprefect.Client
to query the GraphQL endpoint, however, I am
getting errors that have me stumped. The relevant code:
import prefect
import pandas as pd
client = prefect.Client()
client.graphql("""
query {
agent{
flow_runs(limit:5, where:{state:{_eq: "Success"}start_time:{_gt:"2022-02-14"}}){
start_time
end_time
state
flow{
name
id
tasks_aggregate{
aggregate{
count
}
}
}
}
}
} """)
The errors:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 465, in _request
json_resp = response.json()
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/local/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.8/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/workspaces/prefect/ETL/CDNY/GraphQL.py", line 7, in <module>
client.graphql("""
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 298, in graphql
result = <http://self.post|self.post>(
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 213, in post
response = self._request(
File "/usr/local/lib/python3.8/site-packages/prefect/client/client.py", line 468, in _request
raise ClientError(
prefect.utilities.exceptions.ClientError: Malformed response received from Cloud - please ensure that you have an API token properly configured.
We're using Prefect core as our backend at the moment and the documentation for this is sparse when I google. ThanksKevin Kho
Frederick Thomas
02/14/2022, 4:04 PMKevin Kho
prefect auth login --key API_KEY
to use the Client like thisFrederick Thomas
02/14/2022, 4:06 PMKevin Kho
Frederick Thomas
02/14/2022, 4:07 PMKevin Kho
prefect backend server
config.toml
? or with the env var PREFECT___SERVER___ENDPOINT
Frederick Thomas
02/14/2022, 4:09 PMKevin Kho
localhost
, no if the endpoint is remote some_ip_address:4200
and your container has internet connection?client.graphql()
as wellFrederick Thomas
02/14/2022, 4:30 PMprefect backend server
and modified my config.toml for the server section like so:
#### Server Setup
[server]
host = "<http://172.18.1.5>"
endpoint = "<http://172.18.1.5:4200>"
backend = "server"
and the error I'm receiving now:
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='172.18.1.5', port=4200): Max retries exceeded with url: /graphql (Caused by ConnectTimeoutError
Kevin Kho
prefect agent local start
)?Frederick Thomas
02/14/2022, 4:33 PMKevin Kho
Frederick Thomas
02/14/2022, 4:42 PMclient
?Kevin Kho
Frederick Thomas
02/14/2022, 4:53 PMKevin Kho
Sagi Timinsky
02/20/2022, 4:50 PMKevin Kho
Frederick Thomas
02/21/2022, 12:23 PM