0

At the beginning of my IJulia notebook, I have the following preamble that imports several libraries and puts them on all processors:

addprocs(4)
import PyCall
@everywhere using PyCall
@everywhere @pyimport numpy as np
@everywhere @pyimport scipy as sc
.
.
.

The format is from the excepted answer to one of my previous questions. What I want to do now is add the processors and import all my packages in one line. However, I am not sure what would be the most efficient way to do this. I am collaborating with several people on different scientific projects, and I would prefer this importing process to be as simple as possible. Should I make a separate file calling these libraries and then run that file, or should I make my own package that does the above--i.e., define a package that automatically adds the processors, imports the packages, and puts them on all processors?

Joshuah Heath
  • 663
  • 1
  • 5
  • 20
  • 1
    Depends what you mean by "efficient" in this context, but yes, the simplest thing to do would be to put all these instructions in a file called `preamble.jl` and then `include("preamble.jl");` as the first line of your code / script. – Tasos Papastylianou May 25 '17 at 22:35
  • Also, keep in mind that these macros are prone to breaking, so test things thoroughly to check if you'd have to do some of those imports manually yourself. e.g. does `remotecall_fetch(np.array, 2, [1,2,3,4])` work for you after the `@everywhere @pyimport` statement? Or does it segfault and kill the process? – Tasos Papastylianou May 25 '17 at 22:41

0 Answers0