-
Notifications
You must be signed in to change notification settings - Fork 324
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
Download_Mode
for File
, S3_File
and Enso_File
#12017
Open
GregoryTravis
wants to merge
19
commits into
develop
Choose a base branch
from
wip/gmt/11411-download-cache
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
2c44654
wip
GregoryTravis 3340832
Merge branch 'develop' into wip/gmt/11411-download-cache
GregoryTravis f49e29c
wip
GregoryTravis 04ebbda
wip
GregoryTravis 4d1db59
Merge branch 'develop' into wip/gmt/11411-download-cache
GregoryTravis 2bfe697
Merge branch 'develop' into wip/gmt/11411-download-cache
GregoryTravis 3daae54
merge
GregoryTravis c8c77b2
Always mode, changed helper to return bool
GregoryTravis b4f5a9c
remove last-modified-time setter
GregoryTravis b0fb99d
wip
GregoryTravis b2ce858
wip
GregoryTravis 85902ad
changelog
GregoryTravis 269b7c4
merge
GregoryTravis 9bb0dc8
wip
GregoryTravis 6e5fca2
wip
GregoryTravis 9c04163
Merge branch 'develop' into wip/gmt/11411-download-cache
GregoryTravis 00e40af
Merge branch 'develop' into wip/gmt/11411-download-cache
GregoryTravis 6bf36ce
Merge branch 'develop' into wip/gmt/11411-download-cache
GregoryTravis af5d144
green for all 3
GregoryTravis 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
8 changes: 8 additions & 0 deletions
8
distribution/lib/Standard/Base/0.0.0-dev/src/Data/Download/Download_Mode.enso
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import project.Data.Time.Duration.Duration | ||
|
||
type Download_Mode | ||
## Download the file if it does not already exist on disk. | ||
If_Npt_Exists | ||
|
||
## Download the file if it is older than the specified age. | ||
If_Older_than age:Duration |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from Standard.Base import all | ||
|
||
from Standard.Test import all | ||
import Standard.Test.Test_Environment | ||
|
||
from enso_dev.Base_Tests.Network.Http.Http_Test_Setup import base_url_with_slash, pending_has_url | ||
|
||
main filter=Nothing = | ||
suite = Test.build suite_builder-> | ||
add_specs suite_builder | ||
suite.run_with_filter filter | ||
|
||
|
||
with_test_file f ~action = | ||
Panic.with_finalizer (f.delete_if_exists) | ||
action f | ||
|
||
add_specs suite_builder = | ||
suite_builder.group "Download Mode" pending=pending_has_url group_builder-> | ||
url_n_bytes n = base_url_with_slash+'test_download?length='+n.to_text | ||
|
||
group_builder.specify "Will download a file if it does not exist" <| | ||
with_test_file (enso_project.data / "transient" / "if_not_exist.txt") file-> | ||
file.exists . should_be_false | ||
Data.download (url_n_bytes 10) file | ||
first_contents = file.read | ||
Data.download (url_n_bytes 11) file | ||
second_contents = file.read | ||
first_contents . should_equal second_contents |
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.
API suggestion: what if we rename
mode
intoreplace_existing
?IMO it will be much clearer for the user.
If I do:
tbh I'd still expect the second expression to download. That is because I am now downloading a different file to that destination. So while the destination exists, as a user I would expect it to be overwritten, because I've changed the URL - e.g. I was working with a report from June relying on the cache to only download it once, but now I want to start working with reports from July. I change the URL and expect the file to get redownloaded even if it exists - because I expect the data is new. I even reset caches and am confused why I'm still seeing June data in the file.
I understand that this is not what this was designed for, but I think the above is a likely user scenario.
Now, if we rename the parameter to
replace_existing
, the code reads as:Now it is obvious to me that the second statement will do nothing if the first one succeeded - because the file is redownloaded only if it didn't exist in the first place (regardless of the URL). And now that semantics (what is currently implemented) is completely clear when reading the calls.
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.
and regardless of parameter name - we need to update the method documentation to include it and ideally describe what the expected semantics is.
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.
Given that we rely on the 'refresh' button to clear caches in many cases, we probably should add a note that this
download
method works only based on file existance/age and so refresh button does not affect it.As a user I might expect the refresh button to ensure the file is redownloaded (whether that should work this way or not is up to discussion, I think current semantics are ok) - but with current semantics the refresh button just does nothing for
download
. I think it would be good if the documentation mentioned that, so that the user can know what to expect / can see that this is expected and not a bug if they get confused seeing that refresh button does nothing.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.
Renamed to
replace_existing
, and added documentation.I am not sure about how the refresh button interacts with the
Always
option, and I cannot run the front end to find out, so I did not mention that.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.
With
Always
we always redownload the file, right? How could the refresh button interfere with that?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.
What I mean is, I assume that refresh will also cause a download.