Skip to content

Conversation

1yam
Copy link
Member

@1yam 1yam commented Sep 1, 2025

Explain what problem this PR is resolving

Related ClickUp, GitHub or Jira tickets : ALEPH-541

Self proofreading checklist

  • The new code clear, easy to read and well commented.
  • New code does not duplicate the functions of builtin or popular libraries.
  • An LLM was used to review the new code and look for simplifications.
  • New classes and functions contain docstrings explaining what they provide.
  • All new code is covered by relevant tests.

Documentation

Not available yet

Changes

This pull request refactors and modernizes the instance creation flow in the Aleph client, focusing on improved GPU and CRN selection, pricing integration, and code maintainability. The changes transition from legacy list-based CRN handling to a more object-oriented approach, streamline pricing/tier selection, and ensure more robust validation and user feedback. The most important updates are grouped below.

CRN and GPU Selection Refactor:

  • Replaced legacy CRN list handling and GPU selection with the new NetworkGPUS, CRN, and CRNInfo models, enabling more reliable filtering, selection, and display of node and GPU information. All CRN-related logic now uses these models for validation and user prompts. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Pricing and Tier Selection Overhaul:

  • Updated pricing logic to use fetch_pricing_aggregate and the new Price and tier selection methods, with improved eligibility filtering for GPU and confidential tiers, and more robust user prompts when no eligible tiers are available. [1] [2]

Payment and Funds Validation Improvements:

  • Refactored payment validation to use compute unit prices from the new pricing model, ensuring accurate calculation for both pay-as-you-go and holding payment types, with clearer user feedback on insufficient funds or missing price data.

Async CRN List Fetching and Usage:

  • Optimized CRN list fetching by starting the request early and awaiting only when needed, reducing wait times and improving responsiveness during instance creation.

Codebase Cleanup and Import Updates:

  • Removed unused imports and legacy functions, updated imports to reflect new model usage, and ensured all references to CRN and GPU info are consistent across files. [1] [2] [3]

These changes collectively modernize the codebase, improve user experience, and lay the groundwork for future extensibility.

How to test

To test the feature:

  • aleph instance create
  • aleph program create
  • aleph pricing all
  • aleph pricing gpu --with-current-availability

Print screen / video

image

Notes

This PR simplify some of the logic to have more maintenable code and prepare for crédits feature

Copy link

codecov bot commented Sep 1, 2025

Codecov Report

❌ Patch coverage is 64.61538% with 92 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.31%. Comparing base (30375f1) to head (e210838).

Files with missing lines Patch % Lines
src/aleph_client/commands/instance/__init__.py 39.75% 33 Missing and 17 partials ⚠️
src/aleph_client/commands/pricing.py 80.13% 19 Missing and 11 partials ⚠️
src/aleph_client/commands/program.py 50.00% 5 Missing and 1 partial ⚠️
src/aleph_client/commands/instance/network.py 55.55% 4 Missing ⚠️
src/aleph_client/commands/instance/display.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
- Coverage   60.81%   60.31%   -0.50%     
==========================================
  Files          20       20              
  Lines        3718     3757      +39     
  Branches      524      534      +10     
==========================================
+ Hits         2261     2266       +5     
- Misses       1192     1219      +27     
- Partials      265      272       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@nesitor nesitor left a comment

Choose a reason for hiding this comment

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

LGTM

@1yam 1yam force-pushed the 1yam-pricing-refactor branch from 62f238f to e210838 Compare September 16, 2025 09:46
@1yam 1yam mentioned this pull request Sep 16, 2025
5 tasks
@aleph-im aleph-im deleted a comment from github-actions bot Sep 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants