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

Report errors to stdout in REPL mode #417

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yihozhang
Copy link
Collaborator

Without this PR, the user of egglog (which can be say another process) cannot check if the command is successfully executed. The downside of this change is that every error message is now duplicated in the REPL mode. I don't know what the best design here would be. Maybe having another command line flag for this?

Indeed, there are some nuanced differences in the expected behaviors of REPL-mode egglog vs egglog communicating with other processes via stdin/out ("sidecar" egglog).

  • If a command fails, REPL egglog should just ignore this command and continue to read second command, while it may make more sense for sidecar egglog to halt.
  • In REPL egglog because both stderr and stdout are printed in the CLI, we should avoid duplicating information like error messages between stdout/stderr. But this is not true for sidecar egglog since the host process only monitors stderr.

Thoughts and ideas are welcome!

@yihozhang yihozhang requested a review from a team as a code owner August 20, 2024 01:12
@yihozhang yihozhang requested review from oflatt and removed request for a team August 20, 2024 01:12
@saulshanabrook
Copy link
Member

I didn't know sidecar egglog was a thing!

If a command fails, REPL egglog should just ignore this command and continue to read second command, while it may make more sense for sidecar egglog to halt.

That makes sense to me.

In REPL egglog because both stderr and stdout are printed in the CLI, we should avoid duplicating information like error messages between stdout/stderr. But this is not true for sidecar egglog since the host process only monitors stderr.

Hm, why doesn't it monitor stdout?

@yihozhang
Copy link
Collaborator Author

yihozhang commented Aug 20, 2024 via email

@oflatt
Copy link
Member

oflatt commented Aug 22, 2024

For sidecar egglog, I think this PR isn't sufficient. We need a reliable way to check that a command has finished, since the absence of an error isn't enough.

My recommendation is that we have an option that prints s-expressions as the output, one s-expression per command.
So in sidecar mode we would have
(
"Added a rule with name myrule to ruleset blank"
"Some other information printed out"
)

As for the duplication, having a command line flag for REPL mode sounds fine to me

@oflatt
Copy link
Member

oflatt commented Aug 22, 2024

@ezrosent suggestion:
Give egglog a mode where it accepts egglog and spits out JSON. That way you get structured output.
@oflatt likes this idea (the default could be REPL mode, solving the problem in this PR)

@yihozhang yihozhang marked this pull request as draft November 6, 2024 22:59
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

Successfully merging this pull request may close these issues.

3 participants