PrefectHQ / prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
https://prefect.io
Apache License 2.0
17.55k stars 1.65k forks source link

Bugged UI. Does not show any task run and data flow chart #16043

Open kavvkon opened 4 days ago

kavvkon commented 4 days ago

Bug summary

When I visualize a flow run in a local server, the flow runs successfully but the visual info on server does not work very well. I do not see any task runs, and the flow runs do not appear in the UI as blocks. Version 2 was working fine !

Successful run: C:\Windows>C:/Users/paul/Anaconda3/envs/prefect_env/python.exe my_gh_workflow.py

15:05:55.665 | INFO | prefect.engine - Created flow run 'righteous-dragon' for flow 'log-repo-info' 15:05:55.665 | INFO | prefect.engine - View at http://192.168.1.10:4200/runs/flow-run/b99db794-7b04-4b70-af3d-7eeb6bd51948 15:05:57.441 | INFO | Task run 'get_repo_info-2bd' - Finished in state Completed() 15:05:57.441 | INFO | Flow run 'righteous-dragon' - Stars 🌠 : 17477 15:05:59.144 | INFO | Task run 'get_contributors-838' - Finished in state Completed() 15:05:59.146 | INFO | Flow run 'righteous-dragon' - Number of contributors πŸ‘·: 30 15:05:59.188 | INFO | Flow run 'righteous-dragon' - Finished in state Completed()

image

image

Version info

Version:             3.1.1
API version:         0.8.4
Python version:      3.12.7
Git commit:          6b50a2b9
Built:               Fri, Nov 8, 2024 12:38 PM
OS/Arch:             win32/AMD64
Profile:             default
Server type:         server
Pydantic version:    2.9.2

Additional context

Calling this file my_gh_workflow.py based on this example from https://docs.prefect.io/3.0/get-started/quickstart

import httpx   # an HTTP client library and dependency of Prefect
from prefect import flow, task

@task(retries=2)
def get_repo_info(repo_owner: str, repo_name: str):
    """Get info about a repo - will retry twice after failing"""
    url = f"https://api.github.com/repos/{repo_owner}/{repo_name}"
    api_response = httpx.get(url)
    api_response.raise_for_status()
    repo_info = api_response.json()
    return repo_info

@task
def get_contributors(repo_info: dict):
    """Get contributors for a repo"""
    contributors_url = repo_info["contributors_url"]
    response = httpx.get(contributors_url)
    response.raise_for_status()
    contributors = response.json()
    return contributors

@flow(log_prints=True)
def log_repo_info(repo_owner: str = "PrefectHQ", repo_name: str = "prefect"):
    """
    Given a GitHub repository, logs the number of stargazers
    and contributors for that repo.
    """
    repo_info = get_repo_info(repo_owner, repo_name)
    print(f"Stars 🌠 : {repo_info['stargazers_count']}")

    contributors = get_contributors(repo_info)
    print(f"Number of contributors πŸ‘·: {len(contributors)}")

if __name__ == "__main__":
    log_repo_info()
zzstoatzz commented 4 days ago

hi @kavvkon - thanks for the issue. Do you have any rules that would prevent websocket traffic? also do you see anything about the EventsWorker still processing items?

I think this is likely a duplicate of this issue

kavvkon commented 3 days ago

Yes that should be it. The prefect server is hosted in another PC in intranet, (not through https). But I am in a corporate network and there are some restrictions. Any idea how to bypass and ignore SSL related errors ?

kavvkon commented 3 days ago

This code works btw

import asyncio

from prefect.events.clients import PrefectEventsClient

async def main():
    async with PrefectEventsClient() as client:
        print(f"Connected to: {client._events_socket_url}")
        pong = await client._websocket.ping()
        pong_time = await pong
        print(f"Response received in: {pong_time}")

if __name__ == '__main__':
    asyncio.run(main())
Connected to: ws://192.168.1.10:4200/api/events/in
Response received in: 0.0025052999990293756