-
Notifications
You must be signed in to change notification settings - Fork 76
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
Support Dataverse files without a persistentID #355
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0321a08
Support Dataverse files without a persistentID
santisoler 7ad5073
Don't assume that persistentId is always present
santisoler 1e670cf
Simplify the if statement
santisoler 23d2d02
Merge branch 'main' into dataverse-without-persistentid
santisoler 93d9835
Merge branch 'main' into dataverse-without-persistentid
leouieda 15f7536
Only rely on the file ID, not PID
leouieda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file ID will always be there. It's the primary key in the database.
The persistent ID (DOI or Handle) is optional so you can't rely on it being there. I would simply avoid even checking for it if all you want to do is download the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I thought the
persistentId
is always there, but it's empty if the files doesn't have one. Sorry for the misunderstanding.If that's the case, you're right, we shouldn't assume that
persistentId
will always be there. I'll change theif
statement then.BTW, do you have any example where the
persistentId
is not even included in the response (I'm thinking for testing purposes)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, from a quick test it looks like
persistentId
is always present but can be an empty string. I'll put an example below.I think we're saying the same thing. Always there. Sometimes an empty string. So I'd suggest checking for
id
instead which will always be there and always be a number. I hope this helps! 😄curl -s 'https://dataverse.unc.edu/api/datasets/:persistentId?persistentId=doi:10.15139/S3/TRSZ3X' | jq '.data.latestVersion.files[0]'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great then! The following two lines actually work both with non-existing
persistentId
and ifpersistentId
is an empty string. So I think we could leave them as they are, just in case in the futurepersistentId
is dropped from any Dataverse API.pooch/pooch/downloaders.py
Lines 1049 to 1050 in 1e670cf
My strategy is to check for the
id
only if thepersistentId
is missing. This is due to what I commented above regarding defaulting topersistentId
, being it the first option offered in Dataverse docs.Maybe I'm being too conservative about it... I'm trying to keep the chances of breaking backward compatibility as low as possible, while still supporting the cases where
persistentId
is missing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest changing your strategy to this:
id
Simple! 😄