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

RFC: Fixed relative path include on remote machines #21832

Merged
merged 9 commits into from
Jun 27, 2017

Conversation

Gollor
Copy link
Contributor

@Gollor Gollor commented May 12, 2017

The fix of #21679
This code works when the remote machine tries to include the file using the current working directory. Previously the machine was resolving the path locally, what could lead to errors with relative paths. In the case of include("file.jl") machine remote@remotehost could try to download /home/remote/file.jl from the main machine local@localhost when the true file location is /home/local/file.jl.
Now if the remote machine has to use working directory to include files it will use the main machine working directory instead.

@Gollor Gollor closed this May 13, 2017
@Gollor Gollor deleted the remoteinclude branch May 13, 2017 00:47
@Gollor Gollor restored the remoteinclude branch May 13, 2017 00:48
@Gollor Gollor reopened this May 13, 2017
@tkelman tkelman added the needs tests Unit tests are required for this change label May 13, 2017
try rm("temp.jl") end
return false
end
end == true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test that passes on both versions.

try rm("temp.jl") end
return false
end
end == true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test that requires the fix to pass.

@test let
# creates a new worker in the same folder and tries to include file on both procs
try
touch("temp.jl")
Copy link
Contributor

Choose a reason for hiding this comment

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

we should avoid assuming the current working directory is writable, in some installations it won't be - a mktemp() do block might work well here

@tkelman tkelman removed the needs tests Unit tests are required for this change label May 13, 2017
cd(working_directory)
return true
catch e
try rm(tmp_dir) end
Copy link
Contributor

Choose a reason for hiding this comment

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

better as rm(tmp_dir, force=true) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, that should be better.

@test let
# creates a new worker in the different folder and tries to include file on both procs
working_directory = pwd()
cd(tempdir())
Copy link
Contributor

@tkelman tkelman May 13, 2017

Choose a reason for hiding this comment

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

cd(tempdir()) do
   ...
end

will automatically go back to the original working directory even on failure, bit cleaner

@Gollor
Copy link
Contributor Author

Gollor commented May 13, 2017

I removed the cd( ... ) statement at all since it was conflicting with the local include which is based not on the working directory but on the location of jl file. Now both local and remote includes are following the same relative path.

base/loading.jl Outdated
@@ -263,6 +263,9 @@ const _require_dependencies = Any[] # a list of (path, mtime) tuples that are th
const _track_dependencies = Ref(false) # set this to true to track the list of file dependencies
function _include_dependency(_path::AbstractString)
prev = source_path(nothing)
if myid() != 1 && prev === nothing
prev = remotecall_fetch(abspath, 1, ".")
end
Copy link
Member

Choose a reason for hiding this comment

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

it seems like this may confuse the SOURCE_PATH pop in include_from_node1.

I think it'll be clearer to be explicit here:

    prev = source_path(nothing)
    if prev === nothing
        if myid() == 1
            path = abspath(_path)
        else
            path = joinpath(remotecall_fetch(abspath, 1, "."), _path)
        end
    else
        path = joinpath(dirname(prev), _path)
    end
    if myid() == 1 && _track_dependencies[]
        push!(_require_dependencies, (path, mtime(path)))
    end

Copy link
Contributor Author

@Gollor Gollor May 16, 2017

Choose a reason for hiding this comment

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

@vtjnash Looks nice. But is there a reason why the list of dependencies receives the regular path instead of explicitly absolute one?

Copy link
Member

Choose a reason for hiding this comment

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

because abspath(abspath()) seems unnecessary

@andreasnoack
Copy link
Member

@vtjnash Is this good to go?

end == true

@test let
# creates a new worker in the different folder and tries to include file
Copy link
Contributor

Choose a reason for hiding this comment

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

in a different folder

@vtjnash vtjnash merged commit f31e163 into JuliaLang:master Jun 27, 2017
@tkelman
Copy link
Contributor

tkelman commented Jun 27, 2017

this should have been squashed

@StefanKarpinski
Copy link
Member

Can we PLEASE pay more attention to squashing versus not squashing when merging PRs? This is not hard to do – take a few seconds when you're merging something.

ararslan pushed a commit that referenced this pull request Sep 11, 2017
Fix relative path `include` on remote machines

Ref #21832
(cherry picked from commit f31e163)
ararslan pushed a commit that referenced this pull request Sep 13, 2017
Ref #21832
Squashed for backporting
(cherry picked from commit d86b37c)
(cherry picked from commit 7e7393c)
(cherry picked from commit 6a4acc0)
(cherry picked from commit 93cf6d9)
(cherry picked from commit 2379294)
(cherry picked from commit 7ff6322)
(cherry picked from commit 49abbf3)
(cherry picked from commit eadb699)
(cherry picked from commit 1ce1d75)
vtjnash pushed a commit that referenced this pull request Sep 14, 2017
Ref #21832
Squashed for backporting
(cherry picked from commit d86b37c)
(cherry picked from commit 7e7393c)
(cherry picked from commit 6a4acc0)
(cherry picked from commit 93cf6d9)
(cherry picked from commit 2379294)
(cherry picked from commit 7ff6322)
(cherry picked from commit 49abbf3)
(cherry picked from commit eadb699)
(cherry picked from commit 1ce1d75)
ararslan pushed a commit that referenced this pull request Sep 15, 2017
Ref #21832
Squashed for backporting
(cherry picked from commit d86b37c)
(cherry picked from commit 7e7393c)
(cherry picked from commit 6a4acc0)
(cherry picked from commit 93cf6d9)
(cherry picked from commit 2379294)
(cherry picked from commit 7ff6322)
(cherry picked from commit 49abbf3)
(cherry picked from commit eadb699)
(cherry picked from commit 1ce1d75)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:precompilation Precompilation of modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants