Emma Cooke
11/15/2023, 2:32 PMThis run didn't generate Logs
could someone please help with how I can view the logs ? The version Im using is prefect-2.14.3
Tess Dicker
11/15/2023, 3:05 PM*@flow*(log_prints=True)
Emma Cooke
11/15/2023, 3:08 PM@flow(name="Repo Info", log_prints=True)
Emma Cooke
11/15/2023, 3:14 PM.serve
I donβt see any logs from prefect, nor the prints.
ie removing the .serve
here:
if __name__ == "__main__":
# create your first scheduled deployment
repo_info()
and just running python my_flow.py
I would have expected to see some logging in the terminalTess Dicker
11/15/2023, 6:50 PMEmma Cooke
11/16/2023, 8:33 AMimport httpx
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):
contributors_url = repo_info["contributors_url"]
response = httpx.get(contributors_url)
response.raise_for_status()
contributors = response.json()
return contributors
@flow(name="Repo Info", log_prints=True)
def 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__":
# create your first deployment
repo_info.serve(name="my-first-deployment")
which is taken straight from: https://docs.prefect.io/latest/getting-started/quickstart/#step-3-write-a-flow
and according to the same page, I expect to see:
09:44:37.947 | INFO | Flow run 'piquant-sawfly' - Downloading flow code from storage at '/my_path'
09:44:38.900 | INFO | Flow run 'piquant-sawfly' - Created task run 'get_repo_info-0' for task 'get_repo_info'
09:44:38.901 | INFO | Flow run 'piquant-sawfly' - Executing 'get_repo_info-0' immediately...
09:44:39.365 | INFO | Task run 'get_repo_info-0' - Finished in state Completed()
09:44:39.385 | INFO | Flow run 'piquant-sawfly' - Stars π : 12736
09:44:39.454 | INFO | Flow run 'piquant-sawfly' - Created task run 'get_contributors-0' for task 'get_contributors'
09:44:39.454 | INFO | Flow run 'piquant-sawfly' - Executing 'get_contributors-0' immediately...
09:44:40.411 | INFO | Task run 'get_contributors-0' - Finished in state Completed()
09:44:40.414 | INFO | Flow run 'piquant-sawfly' - Number of contributors π·: 30
09:44:40.527 | INFO | Flow run 'piquant-sawfly' - Finished in state Completed('All states completed.')
09:44:43.018 | INFO | prefect.flow_runs.runner - Process 9867 exited cleanly.
which is here: https://docs.prefect.io/latest/getting-started/quickstart/#step-3-write-a-flow:~:text=You%20should%20s[β¦]20UI%20that%20look%20similar%20to%20this%3AEmma Cooke
11/16/2023, 8:35 AMTess Dicker
11/16/2023, 7:44 PMEmma Cooke
11/20/2023, 8:58 AMEmma Cooke
11/20/2023, 9:21 AMEmma Cooke
11/20/2023, 11:28 AM(prefect) emma@Emmas-MacBook-Pro ml-clause-labelling % python repo_info.py
11:23:36.151 | INFO | httpx - HTTP Request: GET <http://127.0.0.1:4200/api/health> "HTTP/1.1 200 OK"
11:23:36.158 | INFO | httpx - HTTP Request: POST <http://127.0.0.1:4200/api/flows/> "HTTP/1.1 200 OK"
11:23:36.171 | INFO | httpx - HTTP Request: POST <http://127.0.0.1:4200/api/flow_runs/> "HTTP/1.1 201 Created"
11:23:36.172 | INFO | prefect.engine - Created flow run 'quantum-marmot' for flow 'get-repo-info'
11:23:36.177 | INFO | httpx - HTTP Request: GET <http://127.0.0.1:4200/api/block_types/slug/local-file-system> "HTTP/1.1 200 OK"
11:23:36.181 | INFO | httpx - HTTP Request: PATCH <http://127.0.0.1:4200/api/block_types/36c8a439-8621-4ae0-bc4b-1f11338d4048> "HTTP/1.1 204 No Content"
11:23:36.191 | INFO | httpx - HTTP Request: GET <http://127.0.0.1:4200/api/block_schemas/checksum/sha256:6db1ab242e7b2b88a52dc137a7da3a373af63e0a103b9a91e060ed54a26f395a?version=2.8.0> "HTTP/1.1 404 Not Found"
11:23:36.201 | INFO | httpx - HTTP Request: POST <http://127.0.0.1:4200/api/block_schemas/> "HTTP/1.1 201 Created"
11:23:36.220 | INFO | httpx - HTTP Request: POST <http://127.0.0.1:4200/api/block_documents/> "HTTP/1.1 201 Created"
11:23:36.231 | INFO | httpx - HTTP Request: POST <http://127.0.0.1:4200/api/flow_runs/5c03f069-06ce-4ab1-9652-1624236e08d4/set_state> "HTTP/1.1 201 Created"
11:23:36.237 | INFO | httpx - HTTP Request: GET <http://127.0.0.1:4200/api/flow_runs/5c03f069-06ce-4ab1-9652-1624236e08d4> "HTTP/1.1 200 OK"
11:23:36.546 | INFO | httpx - HTTP Request: GET <https://api.github.com/repos/PrefectHQ/prefect> "HTTP/1.1 200 OK"
PrefectHQ/prefect repository statistics π€:
Stars π : 13342
Forks π΄ : 1374
11:23:36.584 | INFO | httpx - HTTP Request: POST <http://127.0.0.1:4200/api/flow_runs/5c03f069-06ce-4ab1-9652-1624236e08d4/set_state> "HTTP/1.1 201 Created"
11:23:36.585 | INFO | Flow run 'quantum-marmot' - Finished in state Completed()
11:23:36.605 | INFO | httpx - HTTP Request: POST <http://127.0.0.1:4200/api/logs/> "HTTP/1.1 201 Created"
but as soon as I move to prefect 2.9.0 or later, I can only see the print statements:
(prefect) emma@Emmas-MacBook-Pro ml-clause-labelling % python repo_info.py
Overriding existing alarm handler <function _alarm_based_timeout.<locals>.sigalarm_to_error at 0x10aac9160>
PrefectHQ/prefect repository statistics π€:
Stars π : 13342
Forks π΄ : 1374
Emma Cooke
11/20/2023, 1:52 PM.prefect
directory locally which contained a logging.yml file, removing this revealed the logs.Tess Dicker
11/20/2023, 2:00 PM