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

Do not use isfile for URLs in checkpath_load #321

Closed
wants to merge 1 commit into from

Conversation

davidanthoff
Copy link
Contributor

Fixes #320. Not sure this is the best solution, but it would still be great if we could merge this quickly and tag a new release, so that the functionality in CSVFiles.jl is no longer broken.

@davidanthoff
Copy link
Contributor Author

@timholy Hm, I don't fully understand what is going on here. The test errors seem to indicate that this package is now somehow integrated with FilePaths.jl? I don't really know how to continue here, but I do know that 1.6 broke things on this aspect of things :) Any ideas how we could resolve this?

@@ -164,7 +164,7 @@ end
function checkpath_load(file)
file === nothing && return nothing # likely stream io
isa(file, IO) && return nothing
!isfile(file) && throw(ArgumentError("No file exists at given path: $file"))
startswith(file, "http://") || startswith(file, "https://") || !isfile(file) && throw(ArgumentError("No file exists at given path: $file"))
Copy link
Member

@johnnychen94 johnnychen94 Apr 10, 2021

Choose a reason for hiding this comment

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

How about using a new helper function?

is_url(path::AbstractString) = startswith(path, "http://") || startswith(path, "https://")
is_url(path) = false

@@ -164,7 +164,7 @@ end
function checkpath_load(file)
file === nothing && return nothing # likely stream io
isa(file, IO) && return nothing
!isfile(file) && throw(ArgumentError("No file exists at given path: $file"))
startswith(file, "http://") || startswith(file, "https://") || !isfile(file) && throw(ArgumentError("No file exists at given path: $file"))
Copy link
Member

Choose a reason for hiding this comment

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

The logic seems a little bit hard to understand. If I understand it correctly, is the following an equivalent version?

Suggested change
startswith(file, "http://") || startswith(file, "https://") || !isfile(file) && throw(ArgumentError("No file exists at given path: $file"))
startswith(file, "http://") || startswith(file, "https://") || isfile(file) || throw(ArgumentError("No file exists at given path: $file"))

@johnnychen94
Copy link
Member

Tests are needed to avoid #320

@davidanthoff
Copy link
Contributor Author

@timholy Bump :) The 1.6 update here broke functionality in CSVFiles.jl that had been working for years, would be good if we could somehow fix that, but I'm stuck, I don't understand what changes were introduced in FileIO.jl that caused this in the first place...

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.

The 1.6 update seems to have broken load from URLs for CSVFiles
2 participants