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

catch exceptions in GAP.Packages.install #815

Merged
merged 3 commits into from
Jun 10, 2022

Conversation

ThomasBreuer
Copy link
Member

@codecov
Copy link

codecov bot commented Jun 2, 2022

Codecov Report

Merging #815 (7abc854) into master (8dd4fb2) will decrease coverage by 0.02%.
The diff coverage is 72.72%.

@@            Coverage Diff             @@
##           master     #815      +/-   ##
==========================================
- Coverage   78.05%   78.03%   -0.03%     
==========================================
  Files          48       48              
  Lines        3669     3687      +18     
==========================================
+ Hits         2864     2877      +13     
- Misses        805      810       +5     
Impacted Files Coverage Δ
src/packages.jl 63.46% <72.72%> (-3.21%) ⬇️
src/adapter.jl 70.78% <0.00%> (+2.88%) ⬆️
pkg/JuliaInterface/gap/utils.gi 22.95% <0.00%> (+4.76%) ⬆️

@ThomasBreuer ThomasBreuer requested a review from fingolfin June 2, 2022 13:14
@fingolfin
Copy link
Member

It addresses it only partially, though: Oscar expects these packages (well, at least ferret) to be loaded in certain places. And by simply silencing the error during startup, we will cause these functions later on to break with no helpful error.

As it is, if go this way, then at the least we should also change Oscar.jl to explicitly check for an error return value when calling this install method and report an appropriate warning to the user (i.e., that a bunch of computations will be slower); or, perhaps better, to adjust the code which relies on e.g. ferret to issue that warning.

Anyway, of course this is still vastly better than the current situation, where some people can't load Oscar at all.

As always, the real fix would be to get GAP_pkg_ferret and so on ready... I'll try to put that in focus again sigh.

@ThomasBreuer
Copy link
Member Author

ThomasBreuer commented Jun 3, 2022

@fingolfin I agree.

In the current setup, the GAP.Packages.load calls in Oscar set quiet to true (for good reasons), thus the warnings have to be added to the Oscar code. Showing the warnings in the initializations has the advantage that we cannot miss some place in the code where they are relevant (and that they are not shown over and over again). The code in Oscar/experimental/GaloisGrp is already safe w.r.t. the possibility that ferret is not available: There is one place in GaloisGrp.jl where ferret's Solve is called, and this call is avoided if GAP.Globals.ConStabilize is not bound.

Thus the only additional question seems to be where to add suitable warnings about possible performance problems.

(Another point: A quick fix for Oscar would be to wrap the GAP.Packages.load calls into try/catch. Shall we do this for the moment?)

@fingolfin
Copy link
Member

I've thought some more about it, and I guess perhaps the "best" fix actually would be to adjust our hack further up in the file you are editing here, where we overwrite a PackageManager function to make it use Julia's download() function. I think we should catch the exception in there because it's actually not advisable to throw a Julia exception through GAP code (in theory it usually works, in practice we (well, probably me) should at some point sit down for 2-3 days and careful audit that case and make sure all corner cases are really dealt with)

@ThomasBreuer
Copy link
Member Author

@fingolfin My idea was to catch any error that may happen on the GAP side during the attempt to install the package, not only the "offline problem". Perhaps we should use each of the two ideas?

@fingolfin
Copy link
Member

Yeah, sounds sensible

@ThomasBreuer
Copy link
Member Author

O.k., I will modify the pull request.

@fingolfin
Copy link
Member

@ThomasBreuer do you think you'll have a chance to revise this today? Otherwise, I'd just merge this as-is and make a release, so that the immediate bug is fixed; a "better" fix can be done later.

@ThomasBreuer
Copy link
Member Author

ThomasBreuer commented Jun 10, 2022

@fingolfin I hope the variant I just pushed is good.
Since GAP's PackageManager does not deal with exceptions, the only idea I had was to catch the error in the Julia code that is
executed by PackageManager, in order not to run into a GAP error, and to rethrow the Julia exception.
Now the Julia error message is shown in the end if one is offline.

src/packages.jl Outdated
Comment on lines 22 to 24
catch e
rethrow()
end
Copy link
Member

@fingolfin fingolfin Jun 10, 2022

Choose a reason for hiding this comment

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

But that's completely redundant, it does nothing at all. I.e. you could just leave it out.

How about this instead?

Suggested change
catch e
rethrow()
end
catch e
return GapObj(Dict{Symbol, Any}(:success => false))
end

@fingolfin fingolfin merged commit 80626e6 into oscar-system:master Jun 10, 2022
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.

2 participants