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 download fail immediately on nonexistent resources #820

Merged
merged 5 commits into from
Oct 28, 2021
Merged

Conversation

jwodder
Copy link
Member

@jwodder jwodder commented Oct 28, 2021

Closes #817.

@jwodder jwodder added the patch Increment the patch version when merged label Oct 28, 2021
@codecov
Copy link

codecov bot commented Oct 28, 2021

Codecov Report

Merging #820 (eca1fe3) into master (1620fcd) will increase coverage by 0.26%.
The diff coverage is 98.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #820      +/-   ##
==========================================
+ Coverage   85.00%   85.26%   +0.26%     
==========================================
  Files          61       61              
  Lines        6201     6293      +92     
==========================================
+ Hits         5271     5366      +95     
+ Misses        930      927       -3     
Flag Coverage Δ
unittests 85.26% <98.33%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dandi/dandiarchive.py 86.34% <94.11%> (+2.50%) ⬆️
dandi/download.py 83.33% <100.00%> (ø)
dandi/tests/test_dandiarchive.py 100.00% <100.00%> (ø)
dandi/support/generatorify.py 0.00% <0.00%> (-16.10%) ⬇️
dandi/dandiapi.py 89.00% <0.00%> (+2.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1620fcd...eca1fe3. Read the comment docs.

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

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

may be we could reduce duplication?

dandi/dandiarchive.py Outdated Show resolved Hide resolved
if strict:
raise
else:
return
Copy link
Member

Choose a reason for hiding this comment

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

that's lot of the same use pattern, I didn't realize it would need to be represented in so many places

I wonder if to reduce at least some code duplication could we have smth like

@contextmanager
def maybe_strict(strict: bool):
      try:
          yield
      except NotFoundError:
          if strict:
              raise

and then here (and elsehwere) have smth like

with maybe_strict(strict):
    yield self.get_dandiset(client).get_asset(self.asset_id)

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

jwodder and others added 2 commits October 28, 2021 14:17
Co-authored-by: Yaroslav Halchenko <debian@onerussian.com>
else:
return None

def get_version_id(self, client: DandiAPIClient) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

just noticed that backward incompatible change is introduced -- we aren't using this one anywhere yet?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, we're not using that method anywhere. Since the logic in this method is already used by RemoteDandiset to determine its default version, get_version_id() was redundant.

Copy link
Member

Choose a reason for hiding this comment

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

and may be we better mark it as minor not as patch ?

Copy link
Member Author

Choose a reason for hiding this comment

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

The method was never intended to be called by anything other than other methods in the same class hierarchy (and thus it shouldn't have been called by users of dandi-cli). I seriously doubt anyone ever used it.

Copy link
Member

Choose a reason for hiding this comment

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

ok, let's proceed then

@yarikoptic yarikoptic merged commit c28a4f0 into master Oct 28, 2021
@yarikoptic yarikoptic deleted the gh-817 branch October 28, 2021 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

we are silently failing to download a non-existing asset
2 participants