Skip to content

Conversation

@philogicae
Copy link
Member

@philogicae philogicae commented Dec 4, 2024

Jira task: ALEPH-231

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.
  • Update docs

Changes

Instances

  • Add 10sec delay in aleph instance confidential cmd to ensure VM is starting
  • Fix payment args and fallback when wrong chain selected for hold/payg
  • Remove deprecated aleph instance erase and aleph instance expire
  • Improve aleph instance create and network.py inner logic
  • Improve commands UX

Programs

  • Update UX (same as instances)
  • Add create alias for aleph program upload
  • Add missing aleph program delete , aleph program list and aleph program persist
  • Add runtime checker program and useful command: aleph program runtime-checker

Pytest (To fix bad coverage) on Aleph testnet

  • Add all mock tests for instance general cmds
  • Add all mock tests for instance coco cmds
  • Add all mock tests for programs cmds

Others

  • Add missing try/catch to handle exceptions
  • Improve aleph account balance
  • Improve aleph node compute

Screenshots

Instances

aleph instance create

image

aleph instance list

image

Programs

aleph program upload (or create)

image

aleph program update

image

aleph program delete

image

aleph program list

image

aleph program persist/unpersist

image

aleph program runtime-checker

image

@philogicae philogicae self-assigned this Dec 4, 2024
@philogicae philogicae changed the title Fix: Various improvements to latest features / UX Fix: Various improvements related to latest features / UX Dec 4, 2024
@philogicae philogicae changed the title Fix: Various improvements related to latest features / UX Fix: Various improvements (UX, edge cases, coverage) Dec 4, 2024
@philogicae philogicae force-pushed the fix-various-improvements branch from a98a437 to 81fda98 Compare December 11, 2024 12:14
@codecov
Copy link

codecov bot commented Dec 11, 2024

Codecov Report

Attention: Patch coverage is 55.44715% with 274 lines in your changes missing coverage. Please review.

Project coverage is 54.32%. Comparing base (e2cc0b4) to head (e6714ea).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/aleph_client/commands/program.py 56.81% 86 Missing and 28 partials ⚠️
src/aleph_client/commands/instance/__init__.py 60.89% 46 Missing and 15 partials ⚠️
src/aleph_client/commands/message.py 11.76% 43 Missing and 2 partials ⚠️
src/aleph_client/commands/utils.py 25.92% 19 Missing and 1 partial ⚠️
src/aleph_client/commands/node.py 22.22% 14 Missing ⚠️
src/aleph_client/commands/instance/network.py 62.85% 9 Missing and 4 partials ⚠️
src/aleph_client/commands/account.py 66.66% 3 Missing and 1 partial ⚠️
src/aleph_client/commands/files.py 85.71% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #312       +/-   ##
===========================================
+ Coverage   39.94%   54.32%   +14.37%     
===========================================
  Files          18       18               
  Lines        2203     2544      +341     
  Branches      271      318       +47     
===========================================
+ Hits          880     1382      +502     
+ Misses       1266     1000      -266     
- Partials       57      162      +105     

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

@philogicae philogicae force-pushed the fix-various-improvements branch 2 times, most recently from 1255b3e to d06f60a Compare December 13, 2024 18:56
@philogicae philogicae force-pushed the fix-various-improvements branch 4 times, most recently from 20f4359 to 0d436ca Compare December 18, 2024 11:04
@philogicae philogicae marked this pull request as ready for review December 18, 2024 11:17
@github-actions
Copy link

Failed to retrieve llama text: POST 502: VM did not respond and was shut down

@philogicae philogicae force-pushed the fix-various-improvements branch 5 times, most recently from f0e145c to 1143f0c Compare December 19, 2024 11:29
@olethanh
Copy link
Contributor

found a bug, just did aleph instance create then enter.

Which payment type do you want to use? [hold/superfluid/nft] (superfluid): 
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ /home/olivier/Projects/aleph/aleph-client/src/aleph_client/utils.py:78 in runner                                                                                                                                                                                                                                                                                                                                                  │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│    75 │   │   │                                                                                ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── locals ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮                                         │
│    76 │   │   │   @wraps(f)                                                                    │   args = ()                                                                                                                                                                                                                                                                            │                                         │
│    77 │   │   │   def runner(*args, **kwargs):                                                 │ kwargs = {'payment_type': None, 'payment_chain': None, 'hypervisor': <HypervisorType.qemu: 'qemu'>, 'name': None, 'rootfs': None, 'rootfs_size': None, 'vcpus': None, 'memory': None, 'timeout_seconds': 30.0, 'ssh_pubkey_file': PosixPath('/home/olivier/.ssh/id_rsa.pub'), ... +15} │                                         │
│ ❱  78 │   │   │   │   return asyncio.run(f(*args, **kwargs))                                   ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                         │
│    79 │   │   │                                                                                                                                                                                                                                                                                                                                                                                                                   │
│    80 │   │   │   decorator(runner)                                                                                                                                                                                                                                                                                                                                                                                               │
│    81 │   │   else:                                                                                                                                                                                                                                                                                                                                                                                                               │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│ /usr/lib/python3.12/asyncio/runners.py:194 in run                                                                                                                                                                                                                                                                                                                                                                                 │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│   191 │   │   │   "asyncio.run() cannot be called from a running event loop")                  ╭───────────────────────────── locals ─────────────────────────────╮                                                                                                                                                                                                                                                               │
│   192 │                                                                                        │        debug = None                                              │                                                                                                                                                                                                                                                               │
│   193 │   with Runner(debug=debug, loop_factory=loop_factory) as runner:                       │ loop_factory = None                                              │                                                                                                                                                                                                                                                               │
│ ❱ 194 │   │   return runner.run(main)                                                          │         main = <coroutine object create at 0x3abd420>            │                                                                                                                                                                                                                                                               │
│   195                                                                                          │       runner = <asyncio.runners.Runner object at 0x7ef80a15b230> │                                                                                                                                                                                                                                                               │
│   196                                                                                          ╰──────────────────────────────────────────────────────────────────╯                                                                                                                                                                                                                                                               │
│   197 def _cancel_all_tasks(loop):                                                                                                                                                                                                                                                                                                                                                                                                │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│ /usr/lib/python3.12/asyncio/runners.py:118 in run                                                                                                                                                                                                                                                                                                                                                                                 │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│   115 │   │                                                                                                                                                                                                                                                                                                                                                                                                                       │
│   116 │   │   self._interrupt_count = 0                                                                                                                                                                                                                                                                                                                                                                                           │
│   117 │   │   try:                                                                                                                                                                                                                                                                                                                                                                                                                │
│ ❱ 118 │   │   │   return self._loop.run_until_complete(task)                                                                                                                                                                                                                                                                                                                                                                      │
│   119 │   │   except exceptions.CancelledError:                                                                                                                                                                                                                                                                                                                                                                                   │
│   120 │   │   │   if self._interrupt_count > 0:                                                                                                                                                                                                                                                                                                                                                                                   │
│   121 │   │   │   │   uncancel = getattr(task, "uncancel", None)                                                                                                                                                                                                                                                                                                                                                                  │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── locals ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮                                                             │
│ │        context = <_contextvars.Context object at 0x7ef80b64d040>                                                                                                                                                                                                                                                                                                  │                                                             │
│ │           coro = <coroutine object create at 0x3abd420>                                                                                                                                                                                                                                                                                                           │                                                             │
│ │           self = <asyncio.runners.Runner object at 0x7ef80a15b230>                                                                                                                                                                                                                                                                                                │                                                             │
│ │ sigint_handler = functools.partial(<bound method Runner._on_sigint of <asyncio.runners.Runner object at 0x7ef80a15b230>>, main_task=<Task finished name='Task-1' coro=<create() done, defined at /home/olivier/Projects/aleph/aleph-client/src/aleph_client/commands/instance/__init__.py:82> exception=AttributeError("'str' object has no attribute 'value'")>) │                                                             │
│ │           task = <Task finished name='Task-1' coro=<create() done, defined at /home/olivier/Projects/aleph/aleph-client/src/aleph_client/commands/instance/__init__.py:82> exception=AttributeError("'str' object has no attribute 'value'")>                                                                                                                     │                                                             │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                             │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│ /usr/lib/python3.12/asyncio/base_events.py:687 in run_until_complete                                                                                                                                                                                                                                                                                                                                                              │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│    684 │   │   if not future.done():                                                            ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────── locals ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮                                                                                       │
│    685 │   │   │   raise RuntimeError('Event loop stopped before Future completed.')            │   future = <Task finished name='Task-1' coro=<create() done, defined at /home/olivier/Projects/aleph/aleph-client/src/aleph_client/commands/instance/__init__.py:82> exception=AttributeError("'str' object has no attribute 'value'")> │                                                                                       │
│    686 │   │                                                                                    │ new_task = False                                                                                                                                                                                                                        │                                                                                       │
│ ❱  687 │   │   return future.result()                                                           │     self = <_UnixSelectorEventLoop running=False closed=True debug=False>                                                                                                                                                               │                                                                                       │
│    688 │                                                                                        ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                                       │
│    689 │   def stop(self):                                                                                                                                                                                                                                                                                                                                                                                                        │
│    690 │   │   """Stop running the event loop.                                                                                                                                                                                                                                                                                                                                                                                    │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│ /home/olivier/Projects/aleph/aleph-client/src/aleph_client/commands/instance/__init__.py:181 in create                                                                                                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                                                                                                                                                                                                   │
│    178 │   if is_stream:                                                                        ╭────────────────────────────────────────────────────────── locals ───────────────────────────────────────────────────────────╮                                                                                                                                                                                                   │
│    179 │   │   if payment_chain is None or payment_chain not in super_token_chains:             │               channel = 'ALEPH-CLOUDSOLUTIONS'                                                                              │                                                                                                                                                                                                   │
│    180 │   │   │   if payment_chain:                                                            │          confidential = False                                                                                               │                                                                                                                                                                                                   │
│ ❱  181 │   │   │   │   console.print(f"[red]{payment_chain.value}[/red] incompatible with Pay-A │ confidential_firmware = 'ba5bb13f3abca960b101a759be162b229e2b7e93ecad9d1307e54de887f177ff'                                  │                                                                                                                                                                                                   │
│    182 │   │   │   payment_chain = Chain(                                                       │                config = MainConfiguration(path=PosixPath('/home/olivier/.aleph-im/private-keys/ethereum.key'), chain='ETH') │                                                                                                                                                                                                   │
│    183 │   │   │   │   Prompt.ask(                                                              │               console = <console width=421 ColorSystem.TRUECOLOR>                                                           │                                                                                                                                                                                                   │
│    184 │   │   │   │   │   "Which chain do you want to use for Pay-As-You-Go?",                 │              crn_hash = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │               crn_url = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │                 debug = False                                                                                               │                                                                                                                                                                                                   │
│                                                                                                 │      ephemeral_volume = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │                   gpu = False                                                                                               │                                                                                                                                                                                                   │
│                                                                                                 │           hold_chains = [<Chain.AVAX: 'AVAX'>, <Chain.BASE: 'BASE'>, <Chain.ETH: 'ETH'>, 'SOL']                             │                                                                                                                                                                                                   │
│                                                                                                 │            hypervisor = <HypervisorType.qemu: 'qemu'>                                                                       │                                                                                                                                                                                                   │
│                                                                                                 │      immutable_volume = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │             is_stream = True                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │                memory = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │                  name = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │         payment_chain = 'ETH'                                                                                               │                                                                                                                                                                                                   │
│                                                                                                 │          payment_type = <PaymentType.superfluid: 'superfluid'>                                                              │                                                                                                                                                                                                   │
│                                                                                                 │     persistent_volume = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │         print_message = False                                                                                               │                                                                                                                                                                                                   │
│                                                                                                 │           private_key = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │      private_key_file = PosixPath('/home/olivier/.aleph-im/private-keys/ethereum.key')                                      │                                                                                                                                                                                                   │
│                                                                                                 │                rootfs = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │           rootfs_size = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │           skip_volume = False                                                                                               │                                                                                                                                                                                                   │
│                                                                                                 │            ssh_pubkey = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDj95BHGUx0/z2G/tTrEi8o49i70xvjcEUdSs3j4A33'+315              │                                                                                                                                                                                                   │
│                                                                                                 │       ssh_pubkey_file = PosixPath('/home/olivier/.ssh/id_rsa.pub')                                                          │                                                                                                                                                                                                   │
│                                                                                                 │    super_token_chains = [<Chain.AVAX: 'AVAX'>, <Chain.BASE: 'BASE'>]                                                        │                                                                                                                                                                                                   │
│                                                                                                 │       timeout_seconds = 30.0                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │                 vcpus = None                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 │               verbose = True                                                                                                │                                                                                                                                                                                                   │
│                                                                                                 ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                                                                                                                                                                                   │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: 'str' object has no attribute 'value'

@philogicae philogicae force-pushed the fix-various-improvements branch from 1143f0c to 6ddffba Compare December 21, 2024 22:11
@philogicae philogicae force-pushed the fix-various-improvements branch 2 times, most recently from eeb6f5b to 2711740 Compare January 8, 2025 13:19
@philogicae philogicae force-pushed the fix-various-improvements branch from ed6925e to 65e839b Compare January 9, 2025 11:45
Copy link
Member

@1yam 1yam left a comment

Choose a reason for hiding this comment

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

LGTM

@philogicae philogicae merged commit 6e4e385 into master Jan 20, 2025
16 checks passed
@philogicae philogicae deleted the fix-various-improvements branch January 20, 2025 10:06
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.

4 participants