Skip to content

Commit

Permalink
Fix: Applied some code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
nesitor committed Dec 9, 2024
1 parent b06594c commit 70b7390
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packaging/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ debian-package-code:
cp -r ../examples/data ./aleph-vm/opt/aleph-vm/examples/data
mkdir -p ./aleph-vm/opt/aleph-vm/examples/volumes
# Fixing this protobuf dependency version to avoid getting CI errors as version 5.29.0 have this compilation issue
pip3 install --progress-bar off --target ./aleph-vm/opt/aleph-vm/ 'aleph-message@git+https://github.com/aleph-im/aleph-message@andres-feature-add_gpu_requirement' 'eth-account==0.10' 'sentry-sdk==1.31.0' 'qmp==1.1.0' 'aleph-superfluid~=0.2.1' 'sqlalchemy[asyncio]>=2.0' 'aiosqlite==0.19.0' 'alembic==1.13.1' 'aiohttp_cors==0.7.0' 'pyroute2==0.7.12' 'python-cpuid==0.1.0' 'solathon==1.0.2' 'protobuf==5.28.3'
pip3 install --progress-bar off --target ./aleph-vm/opt/aleph-vm/ 'aleph-message==0.6' 'eth-account==0.10' 'sentry-sdk==1.31.0' 'qmp==1.1.0' 'aleph-superfluid~=0.2.1' 'sqlalchemy[asyncio]>=2.0' 'aiosqlite==0.19.0' 'alembic==1.13.1' 'aiohttp_cors==0.7.0' 'pyroute2==0.7.12' 'python-cpuid==0.1.0' 'solathon==1.0.2' 'protobuf==5.28.3'
python3 -m compileall ./aleph-vm/opt/aleph-vm/

debian-package-resources: firecracker-bins vmlinux download-ipfs-kubo target/bin/sevctl
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies = [
"aioredis==1.3.1",
"aiosqlite==0.19",
"alembic==1.13.1",
"aleph-message @ git+https://github.com/aleph-im/aleph-message@andres-feature-add_gpu_requirement",
"aleph-message==0.6",
"aleph-superfluid~=0.2.1",
"dbus-python==1.3.2",
"eth-account~=0.10",
Expand Down
10 changes: 5 additions & 5 deletions src/aleph/vm/hypervisors/qemu/qemuvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ async def start(
# Tell to put the output to std fd, so we can include them in the log
"-serial",
"stdio",
# Use host-phys-bits-limit argument for GPU support. TODO: Investigate how to get the correct bits size
#
"-cpu",
"host,host-phys-bits-limit=0x28",
# Uncomment for debug
# "-serial", "telnet:localhost:4321,server,nowait",
# "-snapshot", # Do not save anything to disk
Expand Down Expand Up @@ -145,7 +141,11 @@ def _get_host_volumes_args(self):
return args

def _get_gpu_args(self):
args = []
args = [
# Use host-phys-bits-limit argument for GPU support. TODO: Investigate how to get the correct bits size
"-cpu",
"host,host-phys-bits-limit=0x28",
]
for gpu in self.gpus:
args += [

Check warning on line 150 in src/aleph/vm/hypervisors/qemu/qemuvm.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/hypervisors/qemu/qemuvm.py#L150

Added line #L150 was not covered by tests
"-device",
Expand Down
6 changes: 5 additions & 1 deletion src/aleph/vm/orchestrator/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ def check_tokens(cls, values):
}


class InvalidChainError(ValueError):
pass


def get_chain(chain: str) -> ChainInfo:
try:
return STREAM_CHAINS[chain]
except KeyError:
msg = f"Unknown chain id for chain {chain}"
raise ValueError(msg)
raise InvalidChainError(msg)

Check warning on line 72 in src/aleph/vm/orchestrator/chain.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/chain.py#L72

Added line #L72 was not covered by tests
16 changes: 4 additions & 12 deletions src/aleph/vm/orchestrator/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from aleph.vm.models import VmExecution
from aleph.vm.utils import to_normalized_address

from .chain import ChainInfo, get_chain
from .chain import ChainInfo, InvalidChainError, get_chain

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -91,22 +91,14 @@ class InvalidAddressError(ValueError):
pass


class InvalidChainError(ValueError):
pass


async def get_stream(sender: str, receiver: str, chain: str) -> Decimal:
"""
Get the stream of the user from the Superfluid API.
See https://community.aleph.im/t/pay-as-you-go-using-superfluid/98/11
"""
try:
chain_info: ChainInfo = get_chain(chain=chain)
if not chain_info.active:
msg = f"Chain : {chain} is not active for superfluid"
raise InvalidChainError(msg)
except ValueError:
msg = f"Chain : {chain} is invalid"
chain_info: ChainInfo = get_chain(chain=chain)
if not chain_info.active:
msg = f"Chain : {chain} is not active for superfluid"
raise InvalidChainError(msg)

superfluid_instance = CFA_V1(chain_info.rpc, chain_info.chain_id)
Expand Down
2 changes: 1 addition & 1 deletion src/aleph/vm/orchestrator/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ async def monitor_payments(app: web.Application):
)
except ValueError as error:
logger.error(f"Error found getting stream for chain {chain} and sender {sender}: {error}")
stream = Decimal(0)
continue

Check warning on line 186 in src/aleph/vm/orchestrator/tasks.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/tasks.py#L184-L186

Added lines #L184 - L186 were not covered by tests

required_stream = await compute_required_flow(executions)
logger.debug(f"Required stream for Sender {sender} executions: {required_stream}")
Expand Down

0 comments on commit 70b7390

Please sign in to comment.