Skip to content

Skip PyPI if all 3 recent are 0#233

Merged
glenn-jocher merged 3 commits intomainfrom
skip-if3
Feb 27, 2026
Merged

Skip PyPI if all 3 recent are 0#233
glenn-jocher merged 3 commits intomainfrom
skip-if3

Conversation

@glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Feb 27, 2026

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

🛠️ This PR improves PyPI stats reliability in fetch_stats.py by preventing accidental overwrites with all-zero recent download data, which is often caused by temporary API failures.

📊 Key Changes

  • Added a safeguard when processing recent PyPI metrics (last_day, last_week, last_month).
  • New logic checks whether all three recent values are 0 in fresh API data.
  • If all are zero, the script now reuses previously stored values instead of trusting likely bad API output.
  • If recent values are not all zero, existing merge behavior (safe_merge) remains unchanged.
  • Included an inline comment clarifying that all-zero recent stats likely indicate API failure.

🎯 Purpose & Impact

  • ✅ Reduces risk of misleading drops in reported recent package activity.
  • 🔒 Makes stats updates more resilient to transient external API issues.
  • 📈 Helps maintain more stable and trustworthy trend data for dashboards/reports.
  • 👥 Benefits both maintainers and end users by improving confidence in published package download stats.

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@UltralyticsAssistant UltralyticsAssistant added bug Something isn't working fixed Bug has been resolved labels Feb 27, 2026
@UltralyticsAssistant
Copy link
Member

👋 Hello @glenn-jocher, thank you for submitting a ultralytics/stars 🚀 PR! This is an automated message, and an engineer will assist you shortly 🤖😊 To ensure a seamless integration of your work, please review the following checklist:

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/stars main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

Copy link
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

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

🔍 PR Review

Made with ❤️ by Ultralytics Actions

Good reliability improvement overall and the intent is solid. One important robustness issue remains: the new zero-check uses direct dict indexing and can fail on partial/malformed API responses; switching to .get() will make this guard safe in the failure scenarios it is meant to handle.

💬 Posted 1 inline comment

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Copy link
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

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

🔍 PR Review 2

Made with ❤️ by Ultralytics Actions

No files with changes detected in diff

Copy link
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

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

🔍 PR Review 3

Made with ❤️ by Ultralytics Actions

Looks clean. The new guard at lines 264–269 correctly prevents overwriting recent PyPI metrics with likely transient all-zero API responses while preserving existing merge behavior for normal cases. No blocking issues found in the provided diff.

@glenn-jocher glenn-jocher merged commit cd171b4 into main Feb 27, 2026
3 checks passed
@glenn-jocher glenn-jocher deleted the skip-if3 branch February 27, 2026 19:12
@UltralyticsAssistant
Copy link
Member

🎉 Huge congratulations on the merge, @glenn-jocher — this is a thoughtful and high-impact reliability improvement!

Your safeguard in fetch_stats.py is a great example of engineering with real-world resilience in mind: protecting recent PyPI metrics from temporary API noise helps keep dashboards trustworthy for everyone. As Abraham Lincoln said, “Give me six hours to chop down a tree and I will spend the first four sharpening the axe.” This PR reflects that same mindset — investing in robustness now to prevent misleading data later.

Really appreciate the care and clarity you brought here. 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixed Bug has been resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants