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

Migrate to HerbSpecification.jl #22

Merged
merged 5 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
name = "HerbBenchmarks"
uuid = "eadf8b74-d38a-4b1a-a063-8d36e493d376"
authors = ["jaapjong <[email protected]>", "Tilman Hinnerichs <[email protected]>", "Sebastijan Dumancic <[email protected]>"]
version = "0.1.0"
version = "0.2.0"

[deps]
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
HerbCore = "2b23ba43-8213-43cb-b5ea-38c12b45bd45"
HerbData = "495a3ad3-8034-41b3-a087-aacf2fd71098"
HerbGrammar = "4ef9e186-2fe5-4b24-8de7-9f7291f24af7"
HerbSpecification = "6d54aada-062f-46d8-85cf-a1ceaf058a06"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
SExpressions = "eaa8e424-c5f6-11e8-1b3d-d576ba0eee97"

[compat]
HerbCore = "0.1.0"
HerbData = "0.1.0"
julia = "1.8"
HerbCore = "^0.2.0"
HerbGrammar = "^0.2.0"
HerbSpecification = "^0.1.0"
julia = "^1.8"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ HerbBenchmarks is still not yet complete and is lacking crucial benchmarking fun

Select your favourite benchmark, we use the string transformation benchmark from the SyGuS challenge:
```Julia
using HerbData, HerbGrammar
using HerbSpecification, HerbGrammar

using HerbBenchmarks.PBE_SLIA_Track_2019

Expand Down
2 changes: 1 addition & 1 deletion src/HerbBenchmarks.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module HerbBenchmarks

using HerbCore
using HerbData
using HerbSpecification
using HerbGrammar

include("utils.jl")
Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks_io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ end
"""

"""
function append_cfgrammar(filepath::String, name::String, grammar::Grammar)
function append_cfgrammar(filepath::String, name::String, grammar::AbstractGrammar)
open(filepath, "a") do file
if !isprobabilistic(grammar)
println(file, "grammar_$name = @cfgrammar begin")
Expand Down Expand Up @@ -71,7 +71,7 @@ Parses a directory for all files, parses each data file using `data_file_parser`

Example usage for parsing SyGuS problems.
```julia
using HerbData, HerbGrammar
using HerbSpecification, HerbGrammar

using HerbBenchmarks

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Abstract_Reasoning_2019

using HerbCore
using HerbData
using HerbSpecification
using HerbGrammar

using JSON
Expand Down
10,558 changes: 400 additions & 10,158 deletions src/data/Abstract_Reasoning_2019/evaluation_data.jl

Large diffs are not rendered by default.

8,023 changes: 400 additions & 7,623 deletions src/data/Abstract_Reasoning_2019/training_data.jl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/data/Pixels_2020/Pixels_2020.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Pixels_2020

using HerbCore
using HerbData
using HerbSpecification
using HerbGrammar

include("data.jl")
Expand Down
1,503 changes: 501 additions & 1,002 deletions src/data/Pixels_2020/data.jl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/data/Robots_2020/Robots_2020.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Robots_2020

using HerbCore
using HerbData
using HerbSpecification
using HerbGrammar

include("data.jl")
Expand Down
3,300 changes: 1,100 additions & 2,200 deletions src/data/Robots_2020/data.jl

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module String_transformations_2020

using HerbCore
using HerbData
using HerbSpecification
using HerbGrammar

include("data.jl")
Expand Down
7,660 changes: 639 additions & 7,021 deletions src/data/String_transformations_2020/data.jl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/data/SyGuS/PBE_BV_Track_2018/PBE_BV_Track_2018.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PBE_BV_Track_2018

using HerbCore
using HerbData
using HerbSpecification
using HerbGrammar

include("data.jl")
Expand Down
189,345 changes: 753 additions & 188,592 deletions src/data/SyGuS/PBE_BV_Track_2018/data.jl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/data/SyGuS/PBE_SLIA_Track_2019/PBE_SLIA_Track_2019.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module PBE_SLIA_Track_2019

using HerbCore
using HerbData
using HerbSpecification
using HerbGrammar

include("data.jl")
Expand Down
562 changes: 100 additions & 462 deletions src/data/SyGuS/PBE_SLIA_Track_2019/data.jl

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/data/SyGuS/SyGuS.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module SyGuS

using HerbData
using HerbSpecification
using HerbCore
using HerbGrammar

Expand All @@ -15,11 +15,11 @@ export


"""
parse_sygus_grammar(filename::AbstractString)::Grammar
parse_sygus_grammar(filename::AbstractString)::AbstractGrammar

Parses a SyGuS file for its grammar, by looking for the keyword 'synth-fun' within the S-Expressions. Returns the grammar if found.
"""
function parse_sygus_grammar(filename::AbstractString)::Grammar
function parse_sygus_grammar(filename::AbstractString)::AbstractGrammar
symbol_list = SExpressions.Parser.parsefile(filename)
grammar = Nothing

Expand All @@ -35,7 +35,7 @@ end
"""
parse_sygus_problem(filename::AbstractString)::Problem

Parses a SyGuS file for all examples and returns them, wrapped in a [`HerbData.Problem`](@ref)
Parses a SyGuS file for all examples and returns them, wrapped in a [`HerbSpecification.Problem`](@ref)
"""
function parse_sygus_problem(filename::AbstractString)::Problem
symbol_list = SExpressions.Parser.parsefile(filename)
Expand All @@ -50,11 +50,11 @@ function parse_sygus_problem(filename::AbstractString)::Problem
end

"""
parse_synth_fun(sexpr::SExpressions.Lists.Cons)::Grammar
parse_synth_fun(sexpr::SExpressions.Lists.Cons)::AbstractGrammar

Parses a SyGuS grammar that are named `synth_fun` within SyGuS. Takes the S-Expression of the grammar and returns a [`@cfgrammar`](@ref).
"""
function parse_synth_fun(sexpr::SExpressions.Lists.Cons)::Grammar
function parse_synth_fun(sexpr::SExpressions.Lists.Cons)::AbstractGrammar
return_grammar = @cfgrammar begin end

if sexpr[1] !== Symbol("synth-fun")
Expand Down
6 changes: 3 additions & 3 deletions src/generate_benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using HerbCore
using HerbConstraints
using HerbGrammar
using HerbSearch
using HerbData
using HerbSpecification
using HerbEvaluation

using Serialization
Expand All @@ -23,7 +23,7 @@ domains is a list of domains for the variables
max_count is the maximum number of programs to return
skip is the number of programs to skip before appending one to the result
"""
function io_examples_all(grammar:: Grammar, eval_type:: Symbol, variables:: Vector{Symbol}, domains:: Vector{Vector{Any}}; min_size::Int, max_size::Int, max_count:: Int=10, skip:: Int=0) :: Vector{Tuple{RuleNode, Vector{IOExample}}}
function io_examples_all(grammar::AbstractGrammar, eval_type::Symbol, variables::Vector{Symbol}, domains::Vector{Vector{Any}}; min_size::Int, max_size::Int, max_count::Int=10, skip::Int=0)::Vector{Tuple{RuleNode, Vector{IOExample}}}
skip_rem = skip + 1
es = []
iterations = 0
Expand All @@ -45,7 +45,7 @@ function io_examples_all(grammar:: Grammar, eval_type:: Symbol, variables:: Vect
return es
end

function io_examples(grammar:: Grammar, program:: RuleNode, variables:: Vector{Symbol}, domains:: Vector{Vector{Any}}) :: Vector{IOExample}
function io_examples(grammar::AbstractGrammar, program::RuleNode, variables::Vector{Symbol}, domains::Vector{Vector{Any}})::Vector{IOExample}
symbol_table = SymbolTable(grammar)

# TODO: only use variables that are actually in the program
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using HerbCore
using HerbData
using HerbSpecification
using Test

@testset "HerbBenchmarks.jl" verbose=true begin
Expand Down
8 changes: 4 additions & 4 deletions test/test_datasets.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using HerbCore
using HerbData
using HerbSpecification
using Test

using HerbBenchmarks

@testset verbose=true "String transformations 2020" begin
problem = String_transformations_2020.all_problems
@test typeof(problem[1]) == HerbData.Problem
@test typeof(problem[1].examples[1]) == HerbData.IOExample
problems = all_problems(String_transformations_2020)
@test typeof(problems[1]) <: HerbSpecification.Problem
@test typeof(problems[1].spec[1]) == HerbSpecification.IOExample
end