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

Make ElasticManager more convenient #136

Merged
merged 2 commits into from
Jul 16, 2020

Conversation

marius311
Copy link
Contributor

@marius311 marius311 commented May 2, 2020

This adds two things discussed in #128

First, it gives ElasticManager the addr=:auto option on Linux, which looks up the master's IP address via hostname --ip-address so that you get the private IP and other workers on the LAN can connect to it. This isn't foolproof depending on the network setup, but its 4 for 4 on the HPC clusters I have access to.

Second, it adds a line to what is printed when you evaluate an ElasticManager,

julia> em = ElasticManager(addr=:auto, port=0)
ElasticManager:
  Active workers : []
  Number of workers to be added  : 0
  Terminated workers : []
  Worker connect command : 
    /home/user/bin/julia --project=/home/user/myproject/Project.toml -e 'using ClusterManagers; ClusterManagers.elastic_worker("4cOSyaYpgSl6BC0C","127.0.1.1",36275)'

So that you can just copy/paste that last line without thinking and get a worker.

Finally, I reworked the readme and removed the part about the deprecated @scheduled which doesn't work anymore, even if you switch to @async.

Hopefully this makes setting up an ElasticManager way more streamlined. Let me know if you there's any feedback, I'm happy to make changes.

Closes #128

port = convert(Int,em.sockname[2])
cookie = cluster_cookie()
exename = absolute_exename ? joinpath(Sys.BINDIR, Base.julia_exename()) : "julia"
project = same_project ? ("--project=$(Pkg.API.Context().env.project_file)",) : ()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this one function is sufficient reason to take a dependency on Pkg. And how sure are we that that implementation is stable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking this over. I'm not sure I understand the issue with taking a dependency. Everyone's Julia installation will always include Pkg and load time is tiny. Re stability, I can say at least that Pkg.API.Context().env.project_file seems to be the way Pkg itself looks up the current package to e.g. print when you do Pkg.status().

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency is not so much about loading time, and more about maintenance burden. The reason I ask about stability is because, if it's not exported/part of the stable API, then updates are free to break it without consideration. Given that this package doesn't have great (or any really) tests yet, it may be particularly important that we don't add too much maintenance burden.

That said, I'm not the one to approve/reject, just wanted to flag it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as of julia 1.4 there is also Pkg.project().name. for what version will Pkg.API.Context().env.project_file work?

Copy link
Contributor Author

@marius311 marius311 May 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ for ver in 1.0 1.1 1.2 1.3 1.4; do docker run --rm julia:$ver julia -e "using Pkg; @show Pkg.API.Context().env.project_file"; done
(((Pkg.API).Context()).env).project_file = "/root/.julia/environments/v1.0/Project.toml"
(((Pkg.API).Context()).env).project_file = "/root/.julia/environments/v1.1/Project.toml"
(Pkg.API.Context()).env.project_file = "/root/.julia/environments/v1.2/Project.toml"
(Pkg.API.Context()).env.project_file = "/root/.julia/environments/v1.3/Project.toml"
(Pkg.API.Context()).env.project_file = "/root/.julia/environments/v1.4/Project.toml"

Everything back to the lowest supported version by this package (1.0) looks good, as does nightly which I just checked by hand.


function ElasticManager(;addr=IPv4("127.0.0.1"), port=9009, cookie=nothing, topology=:all_to_all)
function ElasticManager(;addr=IPv4("127.0.0.1"), port=9009, cookie=nothing, topology=:all_to_all, printing_kwargs=())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there are only two allowed printing_kwargs here, a tuple seems like a weird way to do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just didn't want to balloon the number of keyword arguments for ElasticManager and also ElasticManager(..., printing_kwargs=(same_project=true,)) implies same_project=true applies just to printing but ElasticManager(..., same_project=true) might not. But I'm happy to change it however you see fit.

@marius311
Copy link
Contributor Author

Just a friendly ping for whoever can merge this. I'm happy to make any changes requested.

@kescobo
Copy link
Collaborator

kescobo commented May 13, 2020

I can merge, but don't know if I should merge. I got the write bit to help a bit with tests at some point, but don't feel like I have enough authority to actually merge.

@bjarthur
Copy link
Collaborator

yea, me too. would be nice to have other elasticmanager users chime in with comments.

and a test certainly would be nice. could you possibly add one that simply runs the command this PR now prints out to make sure a julia process is actually launched? e,g., no typos in the command string.

@marius311
Copy link
Contributor Author

Sounds good, will add a test.

@marius311 marius311 marked this pull request as ready for review May 13, 2020 19:56
@marius311
Copy link
Contributor Author

Ok, added a test which actually runs the command and checks a worker connects. Also figured out how to do it on Mac. Ready from my end!

@marius311
Copy link
Contributor Author

Merge?

@marius311
Copy link
Contributor Author

Hey guys, could this possibly be merged?

I'm around to do any quick fixes should problems arise, but personally has been working great for me, e.g.:

image

@kescobo
Copy link
Collaborator

kescobo commented Jul 16, 2020

Since no one else has chimed in, there's a test written, and it seems like actual maintainers of this package don't check in too often, I'm going to go ahead and merge. We can always revert if someone bitterly complains after the fact.

That said, I don't know how I feel about tagging a version given that one of the maintainers did actively object to that in #118

@kescobo kescobo merged commit 9d727f7 into JuliaParallel:master Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ElasticManager print out connection instructions
3 participants