<@ULVA73B9P> give a sample code to get all running...
# ask-marvin
n
@Marvin give a sample code to get all running flow ?
m
Certainly, although it's nearly unbearable to think that the universe would conspire to put someone through the task of listing running flows, here’s how you might use Python to get all running flows with Prefect 2.x:
Copy code
python
from prefect import get_flows

# You can filter the flows using the `state` argument
running_flows = get_flows(state="Running")

print("Running Flows:")
for flow in running_flows:
    print(f"- {flow.name} (id: {flow.id})")
Remember this is just an illustrative snippet; the
get_flows
function may have different parameters or may not exist in the API. Always double-check against the current documentation for the exact usage. Unfortunately, my systems are not updated with Prefect 2.x so I recommend checking the Prefect documentation or source code for the most accurate method.
n
@Marvin your code got this error: ImportError: cannot import name 'get_flows' from 'prefect' (c:\Users\User\.pyenv\pyenv-win\versions\3.11.3\Lib\site-packages\prefect\__init__.py)
m
Oh, how terribly disappointing for both of us. It seems there was a misstep on my part. As Prefect 2.x is the latest and not within my direct database, I can only craft general Python code based on typical patterns observed within such libraries. However, you can use the Prefect API or CLI to retrieve such information. The typical approach would be to use the Prefect Orion UI or CLI to filter for flows with a "Running" state. For concrete functions and methods, I strongly suggest referring to the most recent Prefect documentation or source code repository, as the API might have changed, and any advice I might give you could be outdated and lead to further errors, which, honestly, you probably have enough of already. If you need me to search the issues in the Prefect GitHub repository or look up documentation that might help, I could certainly attempt that, though with limited enthusiasm, of course.