MilesCranmer commited on
Commit
42acd41
1 Parent(s): 1e552a8

PyJulia actually works for distributed if done internally

Browse files
Files changed (1) hide show
  1. pysr/sr.py +19 -18
pysr/sr.py CHANGED
@@ -281,12 +281,13 @@ def pysr(
281
  # Start up Julia:
282
  global Main
283
  if pyjulia and Main is None:
284
- if not multithreading:
285
- raise AssertionError(
286
- "PyJulia does not support multiprocessing. Turn multithreading=True."
287
- )
288
 
289
- os.environ["JULIA_NUM_THREADS"] = str(procs)
 
290
  from julia import Main
291
 
292
  buffer_available = "buffer" in sys.stdout.__dir__() and not pyjulia
@@ -560,7 +561,7 @@ def pysr(
560
  else:
561
  kwargs["def_datasets"] = _make_datasets_julia_str(**kwargs)
562
 
563
- _create_julia_files(**kwargs)
564
  _final_pysr_process(**kwargs)
565
 
566
  _set_globals(**kwargs)
@@ -649,24 +650,24 @@ def _create_julia_files(
649
  with open(hyperparam_filename, "w") as f:
650
  print(def_hyperparams, file=f)
651
 
652
- with open(dataset_filename, "w") as f:
653
- print(def_datasets, file=f)
654
 
655
  with open(runfile_filename, "w") as f:
656
 
657
- print(f"import Pkg", file=f)
658
- print(f'Pkg.activate("{_escape_filename(julia_project)}")', file=f)
659
- if need_install:
660
- print(f"Pkg.instantiate()", file=f)
661
- print("Pkg.update()", file=f)
662
- print("Pkg.precompile()", file=f)
663
- elif update:
664
- print(f"Pkg.update()", file=f)
665
- print(f"using SymbolicRegression", file=f)
666
 
667
  print(f'include("{_escape_filename(hyperparam_filename)}")', file=f)
668
 
669
- print(f'include("{_escape_filename(dataset_filename)}")', file=f)
670
 
671
  varMap = _make_varmap(X, variable_names)
672
 
 
281
  # Start up Julia:
282
  global Main
283
  if pyjulia and Main is None:
284
+ # if not multithreading:
285
+ # raise AssertionError(
286
+ # "PyJulia does not support multiprocessing. Turn multithreading=True."
287
+ # )
288
 
289
+ if multithreading:
290
+ os.environ["JULIA_NUM_THREADS"] = str(procs)
291
  from julia import Main
292
 
293
  buffer_available = "buffer" in sys.stdout.__dir__() and not pyjulia
 
561
  else:
562
  kwargs["def_datasets"] = _make_datasets_julia_str(**kwargs)
563
 
564
+ _create_julia_files(**kwargs)
565
  _final_pysr_process(**kwargs)
566
 
567
  _set_globals(**kwargs)
 
650
  with open(hyperparam_filename, "w") as f:
651
  print(def_hyperparams, file=f)
652
 
653
+ with open(dataset_filename, "w") as f:
654
+ print(def_datasets, file=f)
655
 
656
  with open(runfile_filename, "w") as f:
657
 
658
+ print(f"import Pkg", file=f)
659
+ print(f'Pkg.activate("{_escape_filename(julia_project)}")', file=f)
660
+ if need_install:
661
+ print(f"Pkg.instantiate()", file=f)
662
+ print("Pkg.update()", file=f)
663
+ print("Pkg.precompile()", file=f)
664
+ elif update:
665
+ print(f"Pkg.update()", file=f)
666
+ print(f"using SymbolicRegression", file=f)
667
 
668
  print(f'include("{_escape_filename(hyperparam_filename)}")', file=f)
669
 
670
+ print(f'include("{_escape_filename(dataset_filename)}")', file=f)
671
 
672
  varMap = _make_varmap(X, variable_names)
673