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

feat: allow user-specified stdin #382

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/Options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,8 @@ const OPTION_DESCRIPTIONS = """- `defaults`: What set of defaults to use for `Op
Function - a function taking (loss, complexity) as arguments and returning true or false.
- `timeout_in_seconds`: Float64 - the time in seconds after which to exit (as an alternative to the number of iterations).
- `max_evals`: Int (or Nothing) - the maximum number of evaluations of expressions to perform.
- `input_stream`: the stream to read user input from. By default, this is `stdin`. If you encounter issues
with reading from `stdin`, like a hang, you can simply pass `devnull` to this argument.
- `skip_mutation_failures`: Whether to simply skip over mutations that fail or are rejected, rather than to replace the mutated
expression with the original expression and proceed normally.
- `nested_constraints`: Specifies how many times a combination of operators can be nested. For example,
Expand Down Expand Up @@ -574,6 +576,7 @@ $(OPTION_DESCRIPTIONS)
## 10. Stopping Criteria:
timeout_in_seconds::Union{Nothing,Real}=nothing,
max_evals::Union{Nothing,Integer}=nothing,
input_stream::IO=stdin,
## 11. Performance and Parallelization:
turbo::Bool=false,
bumper::Bool=false,
Expand Down Expand Up @@ -926,6 +929,7 @@ $(OPTION_DESCRIPTIONS)
Val(deprecated_return_state),
timeout_in_seconds,
max_evals,
input_stream,
skip_mutation_failures,
_nested_constraints,
deterministic,
Expand Down
1 change: 1 addition & 0 deletions src/OptionsStruct.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ struct Options{
return_state::Val{_return_state}
timeout_in_seconds::Union{Float64,Nothing}
max_evals::Union{Int,Nothing}
input_stream::IO
skip_mutation_failures::Bool
nested_constraints::Union{Vector{Tuple{Int,Int,Vector{Tuple{Int,Int,Int}}}},Nothing}
deterministic::Bool
Expand Down
2 changes: 1 addition & 1 deletion src/SymbolicRegression.jl
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ end
@stable default_mode = "disable" function _create_workers(
datasets::Vector{D}, ropt::AbstractRuntimeOptions, options::AbstractOptions
) where {T,L,D<:Dataset{T,L}}
stdin_reader = watch_stream(stdin)
stdin_reader = watch_stream(options.input_stream)

record = RecordType()
@recorder record["options"] = "$(options)"
Expand Down
Loading