Skip to content

Fix: Hold Restrictions #356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Fix: Hold Restrictions #356

wants to merge 7 commits into from

Conversation

1yam
Copy link
Member

@1yam 1yam commented Mar 25, 2025

This PR adds a check to prevent users from creating a Hold (conf + > 4 compute units).
On the instance side, we attempt to fall back to a compatible chain when possible.
If fallback is not possible or program, we exit.

Related ClickUp, GitHub or Jira tickets : ALEPH-458

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.

Changes

This pull request introduces several changes to the aleph_client project, focusing on handling payment types for instances and programs, and updating unit tests to reflect these changes. The most important changes include adding conditions for payment types based on compute units and confidentiality, and updating the unit tests to handle the new logic.

Payment Type Handling:

  • src/aleph_client/commands/instance/__init__.py: Added a condition to switch payment type to PAYG (superfluid) if the compute units exceed 4 or if the instance is confidential, and the payment type is HOLD. If the current chain is not compatible with PAYG, the instance creation is aborted.
  • src/aleph_client/commands/program.py: Added a condition to prevent programs using more than 4 compute units from using the HOLD payment type, as PAYG is required but not yet available.

Pricing Display:

  • src/aleph_client/commands/pricing.py: Updated the pricing display logic to show "Not Available" for confidential instances or instances with more than 4 compute units when the payment type is HOLD.

Unit Tests:

  • tests/unit/test_instance.py:
    • Imported typer for handling exit codes in tests.
    • Modified the create_mock_vm_coco_client function to include a should_raise parameter to test the new payment type conditions. [1] [2] [3] [4] [5] [6] [7] [8]
    • Updated the test_create_instance function to handle the should_raise parameter and assert the correct exit code when the new conditions are met.

How to test

Create Instance / Program with more than 4 compute unit or/and confidential type.

Print screen / video

Hold_high_tier_reject
conf_and_switch
ProgramReject

Notes

It might be worth considering a refactor to move most of the logic to the SDK side. For example, in the price feature, 100% of the logic is currently in aleph-client, which could be painful for developers.

Copy link

codecov bot commented Mar 25, 2025

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes missing coverage. Please review.

Project coverage is 61.25%. Comparing base (671ea0e) to head (a43aa33).

Files with missing lines Patch % Lines
src/aleph_client/commands/instance/__init__.py 62.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #356      +/-   ##
==========================================
- Coverage   61.32%   61.25%   -0.07%     
==========================================
  Files          18       18              
  Lines        3206     3216      +10     
  Branches      452      455       +3     
==========================================
+ Hits         1966     1970       +4     
- Misses       1001     1004       +3     
- Partials      239      242       +3     

☔ 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.

@aleph-im aleph-im deleted a comment from github-actions bot Mar 25, 2025
@1yam 1yam force-pushed the 1yam-hold-restrictions branch from e44f997 to a43aa33 Compare April 29, 2025 12:55
@1yam 1yam requested a review from nesitor April 29, 2025 12:56
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