Skip to content

Commit ec5c2bb

Browse files
author
Ruinong Tian
committed
Handle condastats overall method exception
1 parent b4ed0fc commit ec5c2bb

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/package_report.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,20 @@ def _generate_staleness_report_per_image(
7373
# Use previous month to get full month of data
7474
previous_month = (datetime.now() - relativedelta(months=1)).strftime("%Y-%m")
7575
pkg_list = list(package_versions_in_upstream.keys())
76-
# Suppress FutureWarning from pandas so it doesn't show in report
77-
with warnings.catch_warnings():
78-
warnings.filterwarnings("ignore", category=FutureWarning)
79-
conda_download_stats = overall(pkg_list, month=previous_month)
76+
77+
# Process packages individually to handle exceptions per package
78+
conda_download_stats = {}
79+
for pkg in pkg_list:
80+
try:
81+
# Suppress FutureWarning from pandas so it doesn't show in report
82+
with warnings.catch_warnings():
83+
warnings.filterwarnings("ignore", category=FutureWarning)
84+
# Get stats for single package
85+
pkg_stats = overall([pkg], month=previous_month)
86+
conda_download_stats[pkg] = pkg_stats.get(pkg, "N/A")
87+
except ValueError as e:
88+
print(f"Warning: Unable to fetch download statistics for {pkg}: {str(e)}")
89+
conda_download_stats[pkg] = "N/A"
8090

8191
for package in package_versions_in_upstream:
8292
version_in_sagemaker_distribution = str(target_packages_match_spec_out[package].get("version")).removeprefix(

0 commit comments

Comments
 (0)