Fix: Hold Restrictions #356
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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
:typer
for handling exit codes in tests.create_mock_vm_coco_client
function to include ashould_raise
parameter to test the new payment type conditions. [1] [2] [3] [4] [5] [6] [7] [8]test_create_instance
function to handle theshould_raise
parameter and assert the correct exit code when the new conditions are met.How to test
Create
Instance / Program
with more than4 compute unit
or/andconfidential
type.Print screen / video
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.