Julia invoke script on existing REPL from command line
up vote
1
down vote
favorite
I want to run a Julia script from window command line, but it seems everytime I run > Julia code.jl
, a new instance of Julia is created and the initiation time (package loading, compiling?) is quite long.
Is there a way for me to skip this initiation time by running the script on the current REPL/Julia instance? (which usually saves me 50% of running time).
I am using Julia 1.0.
Thank you,
cmd julia-lang read-eval-print-loop
add a comment |
up vote
1
down vote
favorite
I want to run a Julia script from window command line, but it seems everytime I run > Julia code.jl
, a new instance of Julia is created and the initiation time (package loading, compiling?) is quite long.
Is there a way for me to skip this initiation time by running the script on the current REPL/Julia instance? (which usually saves me 50% of running time).
I am using Julia 1.0.
Thank you,
cmd julia-lang read-eval-print-loop
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I want to run a Julia script from window command line, but it seems everytime I run > Julia code.jl
, a new instance of Julia is created and the initiation time (package loading, compiling?) is quite long.
Is there a way for me to skip this initiation time by running the script on the current REPL/Julia instance? (which usually saves me 50% of running time).
I am using Julia 1.0.
Thank you,
cmd julia-lang read-eval-print-loop
I want to run a Julia script from window command line, but it seems everytime I run > Julia code.jl
, a new instance of Julia is created and the initiation time (package loading, compiling?) is quite long.
Is there a way for me to skip this initiation time by running the script on the current REPL/Julia instance? (which usually saves me 50% of running time).
I am using Julia 1.0.
Thank you,
cmd julia-lang read-eval-print-loop
cmd julia-lang read-eval-print-loop
asked Nov 15 at 16:08
Huy Tran
112
112
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
There are several possible solutions. All of them involve different ways of sending commands to a running Julia session. The first few that come to my mind are:
- use sockets as explained in https://docs.julialang.org/en/v1/manual/networking-and-streams/#A-simple-TCP-example-1
- set up a HTTP server e.g. using https://github.com/JuliaWeb/HTTP.jl
- use named pipes, as explained in Named pipe does not wait until completion in bash
- communicate e.g. through the file system (e.g. make Julia scan some folder for
.jl
files and if it finds them there they get executed and moved to another folder or deleted) - this is probably simplest to implement correctly
In all the solutions you can send the command to Julia by executing some shell command.
No matter which approach you prefer the key challenge is sanitizing the code to handle errors properly (i.e. a situation when you sent some command to the Julia session and it crashes or when you send requests faster than Julia is able to handle them). This is especially important if you want the Julia server to be detached from the terminal.
As a side note: when using the Distributed module from stdlib in Julia for multiprocessing you actually do a very similar thing (but the communication is Julia to Julia) so you can also have a look how this module is implemented to get the feeling how it can be done.
Thank you. I will look into this. Currently, what I do is using a 'while(true) sleep(1)' to listen to the trigger signal file, which is kinda like a server I guess.
– Huy Tran
Nov 15 at 22:39
Yes - this is something like solution four I have described, where you achieve synchronization via the file system.
– Bogumił Kamiński
Nov 15 at 22:42
add a comment |
up vote
0
down vote
You can use include
:
julia> include("code.jl")
Hi, it should be from terminal (cmd), not from the current running julia REPL.
– Huy Tran
Nov 15 at 16:50
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323489%2fjulia-invoke-script-on-existing-repl-from-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
There are several possible solutions. All of them involve different ways of sending commands to a running Julia session. The first few that come to my mind are:
- use sockets as explained in https://docs.julialang.org/en/v1/manual/networking-and-streams/#A-simple-TCP-example-1
- set up a HTTP server e.g. using https://github.com/JuliaWeb/HTTP.jl
- use named pipes, as explained in Named pipe does not wait until completion in bash
- communicate e.g. through the file system (e.g. make Julia scan some folder for
.jl
files and if it finds them there they get executed and moved to another folder or deleted) - this is probably simplest to implement correctly
In all the solutions you can send the command to Julia by executing some shell command.
No matter which approach you prefer the key challenge is sanitizing the code to handle errors properly (i.e. a situation when you sent some command to the Julia session and it crashes or when you send requests faster than Julia is able to handle them). This is especially important if you want the Julia server to be detached from the terminal.
As a side note: when using the Distributed module from stdlib in Julia for multiprocessing you actually do a very similar thing (but the communication is Julia to Julia) so you can also have a look how this module is implemented to get the feeling how it can be done.
Thank you. I will look into this. Currently, what I do is using a 'while(true) sleep(1)' to listen to the trigger signal file, which is kinda like a server I guess.
– Huy Tran
Nov 15 at 22:39
Yes - this is something like solution four I have described, where you achieve synchronization via the file system.
– Bogumił Kamiński
Nov 15 at 22:42
add a comment |
up vote
1
down vote
There are several possible solutions. All of them involve different ways of sending commands to a running Julia session. The first few that come to my mind are:
- use sockets as explained in https://docs.julialang.org/en/v1/manual/networking-and-streams/#A-simple-TCP-example-1
- set up a HTTP server e.g. using https://github.com/JuliaWeb/HTTP.jl
- use named pipes, as explained in Named pipe does not wait until completion in bash
- communicate e.g. through the file system (e.g. make Julia scan some folder for
.jl
files and if it finds them there they get executed and moved to another folder or deleted) - this is probably simplest to implement correctly
In all the solutions you can send the command to Julia by executing some shell command.
No matter which approach you prefer the key challenge is sanitizing the code to handle errors properly (i.e. a situation when you sent some command to the Julia session and it crashes or when you send requests faster than Julia is able to handle them). This is especially important if you want the Julia server to be detached from the terminal.
As a side note: when using the Distributed module from stdlib in Julia for multiprocessing you actually do a very similar thing (but the communication is Julia to Julia) so you can also have a look how this module is implemented to get the feeling how it can be done.
Thank you. I will look into this. Currently, what I do is using a 'while(true) sleep(1)' to listen to the trigger signal file, which is kinda like a server I guess.
– Huy Tran
Nov 15 at 22:39
Yes - this is something like solution four I have described, where you achieve synchronization via the file system.
– Bogumił Kamiński
Nov 15 at 22:42
add a comment |
up vote
1
down vote
up vote
1
down vote
There are several possible solutions. All of them involve different ways of sending commands to a running Julia session. The first few that come to my mind are:
- use sockets as explained in https://docs.julialang.org/en/v1/manual/networking-and-streams/#A-simple-TCP-example-1
- set up a HTTP server e.g. using https://github.com/JuliaWeb/HTTP.jl
- use named pipes, as explained in Named pipe does not wait until completion in bash
- communicate e.g. through the file system (e.g. make Julia scan some folder for
.jl
files and if it finds them there they get executed and moved to another folder or deleted) - this is probably simplest to implement correctly
In all the solutions you can send the command to Julia by executing some shell command.
No matter which approach you prefer the key challenge is sanitizing the code to handle errors properly (i.e. a situation when you sent some command to the Julia session and it crashes or when you send requests faster than Julia is able to handle them). This is especially important if you want the Julia server to be detached from the terminal.
As a side note: when using the Distributed module from stdlib in Julia for multiprocessing you actually do a very similar thing (but the communication is Julia to Julia) so you can also have a look how this module is implemented to get the feeling how it can be done.
There are several possible solutions. All of them involve different ways of sending commands to a running Julia session. The first few that come to my mind are:
- use sockets as explained in https://docs.julialang.org/en/v1/manual/networking-and-streams/#A-simple-TCP-example-1
- set up a HTTP server e.g. using https://github.com/JuliaWeb/HTTP.jl
- use named pipes, as explained in Named pipe does not wait until completion in bash
- communicate e.g. through the file system (e.g. make Julia scan some folder for
.jl
files and if it finds them there they get executed and moved to another folder or deleted) - this is probably simplest to implement correctly
In all the solutions you can send the command to Julia by executing some shell command.
No matter which approach you prefer the key challenge is sanitizing the code to handle errors properly (i.e. a situation when you sent some command to the Julia session and it crashes or when you send requests faster than Julia is able to handle them). This is especially important if you want the Julia server to be detached from the terminal.
As a side note: when using the Distributed module from stdlib in Julia for multiprocessing you actually do a very similar thing (but the communication is Julia to Julia) so you can also have a look how this module is implemented to get the feeling how it can be done.
answered Nov 15 at 19:10
Bogumił Kamiński
11.7k11120
11.7k11120
Thank you. I will look into this. Currently, what I do is using a 'while(true) sleep(1)' to listen to the trigger signal file, which is kinda like a server I guess.
– Huy Tran
Nov 15 at 22:39
Yes - this is something like solution four I have described, where you achieve synchronization via the file system.
– Bogumił Kamiński
Nov 15 at 22:42
add a comment |
Thank you. I will look into this. Currently, what I do is using a 'while(true) sleep(1)' to listen to the trigger signal file, which is kinda like a server I guess.
– Huy Tran
Nov 15 at 22:39
Yes - this is something like solution four I have described, where you achieve synchronization via the file system.
– Bogumił Kamiński
Nov 15 at 22:42
Thank you. I will look into this. Currently, what I do is using a 'while(true) sleep(1)' to listen to the trigger signal file, which is kinda like a server I guess.
– Huy Tran
Nov 15 at 22:39
Thank you. I will look into this. Currently, what I do is using a 'while(true) sleep(1)' to listen to the trigger signal file, which is kinda like a server I guess.
– Huy Tran
Nov 15 at 22:39
Yes - this is something like solution four I have described, where you achieve synchronization via the file system.
– Bogumił Kamiński
Nov 15 at 22:42
Yes - this is something like solution four I have described, where you achieve synchronization via the file system.
– Bogumił Kamiński
Nov 15 at 22:42
add a comment |
up vote
0
down vote
You can use include
:
julia> include("code.jl")
Hi, it should be from terminal (cmd), not from the current running julia REPL.
– Huy Tran
Nov 15 at 16:50
add a comment |
up vote
0
down vote
You can use include
:
julia> include("code.jl")
Hi, it should be from terminal (cmd), not from the current running julia REPL.
– Huy Tran
Nov 15 at 16:50
add a comment |
up vote
0
down vote
up vote
0
down vote
You can use include
:
julia> include("code.jl")
You can use include
:
julia> include("code.jl")
answered Nov 15 at 16:36
fredrikekre
1,8051512
1,8051512
Hi, it should be from terminal (cmd), not from the current running julia REPL.
– Huy Tran
Nov 15 at 16:50
add a comment |
Hi, it should be from terminal (cmd), not from the current running julia REPL.
– Huy Tran
Nov 15 at 16:50
Hi, it should be from terminal (cmd), not from the current running julia REPL.
– Huy Tran
Nov 15 at 16:50
Hi, it should be from terminal (cmd), not from the current running julia REPL.
– Huy Tran
Nov 15 at 16:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323489%2fjulia-invoke-script-on-existing-repl-from-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown