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

logger.error does not output to stderr #2305

Open
yank666 opened this issue Feb 26, 2025 · 2 comments
Open

logger.error does not output to stderr #2305

yank666 opened this issue Feb 26, 2025 · 2 comments

Comments

@yank666
Copy link

yank666 commented Feb 26, 2025

I want to add more detailed error describe in stderr if a step faild , but when i use logger.error print ,running.stderr dosen't print my error log

if __name__=="__main__":
    with Runner('first_flow.py', show_output=True, pylint=False).run() as running:
        print(running.stderr)

here is my simple workflow

from logging import getLogger
from metaflow import FlowSpec, step, current

logger = getLogger(__name__)

class HelloFlow(FlowSpec):
    def __init__(self, use_cli=True):
        super().__init__(use_cli)
        self.doc = None

    @step
    def start(self):


        self.next(self.hello)

    @step
    def hello(self):
        logger.error(f"HelloFlow failed to hello, {current.run_id}")
        raise ValueError("error again")
        self.next(self.end)


   

    @step
    def end(self):
        pass
@savingoyal
Copy link
Collaborator

you might need to configure logger to emit to stderr

handler = logging.StreamHandler(sys.stderr)
logger.addHandler(handler)

@yank666
Copy link
Author

yank666 commented Feb 26, 2025

sorry , it nor work. When i fix code as you shown, stderr still can't catch error message

And ,another question if you konw, if workflow failed ,how can i exactly get the step that failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants