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

New GAP-level variable ErrorOutput for "*errout*" #2824

Merged
merged 2 commits into from
Sep 21, 2018

Conversation

ssiccha
Copy link
Contributor

@ssiccha ssiccha commented Sep 18, 2018

This is a "revival" of #1815.

Changes in comparison to PR #1815

The changes to markus' PR are

  • I got rid of the C level declarations
  • I'm using "*errout*" instead of wrapping it in an OutputTextFile(). The reason being that when using OutputTextFile("*errout*", bool) (with bool true or false) make testinstall fails due to the error messages vanishing into thin air. Actually they still appear in the terminal, but before all of the "testing: ..." output. I guess this may be somehow related to Out of order printing when using OutputTextFile("*stdout*", false) #2823?
  • I did not define StandardInput and StandardOutput. If GAP's i/o is going to
    be refactored by using GAP level IsOutputTextStream objects we can still define them then.

I did not do changes to colorprompt.g since I think STDOut is only defined in this file because there is no method installed for WriteAll which can take "*stdout*" as an argument. Also I have the feeling defining ErrorOutput should be a temporary solution only.

@ssiccha ssiccha added kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements topic: error handling labels Sep 18, 2018
@ssiccha ssiccha force-pushed the ss/gap-level-stdin-stdout-errout branch from 9645f68 to f99f240 Compare September 18, 2018 15:24
lib/streams.gi Outdated
@@ -642,7 +642,7 @@ function( str )
if fid = fail then
return fail;
else
AddSet( InputTextFileStillOpen, fid );
ADD_SET( InputTextFileStillOpen, fid );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, this was needed in markus' PR. But since i'm now using "*errout*" directly this is not necessary anymore. I'll fix this.

lib/error.g Outdated
PRINT_CURRENT_STATEMENT("*errout*", context);
PrintTo("*errout*", " called from\n");
PRINT_CURRENT_STATEMENT(ErrorOutput, context);
PrintTo(ErrorOutput, " called from\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am feeling a bit conflicted about the name ErrorOutput; it'll show up in tab completion easily, esp. if one is writing code that uses Error. Since it is deeply internal, I'd prefer calling it something like ERROR_OUTPUT.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will do that.

@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 18, 2018

Also this is breaking HPCGAP. I'll have a look.

@ssiccha ssiccha force-pushed the ss/gap-level-stdin-stdout-errout branch 3 times, most recently from 34a9e7e to e04b261 Compare September 18, 2018 16:40
@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 19, 2018

@fingolfin Checks pass now.

@ssiccha ssiccha force-pushed the ss/gap-level-stdin-stdout-errout branch from e04b261 to f08fcb5 Compare September 19, 2018 12:51
@codecov
Copy link

codecov bot commented Sep 19, 2018

Codecov Report

Merging #2824 into master will increase coverage by <.01%.
The diff coverage is 10%.

@@            Coverage Diff             @@
##           master    #2824      +/-   ##
==========================================
+ Coverage   76.09%    76.1%   +<.01%     
==========================================
  Files         480      480              
  Lines      240969   240969              
==========================================
+ Hits       183375   183380       +5     
+ Misses      57594    57589       -5
Impacted Files Coverage Δ
lib/error.g 38.2% <10%> (ø) ⬆️
hpcgap/lib/hpc/stdtasks.g 64.7% <0%> (+1.27%) ⬆️

@fingolfin fingolfin added the gapdays2018-fall Issues and PRs that arose at https://www.gapdays.de/gapdays2018-fall label Sep 19, 2018
Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we just merge this as is, or is there any reason not to? @markuspf @ssiccha ?

@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 20, 2018

@fingolfin it can be merged like this 👍

@ssiccha ssiccha added the release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes label Sep 20, 2018
@ssiccha ssiccha force-pushed the ss/gap-level-stdin-stdout-errout branch from f08fcb5 to 5912047 Compare September 20, 2018 15:37
@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 20, 2018

I have just added that "ERROR_OUTPUT" is a readwrite global from the start.

If you're ok with this you can merge it like this.

@ssiccha ssiccha force-pushed the ss/gap-level-stdin-stdout-errout branch 3 times, most recently from 28bd1c9 to b43200f Compare September 20, 2018 16:51
@markuspf
Copy link
Member

I would merge this but tests don't run it seems.

@fingolfin
Copy link
Member

We have completly overloaded Travis and AppVeyor. I recommend that we just wait till tomorrow with further merges, to let them finish of the dozen or so pending builds on each.

@ssiccha ssiccha force-pushed the ss/gap-level-stdin-stdout-errout branch from b43200f to 7e11276 Compare September 21, 2018 07:56
@markuspf
Copy link
Member

@ssiccha are you still making changes to this or can i merge once tests cycled?

@markuspf
Copy link
Member

Also do you mind doing a PR for JupyterKernel? Unfortunately we'll have to keep it 4.10 compatible, unless we backport this to stable-4.10.

@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 21, 2018

I broke the PR yesterday, but I didn't notice since I accidentally used the wrong gap on my machine. If this round of tests pass then it can be merged. Unless I shouldn't define ERROR_OUTPUT in the error.g file? I moved the definition to error.g since streams.gi seems to get loaded after error.g.

Yepp, I'll do the Jupyter PR. It would be nice if this got backported.

lib/streams.gd Outdated
@@ -1350,6 +1350,7 @@ DeclareGlobalFunction( "UnInstallCharReadHookFunc" );
DeclareGlobalFunction( "InputFromUser" );



Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pleas remove this change

##
## Default stream for error messages.
BindGlobal("ERROR_OUTPUT", "*errout*");
MakeReadWriteGlobal("ERROR_OUTPUT", "*errout*");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This must be in the .gd file not the .gi!

Also, if you want this writeable (apparently I misunderstood you yesterday), just use ERROR_OUTPUT:=...

lib/error.g Outdated
##
## Default stream for error messages.
BindGlobal("ERROR_OUTPUT", "*errout*");
MakeReadWriteGlobal("ERROR_OUTPUT");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why even both, why not just do: ERROR_OUTPUT := "*errout*";?

@fingolfin
Copy link
Member

@markuspf From my POV we could backport this PR to stable-4.10

@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 21, 2018

I'm now using ERROR_OUTPUT := "*errout*";. Should I leave it in the error.g file then or move it somewhere else?

This commit introduces a new global variable ERROR_OUTPUT.

As a next step one can make it possible to change the targets
of the magic strings "*stdout*", "*stdin*", and "*errout*",
as suggested by @fingolfin in gap-system#1815. See gap-system#2822.
Makes all functions in error.g use ERROR_OUTPUT instead of the magic
string "*errout*". Then the error messages can be redirected by
overwriting ERROR_OUTPUT.

This should be temporary. If the target of "*errout*" itself can be
changed, this can be reverted again. See gap-system#2822.
@ssiccha ssiccha force-pushed the ss/gap-level-stdin-stdout-errout branch from 7e11276 to 7a4ede8 Compare September 21, 2018 15:58
@fingolfin
Copy link
Member

Since it is used in error.g and only there, that indeed seems sensible.

@fingolfin fingolfin merged commit d49eb09 into gap-system:master Sep 21, 2018
@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 21, 2018

@mtorpey you should be able to use this in your package manager now. :)

@ssiccha
Copy link
Contributor Author

ssiccha commented Sep 21, 2018

It will not redirect syntax errors though since these are printed from somewhere within the kernel.

@ssiccha ssiccha deleted the ss/gap-level-stdin-stdout-errout branch September 22, 2018 08:20
@dimpase
Copy link
Member

dimpase commented Sep 26, 2018

While using libgap, I get hit by

gap: panic, could not open *errout*!

error message, and then the whole thing bails out. Should I use functionality from this PR, and if yes, how?

Or, perhaps, this is the result merging of this PR ?

@ChrisJefferson
Copy link
Contributor

I don't think this PR should have made any difference in that area, unless there was a bug.

When using libgap, are you closing the errout socket (usually 2 at the C level)?

@dimpase
Copy link
Member

dimpase commented Sep 26, 2018

the code I am porting was written for GAP 4.8.0 or so. It seems that in the meantime GAP's error handling has been changed a lot.
The old code grabs GAP's stderr_buffer and makes it available for error reporting at Python level, via an error-handler callback.

How would one do this with GAP 4.10?

@ChrisJefferson
Copy link
Contributor

I'm not sure there is a nice way, and either way we probably shouldn't be discussing it down here. It could/should be part of libgap I imagine,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-4.10-DONE gapdays2018-fall Issues and PRs that arose at https://www.gapdays.de/gapdays2018-fall kind: enhancement Label for issues suggesting enhancements; and for pull requests implementing enhancements release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes topic: error handling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants