Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flow_run_name formatting variable does not work in task run logger #8611

Closed
4 tasks done
leonarduschen opened this issue Feb 22, 2023 · 1 comment · Fixed by #9170
Closed
4 tasks done

flow_run_name formatting variable does not work in task run logger #8611

leonarduschen opened this issue Feb 22, 2023 · 1 comment · Fixed by #9170
Labels
bug Something isn't working

Comments

@leonarduschen
Copy link

leonarduschen commented Feb 22, 2023

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Prefect documentation for this issue.
  • I checked that this issue is related to Prefect and not one of its dependencies.

Bug summary

The variable flow_run_name in task_run_logger replaced with <unknown> instead of the actual flow run name

Reproduction

Change the following part of https://github.com/PrefectHQ/prefect/blob/2.8.2/src/prefect/logging/logging.yml and copy to ~/.prefect/logging.yml

task_run_fmt: "%(asctime)s.%(msecs)03d | %(levelname)-7s | Flow run %(flow_run_name)r - Task run %(task_run_name)r - %(message)s"

Flow code snippet:

from prefect import flow, get_run_logger, task
from prefect.context import get_run_context


@task
def say_hello_world() -> None:
    logger = get_run_logger()
    logger.info("Hello World")


@flow(name="hello-world")
def main_flow() -> None:
    logger = get_run_logger()

    flow_context = get_run_context()

    logger.info(f"Running flow at {flow_context.start_time}")

    say_hello_world()


if __name__ == "__main__":
    main_flow()

Error

15:37:42.607 | INFO    | prefect.engine - Created flow run 'beautiful-chicken' for flow 'hello-world'
15:37:42.707 | INFO    | Flow run 'beautiful-chicken' - Running flow at 2023-02-22T07:37:42.706671+00:00
15:37:42.736 | INFO    | Flow run 'beautiful-chicken' - Created task run 'say_hello_world-0' for task 'say_hello_world'
15:37:42.737 | INFO    | Flow run 'beautiful-chicken' - Executing 'say_hello_world-0' immediately...
15:37:42.774 | INFO    | Flow run 'beautiful-chicken' - Task run 'say_hello_world-0' - Hello World
15:37:42.798 | INFO    | Flow run '<unknown>' - Task run 'say_hello_world-0' - Finished in state Completed()
15:37:42.827 | INFO    | Flow run 'beautiful-chicken' - Finished in state Completed('All states completed.')

Versions

Version:             2.8.2
API version:         0.8.4
Python version:      3.9.7
Git commit:          afbed19d
Built:               Fri, Feb 17, 2023 10:02 AM
OS/Arch:             linux/x86_64
Profile:             default
Server type:         server

Additional context

No response

@leonarduschen leonarduschen added bug Something isn't working status:triage labels Feb 22, 2023
@leonarduschen
Copy link
Author

@EmilRex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants