diff --git a/pysr/julia_import.py b/pysr/julia_import.py index 4ea6b88d..26288c75 100644 --- a/pysr/julia_import.py +++ b/pysr/julia_import.py @@ -64,5 +64,8 @@ def _import_juliacall(): jl.seval("using SymbolicRegression") SymbolicRegression = jl.SymbolicRegression +# Expose `D` operator: +jl.seval("using SymbolicRegression: D") + jl.seval("using Pkg: Pkg") Pkg = jl.Pkg diff --git a/pysr/juliapkg.json b/pysr/juliapkg.json index 9c28c96e..1673a713 100644 --- a/pysr/juliapkg.json +++ b/pysr/juliapkg.json @@ -3,7 +3,7 @@ "packages": { "SymbolicRegression": { "uuid": "8254be44-1295-4e6a-a16d-46603ac705cb", - "version": "=1.2.0" + "version": "=1.4.0" }, "Serialization": { "uuid": "9e88b42a-f829-5b0c-bbe9-9e923198166b", diff --git a/pysr/param_groupings.yml b/pysr/param_groupings.yml index f43c67f9..769e6647 100644 --- a/pysr/param_groupings.yml +++ b/pysr/param_groupings.yml @@ -92,6 +92,7 @@ - print_precision - progress - logger_spec + - input_stream - Environment: - temp_equation_file - tempdir diff --git a/pysr/sr.py b/pysr/sr.py index c23805b4..c7beae23 100644 --- a/pysr/sr.py +++ b/pysr/sr.py @@ -618,6 +618,12 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator): Logger specification for the Julia backend. See, for example, `TensorBoardLoggerSpec`. Default is `None`. + input_stream : str + 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. You can also + reference an arbitrary Julia object in the `Main` namespace. + Default is `"stdin"`. run_id : str A unique identifier for the run. Will be generated using the current date and time if not provided. @@ -863,6 +869,7 @@ def __init__( print_precision: int = 5, progress: bool = True, logger_spec: AbstractLoggerSpec | None = None, + input_stream: str = "stdin", run_id: str | None = None, output_directory: str | None = None, temp_equation_file: bool = False, @@ -969,6 +976,7 @@ def __init__( self.print_precision = print_precision self.progress = progress self.logger_spec = logger_spec + self.input_stream = input_stream # - Project management self.run_id = run_id self.output_directory = output_directory @@ -1888,6 +1896,8 @@ def _run( else "nothing" ) + input_stream = jl.seval(self.input_stream) + load_required_packages( turbo=self.turbo, bumper=self.bumper, @@ -2002,6 +2012,7 @@ def _run( crossover_probability=self.crossover_probability, skip_mutation_failures=self.skip_mutation_failures, max_evals=self.max_evals, + input_stream=input_stream, early_stop_condition=early_stop_condition, seed=seed, deterministic=self.deterministic,