Skip to content

Commit

Permalink
Load hulpke/extraperfect as lazy artifact (#2432)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Jun 20, 2023
1 parent 04c90ae commit 436a22f
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 14 deletions.
16 changes: 16 additions & 0 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[gap_extraperfect]
git-tree-sha1 = "084fa12573e5089ceb3299f9d341f244b415da52"
lazy = true

[[gap_extraperfect.download]]
sha256 = "e565303927682f54cba20a69b8d23673b9b9d4d2a2bc88751f58ed5d3365e29f"
url = "https://github.com/oscar-system/GAP.jl/releases/download/archive-tag/extraperfect.tar.gz"
# Created from https://github.com/hulpke/extraperfect using
# #!/bin/sh
# export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)
# rm -rf extraperfect
# mkdir extraperfect
# gzip -9 -n -c perf27.grp > extraperfect/perf27.grp.gz
# gzip -9 -n -c perf33.grp > extraperfect/perf33.grp.gz
# gtar --mtime="$(git log -1 --pretty=%cI)" --owner=0 --group=0 --numeric-owner -cvf extraperfect.tar extraperfect
# gzip -n -c extraperfect.tar > extraperfect.tar.gz
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
GAP = "c863536a-3901-11e9-33e7-d5cd0df7b904"
Hecke = "3e1990a7-5d81-5526-99ce-9ba3ff248f21"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
Nemo = "2edaba10-b0f1-5616-af89-8c11ac63239a"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Polymake = "d720cf60-89b5-51f5-aff5-213f193123e7"
Expand Down
15 changes: 15 additions & 0 deletions gap/OscarInterface/gap/OscarInterface.gi
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
BindGlobal("ReplaceGapFunc", function(name, func)
local orig_name;
# Store a copy of the original value, but only if that copy does not yet
# exist. This ensures we don't overwrite it during a call to `Reread`.
orig_name := Concatenation("_ORIG_", name);
if not IsBoundGlobal(orig_name) then
BindGlobal(orig_name, ValueGlobal(name));
fi;
MakeReadWriteGlobal(name);
UnbindGlobal(name);
BindGlobal(name, func);
end);

############################################################################

InstallOtherMethod( ImagesRepresentative,
[ IsActionHomomorphism and HasJuliaData, IsMultiplicativeElementWithInverse ],
function( hom, elm )
Expand Down
13 changes: 0 additions & 13 deletions gap/OscarInterface/gap/alnuth.gi
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,6 @@
#
LoadPackage("alnuth"); # HACK

BindGlobal("ReplaceGapFunc", function(name, func)
local orig_name;
# Store a copy of the original value, but only if that copy does not yet
# exist. This ensures we don't overwrite it during a call to `Reread`.
orig_name := Concatenation("_ORIG_", name);
if not IsBoundGlobal(orig_name) then
BindGlobal(orig_name, ValueGlobal(name));
fi;
MakeReadWriteGlobal(name);
UnbindGlobal(name);
BindGlobal(name, func);
end);

# store isomorphism between GAP and OSCAR univariate polynomial ring over the
# rationals as we need it a lot
BindGlobal("_PolyRingIso", Oscar.iso_gap_oscar(PolynomialRing(Rationals)));
Expand Down
2 changes: 1 addition & 1 deletion src/GAP/GAP.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include("wrappers.jl")
include("customize.jl")
include("utils.jl")
include("gap_to_oscar.jl")
include("oscar_to_gap.jl")
include("iso_gap_oscar.jl")
include("iso_oscar_gap.jl")

11 changes: 11 additions & 0 deletions src/GAP/utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function _write_gap_file(relpath::String, content::String)
gaproot = GAP.Setup.gaproot()
path = joinpath(gaproot, relpath)
mkpath(dirname(path))
# write to a temporary file and move later to avoid race conditions
tmpfile = tempname(dirname(path); cleanup=false)
open(tmpfile, "w") do file
write(file, content)
end
Base.Filesystem.rename(tmpfile, path)
end
2 changes: 2 additions & 0 deletions src/Groups/libraries/libraries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ function __init_group_libraries()
_atlas_group_filter_attrs[character] = (Oscar.GroupClassFunction, GAP.Globals.Character, nothing)
_atlas_group_filter_attrs[characteristic] = (_IntOrIntVec, GAP.Globals.Characteristic, nothing)
_atlas_group_filter_attrs[dim] = (_IntOrIntVec, GAP.Globals.Dimension, nothing)

__init_extraperfect()
end

# return the output of the function f and the corresponding GAP function
Expand Down
16 changes: 16 additions & 0 deletions src/Groups/libraries/perfectgroups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,19 @@ function number_perfect_groups(n::IntegerUnion)
end

# TODO: add all_perfect_groups() iterator

function __init_extraperfect()
for i in [27, 33]
_write_gap_file(
"grp/perf$(i).grp",
"Read(JuliaToGAP(IsString, Oscar._path_extraperfect($(i))));\n",
)
end
end

function _path_extraperfect(i::Int)
return joinpath(
artifact"gap_extraperfect/extraperfect",
"perf$(i).grp.gz",
)
end
1 change: 1 addition & 0 deletions src/Oscar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ OSCAR is licensed under the GPL v3+ (see LICENSE.md).
module Oscar

using Preferences
using LazyArtifacts

include("imports.jl")

Expand Down
3 changes: 3 additions & 0 deletions test/Groups/libraries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ end
@test number_perfect_groups(ZZRingElem(60)^3) == 1
@test_throws ArgumentError number_perfect_groups(0) # invalid argument
@test_throws ArgumentError number_perfect_groups(ZZRingElem(60)^10) # result not known

# lazy artifact loading (needs network access, see https://github.com/oscar-system/Oscar.jl/issues/2480)
#@test perfect_group(1376256, 1) isa PermGroup
end

@testset "Small groups" begin
Expand Down

0 comments on commit 436a22f

Please sign in to comment.