We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AuthorizationError when watching logs from CLI
When running with `prefect run cloud --logs`, after a few minutes I see the following error:
```
prefect.utilities.exceptions.AuthorizationError: [{'message': 'AuthenticationError', 'locations': [], 'path': ['flow_run'], 'extensions': {'code': 'UNAUTHENTICATED'}}]
```
The run itself succeeds but the logs stop at that point, so I guess the token is initially valid but just expires...?

cc @joshmeek @cicdw 

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/prefect/cli/run.py`
Content:
```
1 import json
2 import time
3 
4 import click
5 from tabulate import tabulate
6 
7 from prefect.client import Client
8 from prefect.utilities.graphql import EnumValue, with_args
9 
10 
11 @click.group(hidden=True)
12 def run():
13     """
14     Run Prefect flows.
15 
16     \b
17     Usage:
18         $ prefect run [STORAGE/PLATFORM]
19 
20     \b
21     Arguments:
22         cloud   Run flows in Prefect Cloud
23 
24     \b
25     Examples:
26         $ prefect run cloud --name Test-Flow --project My-Project
27         Flow Run ID: 2ba3rrfd-411c-4d99-bb2a-f64a6dea78f9
28 
29     \b
30         $ prefect run cloud --name Test-Flow --project My-Project --watch
31         Flow Run ID: 2ba3rrfd-411c-4d99-bb2a-f64a6dea78f9
32         Scheduled -> Submitted -> Running -> Success
33     """
34 
35 
36 @run.command(hidden=True)
37 @click.option(
38     "--name", "-n", required=True, help="The name of a flow to run.", hidden=True
39 )
40 @click.option(
41     "--project",
42     "-p",
43     required=True,
44     help="The project that contains the flow.",
45     hidden=True,
46 )
47 @click.option("--version", "-v", type=int, help="A flow version to run.", hidden=True)
48 @click.option(
49     "--parameters-file",
50     "-pf",
51     help="A parameters JSON file.",
52     hidden=True,
53     type=click.Path(exists=True),
54 )
55 @click.option(
56     "--parameters-string", "-ps", help="A parameters JSON string.", hidden=True
57 )
58 @click.option("--run-name", "-rn", help="A name to assign for this run.", hidden=True)
59 @click.option(
60     "--watch",
61     "-w",
62     is_flag=True,
63     help="Watch current state of the flow run.",
64     hidden=True,
65 )
66 @click.option(
67     "--logs", "-l", is_flag=True, help="Live logs of the flow run.", hidden=True
68 )
69 def cloud(
70     name, project, version, parameters_file, parameters_string, run_name, watch, logs
71 ):
72     """
73     Run a registered flow in Prefect Cloud.
74 
75     \b
76     Options:
77         --name, -n                  TEXT        The name of a flow to run                                       [required]
78         --project, -p               TEXT        The name of a project that contains the flow                    [required]
79         --version, -v               INTEGER     A flow version to run
80         --parameters-file, -pf      FILE PATH   A filepath of a JSON file containing parameters
81         --parameters-string, -ps    TEXT        A string of JSON parameters
82         --run-name, -rn             TEXT        A name to assign for this run
83         --watch, -w                             Watch current state of the flow run, stream output to stdout
84         --logs, -l                              Get logs of the flow run, stream output to stdout
85 
86     \b
87     If both `--parameters-file` and `--parameters-string` are provided then the values passed
88     in through the string will override the values provided from the file.
89 
90     \b
91     e.g.
92     File contains:  {"a": 1, "b": 2}
93     String:         '{"a": 3}'
94     Parameters passed to the flow run: {"a": 3, "b": 2}
95     """
96 
97     if watch and logs:
98         click.secho(
99             "Streaming state and logs not currently supported together.", fg="red"
100         )
101         return
102 
103     query = {
104         "query": {
105             with_args(
106                 "flow",
107                 {
108                     "where": {
109                         "_and": {
110                             "name": {"_eq": name},
111                             "version": {"_eq": version},
112                             "project": {"name": {"_eq": project}},
113                         }
114                     },
115                     "order_by": {
116                         "name": EnumValue("asc"),
117                         "version": EnumValue("desc"),
118                     },
119                     "distinct_on": EnumValue("name"),
120                 },
121             ): {"id": True}
122         }
123     }
124 
125     client = Client()
126     result = client.graphql(query)
127 
128     flow_data = result.data.flow
129 
130     if flow_data:
131         flow_id = flow_data[0].id
132     else:
133         click.secho("{} not found".format(name), fg="red")
134         return
135 
136     # Load parameters from file if provided
137     file_params = {}
138     if parameters_file:
139         with open(parameters_file) as params_file:
140             file_params = json.load(params_file)
141 
142     # Load parameters from string if provided
143     string_params = {}
144     if parameters_string:
145         string_params = json.loads(parameters_string)
146 
147     flow_run_id = client.create_flow_run(
148         flow_id=flow_id, parameters={**file_params, **string_params}, run_name=run_name
149     )
150     click.echo("Flow Run ID: {}".format(flow_run_id))
151 
152     if watch:
153         current_states = []
154         while True:
155             query = {
156                 "query": {
157                     with_args("flow_run_by_pk", {"id": flow_run_id}): {
158                         with_args(
159                             "states",
160                             {"order_by": {EnumValue("timestamp"): EnumValue("asc")}},
161                         ): {"state": True, "timestamp": True}
162                     }
163                 }
164             }
165 
166             result = client.graphql(query)
167 
168             # Filter through retrieved states and output in order
169             for state_index in result.data.flow_run_by_pk.states:
170                 state = state_index.state
171                 if state not in current_states:
172                     if state != "Success" and state != "Failed":
173                         click.echo("{} -> ".format(state), nl=False)
174                     else:
175                         click.echo(state)
176                         return
177 
178                     current_states.append(state)
179 
180             time.sleep(3)
181 
182     if logs:
183         all_logs = []
184 
185         log_query = {
186             with_args(
187                 "logs", {"order_by": {EnumValue("timestamp"): EnumValue("asc")}}
188             ): {"timestamp": True, "message": True, "level": True},
189             "start_time": True,
190         }
191 
192         query = {
193             "query": {
194                 with_args(
195                     "flow_run",
196                     {
197                         "where": {"id": {"_eq": flow_run_id}},
198                         "order_by": {EnumValue("start_time"): EnumValue("desc")},
199                     },
200                 ): log_query
201             }
202         }
203 
204         while True:
205             result = Client().graphql(query)
206 
207             flow_run = result.data.flow_run
208             if not flow_run:
209                 click.secho("{} not found".format(flow_run_id), fg="red")
210                 return
211 
212             new_run = flow_run[0]
213             logs = new_run.logs
214             output = []
215 
216             for i in logs:
217                 if [i.timestamp, i.level, i.message] not in all_logs:
218 
219                     if not len(all_logs):
220                         click.echo(
221                             tabulate(
222                                 [[i.timestamp, i.level, i.message]],
223                                 headers=["TIMESTAMP", "LEVEL", "MESSAGE"],
224                                 tablefmt="plain",
225                                 numalign="left",
226                                 stralign="left",
227                             )
228                         )
229                         all_logs.append([i.timestamp, i.level, i.message])
230                         continue
231 
232                     output.append([i.timestamp, i.level, i.message])
233                     all_logs.append([i.timestamp, i.level, i.message])
234 
235             if output:
236                 click.echo(
237                     tabulate(output, tablefmt="plain", numalign="left", stralign="left")
238                 )
239 
240             # Check if state is either Success or Failed, exit if it is
241             pk_query = {
242                 "query": {
243                     with_args("flow_run_by_pk", {"id": flow_run_id}): {"state": True}
244                 }
245             }
246             result = client.graphql(pk_query)
247 
248             if (
249                 result.data.flow_run_by_pk.state == "Success"
250                 or result.data.flow_run_by_pk.state == "Failed"
251             ):
252                 return
253 
254             time.sleep(3)
255
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/prefect/cli/run.py b/src/prefect/cli/run.py
--- a/src/prefect/cli/run.py
+++ b/src/prefect/cli/run.py
@@ -202,7 +202,7 @@
         }
 
         while True:
-            result = Client().graphql(query)
+            result = client.graphql(query)
 
             flow_run = result.data.flow_run
             if not flow_run:

{"golden_diff": "diff --git a/src/prefect/cli/run.py b/src/prefect/cli/run.py\n--- a/src/prefect/cli/run.py\n+++ b/src/prefect/cli/run.py\n@@ -202,7 +202,7 @@\n         }\n \n         while True:\n-            result = Client().graphql(query)\n+            result = client.graphql(query)\n \n             flow_run = result.data.flow_run\n             if not flow_run:\n", "issue": "AuthorizationError when watching logs from CLI\nWhen running with `prefect run cloud --logs`, after a few minutes I see the following error:\r\n```\r\nprefect.utilities.exceptions.AuthorizationError: [{'message': 'AuthenticationError', 'locations': [], 'path': ['flow_run'], 'extensions': {'code': 'UNAUTHENTICATED'}}]\r\n```\r\nThe run itself succeeds but the logs stop at that point, so I guess the token is initially valid but just expires...?\r\n\r\ncc @joshmeek @cicdw \n", "before_files": [{"content": "import json\nimport time\n\nimport click\nfrom tabulate import tabulate\n\nfrom prefect.client import Client\nfrom prefect.utilities.graphql import EnumValue, with_args\n\n\n@click.group(hidden=True)\ndef run():\n    \"\"\"\n    Run Prefect flows.\n\n    \\b\n    Usage:\n        $ prefect run [STORAGE/PLATFORM]\n\n    \\b\n    Arguments:\n        cloud   Run flows in Prefect Cloud\n\n    \\b\n    Examples:\n        $ prefect run cloud --name Test-Flow --project My-Project\n        Flow Run ID: 2ba3rrfd-411c-4d99-bb2a-f64a6dea78f9\n\n    \\b\n        $ prefect run cloud --name Test-Flow --project My-Project --watch\n        Flow Run ID: 2ba3rrfd-411c-4d99-bb2a-f64a6dea78f9\n        Scheduled -> Submitted -> Running -> Success\n    \"\"\"\n\n\n@run.command(hidden=True)\n@click.option(\n    \"--name\", \"-n\", required=True, help=\"The name of a flow to run.\", hidden=True\n)\n@click.option(\n    \"--project\",\n    \"-p\",\n    required=True,\n    help=\"The project that contains the flow.\",\n    hidden=True,\n)\n@click.option(\"--version\", \"-v\", type=int, help=\"A flow version to run.\", hidden=True)\n@click.option(\n    \"--parameters-file\",\n    \"-pf\",\n    help=\"A parameters JSON file.\",\n    hidden=True,\n    type=click.Path(exists=True),\n)\n@click.option(\n    \"--parameters-string\", \"-ps\", help=\"A parameters JSON string.\", hidden=True\n)\n@click.option(\"--run-name\", \"-rn\", help=\"A name to assign for this run.\", hidden=True)\n@click.option(\n    \"--watch\",\n    \"-w\",\n    is_flag=True,\n    help=\"Watch current state of the flow run.\",\n    hidden=True,\n)\n@click.option(\n    \"--logs\", \"-l\", is_flag=True, help=\"Live logs of the flow run.\", hidden=True\n)\ndef cloud(\n    name, project, version, parameters_file, parameters_string, run_name, watch, logs\n):\n    \"\"\"\n    Run a registered flow in Prefect Cloud.\n\n    \\b\n    Options:\n        --name, -n                  TEXT        The name of a flow to run                                       [required]\n        --project, -p               TEXT        The name of a project that contains the flow                    [required]\n        --version, -v               INTEGER     A flow version to run\n        --parameters-file, -pf      FILE PATH   A filepath of a JSON file containing parameters\n        --parameters-string, -ps    TEXT        A string of JSON parameters\n        --run-name, -rn             TEXT        A name to assign for this run\n        --watch, -w                             Watch current state of the flow run, stream output to stdout\n        --logs, -l                              Get logs of the flow run, stream output to stdout\n\n    \\b\n    If both `--parameters-file` and `--parameters-string` are provided then the values passed\n    in through the string will override the values provided from the file.\n\n    \\b\n    e.g.\n    File contains:  {\"a\": 1, \"b\": 2}\n    String:         '{\"a\": 3}'\n    Parameters passed to the flow run: {\"a\": 3, \"b\": 2}\n    \"\"\"\n\n    if watch and logs:\n        click.secho(\n            \"Streaming state and logs not currently supported together.\", fg=\"red\"\n        )\n        return\n\n    query = {\n        \"query\": {\n            with_args(\n                \"flow\",\n                {\n                    \"where\": {\n                        \"_and\": {\n                            \"name\": {\"_eq\": name},\n                            \"version\": {\"_eq\": version},\n                            \"project\": {\"name\": {\"_eq\": project}},\n                        }\n                    },\n                    \"order_by\": {\n                        \"name\": EnumValue(\"asc\"),\n                        \"version\": EnumValue(\"desc\"),\n                    },\n                    \"distinct_on\": EnumValue(\"name\"),\n                },\n            ): {\"id\": True}\n        }\n    }\n\n    client = Client()\n    result = client.graphql(query)\n\n    flow_data = result.data.flow\n\n    if flow_data:\n        flow_id = flow_data[0].id\n    else:\n        click.secho(\"{} not found\".format(name), fg=\"red\")\n        return\n\n    # Load parameters from file if provided\n    file_params = {}\n    if parameters_file:\n        with open(parameters_file) as params_file:\n            file_params = json.load(params_file)\n\n    # Load parameters from string if provided\n    string_params = {}\n    if parameters_string:\n        string_params = json.loads(parameters_string)\n\n    flow_run_id = client.create_flow_run(\n        flow_id=flow_id, parameters={**file_params, **string_params}, run_name=run_name\n    )\n    click.echo(\"Flow Run ID: {}\".format(flow_run_id))\n\n    if watch:\n        current_states = []\n        while True:\n            query = {\n                \"query\": {\n                    with_args(\"flow_run_by_pk\", {\"id\": flow_run_id}): {\n                        with_args(\n                            \"states\",\n                            {\"order_by\": {EnumValue(\"timestamp\"): EnumValue(\"asc\")}},\n                        ): {\"state\": True, \"timestamp\": True}\n                    }\n                }\n            }\n\n            result = client.graphql(query)\n\n            # Filter through retrieved states and output in order\n            for state_index in result.data.flow_run_by_pk.states:\n                state = state_index.state\n                if state not in current_states:\n                    if state != \"Success\" and state != \"Failed\":\n                        click.echo(\"{} -> \".format(state), nl=False)\n                    else:\n                        click.echo(state)\n                        return\n\n                    current_states.append(state)\n\n            time.sleep(3)\n\n    if logs:\n        all_logs = []\n\n        log_query = {\n            with_args(\n                \"logs\", {\"order_by\": {EnumValue(\"timestamp\"): EnumValue(\"asc\")}}\n            ): {\"timestamp\": True, \"message\": True, \"level\": True},\n            \"start_time\": True,\n        }\n\n        query = {\n            \"query\": {\n                with_args(\n                    \"flow_run\",\n                    {\n                        \"where\": {\"id\": {\"_eq\": flow_run_id}},\n                        \"order_by\": {EnumValue(\"start_time\"): EnumValue(\"desc\")},\n                    },\n                ): log_query\n            }\n        }\n\n        while True:\n            result = Client().graphql(query)\n\n            flow_run = result.data.flow_run\n            if not flow_run:\n                click.secho(\"{} not found\".format(flow_run_id), fg=\"red\")\n                return\n\n            new_run = flow_run[0]\n            logs = new_run.logs\n            output = []\n\n            for i in logs:\n                if [i.timestamp, i.level, i.message] not in all_logs:\n\n                    if not len(all_logs):\n                        click.echo(\n                            tabulate(\n                                [[i.timestamp, i.level, i.message]],\n                                headers=[\"TIMESTAMP\", \"LEVEL\", \"MESSAGE\"],\n                                tablefmt=\"plain\",\n                                numalign=\"left\",\n                                stralign=\"left\",\n                            )\n                        )\n                        all_logs.append([i.timestamp, i.level, i.message])\n                        continue\n\n                    output.append([i.timestamp, i.level, i.message])\n                    all_logs.append([i.timestamp, i.level, i.message])\n\n            if output:\n                click.echo(\n                    tabulate(output, tablefmt=\"plain\", numalign=\"left\", stralign=\"left\")\n                )\n\n            # Check if state is either Success or Failed, exit if it is\n            pk_query = {\n                \"query\": {\n                    with_args(\"flow_run_by_pk\", {\"id\": flow_run_id}): {\"state\": True}\n                }\n            }\n            result = client.graphql(pk_query)\n\n            if (\n                result.data.flow_run_by_pk.state == \"Success\"\n                or result.data.flow_run_by_pk.state == \"Failed\"\n            ):\n                return\n\n            time.sleep(3)\n", "path": "src/prefect/cli/run.py"}], "after_files": [{"content": "import json\nimport time\n\nimport click\nfrom tabulate import tabulate\n\nfrom prefect.client import Client\nfrom prefect.utilities.graphql import EnumValue, with_args\n\n\n@click.group(hidden=True)\ndef run():\n    \"\"\"\n    Run Prefect flows.\n\n    \\b\n    Usage:\n        $ prefect run [STORAGE/PLATFORM]\n\n    \\b\n    Arguments:\n        cloud   Run flows in Prefect Cloud\n\n    \\b\n    Examples:\n        $ prefect run cloud --name Test-Flow --project My-Project\n        Flow Run ID: 2ba3rrfd-411c-4d99-bb2a-f64a6dea78f9\n\n    \\b\n        $ prefect run cloud --name Test-Flow --project My-Project --watch\n        Flow Run ID: 2ba3rrfd-411c-4d99-bb2a-f64a6dea78f9\n        Scheduled -> Submitted -> Running -> Success\n    \"\"\"\n\n\n@run.command(hidden=True)\n@click.option(\n    \"--name\", \"-n\", required=True, help=\"The name of a flow to run.\", hidden=True\n)\n@click.option(\n    \"--project\",\n    \"-p\",\n    required=True,\n    help=\"The project that contains the flow.\",\n    hidden=True,\n)\n@click.option(\"--version\", \"-v\", type=int, help=\"A flow version to run.\", hidden=True)\n@click.option(\n    \"--parameters-file\",\n    \"-pf\",\n    help=\"A parameters JSON file.\",\n    hidden=True,\n    type=click.Path(exists=True),\n)\n@click.option(\n    \"--parameters-string\", \"-ps\", help=\"A parameters JSON string.\", hidden=True\n)\n@click.option(\"--run-name\", \"-rn\", help=\"A name to assign for this run.\", hidden=True)\n@click.option(\n    \"--watch\",\n    \"-w\",\n    is_flag=True,\n    help=\"Watch current state of the flow run.\",\n    hidden=True,\n)\n@click.option(\n    \"--logs\", \"-l\", is_flag=True, help=\"Live logs of the flow run.\", hidden=True\n)\ndef cloud(\n    name, project, version, parameters_file, parameters_string, run_name, watch, logs\n):\n    \"\"\"\n    Run a registered flow in Prefect Cloud.\n\n    \\b\n    Options:\n        --name, -n                  TEXT        The name of a flow to run                                       [required]\n        --project, -p               TEXT        The name of a project that contains the flow                    [required]\n        --version, -v               INTEGER     A flow version to run\n        --parameters-file, -pf      FILE PATH   A filepath of a JSON file containing parameters\n        --parameters-string, -ps    TEXT        A string of JSON parameters\n        --run-name, -rn             TEXT        A name to assign for this run\n        --watch, -w                             Watch current state of the flow run, stream output to stdout\n        --logs, -l                              Get logs of the flow run, stream output to stdout\n\n    \\b\n    If both `--parameters-file` and `--parameters-string` are provided then the values passed\n    in through the string will override the values provided from the file.\n\n    \\b\n    e.g.\n    File contains:  {\"a\": 1, \"b\": 2}\n    String:         '{\"a\": 3}'\n    Parameters passed to the flow run: {\"a\": 3, \"b\": 2}\n    \"\"\"\n\n    if watch and logs:\n        click.secho(\n            \"Streaming state and logs not currently supported together.\", fg=\"red\"\n        )\n        return\n\n    query = {\n        \"query\": {\n            with_args(\n                \"flow\",\n                {\n                    \"where\": {\n                        \"_and\": {\n                            \"name\": {\"_eq\": name},\n                            \"version\": {\"_eq\": version},\n                            \"project\": {\"name\": {\"_eq\": project}},\n                        }\n                    },\n                    \"order_by\": {\n                        \"name\": EnumValue(\"asc\"),\n                        \"version\": EnumValue(\"desc\"),\n                    },\n                    \"distinct_on\": EnumValue(\"name\"),\n                },\n            ): {\"id\": True}\n        }\n    }\n\n    client = Client()\n    result = client.graphql(query)\n\n    flow_data = result.data.flow\n\n    if flow_data:\n        flow_id = flow_data[0].id\n    else:\n        click.secho(\"{} not found\".format(name), fg=\"red\")\n        return\n\n    # Load parameters from file if provided\n    file_params = {}\n    if parameters_file:\n        with open(parameters_file) as params_file:\n            file_params = json.load(params_file)\n\n    # Load parameters from string if provided\n    string_params = {}\n    if parameters_string:\n        string_params = json.loads(parameters_string)\n\n    flow_run_id = client.create_flow_run(\n        flow_id=flow_id, parameters={**file_params, **string_params}, run_name=run_name\n    )\n    click.echo(\"Flow Run ID: {}\".format(flow_run_id))\n\n    if watch:\n        current_states = []\n        while True:\n            query = {\n                \"query\": {\n                    with_args(\"flow_run_by_pk\", {\"id\": flow_run_id}): {\n                        with_args(\n                            \"states\",\n                            {\"order_by\": {EnumValue(\"timestamp\"): EnumValue(\"asc\")}},\n                        ): {\"state\": True, \"timestamp\": True}\n                    }\n                }\n            }\n\n            result = client.graphql(query)\n\n            # Filter through retrieved states and output in order\n            for state_index in result.data.flow_run_by_pk.states:\n                state = state_index.state\n                if state not in current_states:\n                    if state != \"Success\" and state != \"Failed\":\n                        click.echo(\"{} -> \".format(state), nl=False)\n                    else:\n                        click.echo(state)\n                        return\n\n                    current_states.append(state)\n\n            time.sleep(3)\n\n    if logs:\n        all_logs = []\n\n        log_query = {\n            with_args(\n                \"logs\", {\"order_by\": {EnumValue(\"timestamp\"): EnumValue(\"asc\")}}\n            ): {\"timestamp\": True, \"message\": True, \"level\": True},\n            \"start_time\": True,\n        }\n\n        query = {\n            \"query\": {\n                with_args(\n                    \"flow_run\",\n                    {\n                        \"where\": {\"id\": {\"_eq\": flow_run_id}},\n                        \"order_by\": {EnumValue(\"start_time\"): EnumValue(\"desc\")},\n                    },\n                ): log_query\n            }\n        }\n\n        while True:\n            result = client.graphql(query)\n\n            flow_run = result.data.flow_run\n            if not flow_run:\n                click.secho(\"{} not found\".format(flow_run_id), fg=\"red\")\n                return\n\n            new_run = flow_run[0]\n            logs = new_run.logs\n            output = []\n\n            for i in logs:\n                if [i.timestamp, i.level, i.message] not in all_logs:\n\n                    if not len(all_logs):\n                        click.echo(\n                            tabulate(\n                                [[i.timestamp, i.level, i.message]],\n                                headers=[\"TIMESTAMP\", \"LEVEL\", \"MESSAGE\"],\n                                tablefmt=\"plain\",\n                                numalign=\"left\",\n                                stralign=\"left\",\n                            )\n                        )\n                        all_logs.append([i.timestamp, i.level, i.message])\n                        continue\n\n                    output.append([i.timestamp, i.level, i.message])\n                    all_logs.append([i.timestamp, i.level, i.message])\n\n            if output:\n                click.echo(\n                    tabulate(output, tablefmt=\"plain\", numalign=\"left\", stralign=\"left\")\n                )\n\n            # Check if state is either Success or Failed, exit if it is\n            pk_query = {\n                \"query\": {\n                    with_args(\"flow_run_by_pk\", {\"id\": flow_run_id}): {\"state\": True}\n                }\n            }\n            result = client.graphql(pk_query)\n\n            if (\n                result.data.flow_run_by_pk.state == \"Success\"\n                or result.data.flow_run_by_pk.state == \"Failed\"\n            ):\n                return\n\n            time.sleep(3)\n", "path": "src/prefect/cli/run.py"}]}