Skip to content

Commit

Permalink
move deprecation check outside package caching (dbt-labs#5069)
Browse files Browse the repository at this point in the history
* move deprecation check outside package caching

* add changelog
  • Loading branch information
emmyoop authored and Axel Goblet committed May 20, 2022
1 parent e74224a commit 0bc0cf3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20220414-132206.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Under the Hood
body: Move package deprecation check outside of package cache
time: 2022-04-14T13:22:06.157579-05:00
custom:
Author: emmyoop
Issue: "5068"
PR: "5069"
19 changes: 9 additions & 10 deletions core/dbt/clients/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ def _get(package_name, registry_base_url=None):
fire_event(RegistryResponseExtraNestedKeys(response=response))
raise requests.exceptions.ContentDecodingError(error_msg, response=resp)

return response


_get_cached = memoized(_get_with_retries)


def package(package_name, registry_base_url=None) -> Dict[str, Any]:
# returns a dictionary of metadata for all versions of a package
response = _get_cached(package_name, registry_base_url)
# Either redirectnamespace or redirectname in the JSON response indicate a redirect
# redirectnamespace redirects based on package ownership
# redirectname redirects based on package name
Expand All @@ -107,16 +116,6 @@ def _get(package_name, registry_base_url=None):

new_nwo = use_namespace + "/" + use_name
deprecations.warn("package-redirect", old_name=package_name, new_name=new_nwo)

return response


_get_cached = memoized(_get_with_retries)


def package(package_name, registry_base_url=None) -> Dict[str, Any]:
# returns a dictionary of metadata for all versions of a package
response = _get_cached(package_name, registry_base_url)
return response["versions"]


Expand Down

0 comments on commit 0bc0cf3

Please sign in to comment.