Skip to content

Commit

Permalink
Fix to handle regression test when package is missing on PyPI (#10180)
Browse files Browse the repository at this point in the history
* Add exception handling to handle when package is missing on PyPI
  • Loading branch information
praveenkuttappan committed Mar 9, 2020
1 parent 495c617 commit 74650bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 5 additions & 1 deletion scripts/devops_tasks/common_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,11 @@ def filter_dev_requirements(pkg_root_path, packages_to_exclude, dest_dir):
def is_required_version_on_pypi(package_name, spec):
from pypi_tools.pypi import PyPIClient
client = PyPIClient()
versions = [str(v) for v in client.get_ordered_versions(package_name) if str(v) in spec]
versions = []
try:
versions = [str(v) for v in client.get_ordered_versions(package_name) if str(v) in spec]
except:
logging.error("Package {} is not found on PyPI", package_name)
return versions

def find_packages_missing_on_pypi(path):
Expand Down
11 changes: 8 additions & 3 deletions scripts/devops_tasks/git_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,20 @@ def get_release_tag(dep_pkg_name, isLatest):
from pypi_tools.pypi import PyPIClient

client = PyPIClient()
versions = [str(v) for v in client.get_ordered_versions(dep_pkg_name)]
logging.info("Versions for {0} is: {1}".format(dep_pkg_name, versions))
versions = []
try:
versions = [str(v) for v in client.get_ordered_versions(dep_pkg_name)]
logging.info("Versions available on PyPI for {0} are: {1}".format(dep_pkg_name, versions))
except:
logging.error("Package {} is not available on PyPI".format(dep_pkg_name))
return None

# filter excluded versions
if dep_pkg_name in EXCLUDED_PACKAGE_VERSIONS:
versions = [v for v in versions if v not in EXCLUDED_PACKAGE_VERSIONS[dep_pkg_name]]
logging.info("Filtered versions for {0} is: {1}".format(dep_pkg_name, versions))

if len(versions) == 0:
if not versions:
logging.info(
"Released version info for package {} is not available".format(dep_pkg_name)
)
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-core/dev_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ typing_extensions>=3.7.2
opencensus>=0.6.0
opencensus-ext-azure>=0.3.1
opencensus-ext-threading
mock
mock

0 comments on commit 74650bc

Please sign in to comment.