Skip to content

Commit

Permalink
Fix: run_guest_api mixed str and Path
Browse files Browse the repository at this point in the history
Solution: Accept a `pathlib.Path` as argument and convert as string.
  • Loading branch information
hoh authored and olethanh committed Apr 10, 2024
1 parent d660948 commit e28fcaa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/aleph/vm/guest_api/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import re
from pathlib import Path
from typing import Optional

import aiohttp
Expand Down Expand Up @@ -152,7 +153,7 @@ async def list_keys_from_cache(request: web.Request):


def run_guest_api(
unix_socket_path,
unix_socket_path: Path,
vm_hash: Optional[str] = None,
sentry_dsn: Optional[str] = None,
server_name: Optional[str] = None,
Expand Down Expand Up @@ -195,8 +196,8 @@ def run_guest_api(
app.router.add_route(method="POST", path="/api/v0/p2p/pubsub/pub", handler=repost)

# web.run_app(app=app, port=9000)
web.run_app(app=app, path=unix_socket_path)
web.run_app(app=app, path=str(unix_socket_path))


if __name__ == "__main__":
run_guest_api("/tmp/guest-api", vm_hash="vm")
run_guest_api(Path("/tmp/guest-api"), vm_hash="vm")
6 changes: 4 additions & 2 deletions tests/supervisor/test_execution.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import logging

import pytest
from aleph_message.models import ItemHash
Expand All @@ -20,8 +21,8 @@ async def test_create_execution():
settings.ALLOW_VM_NETWORKING = False
settings.USE_JAILER = False

import logging
logging.basicConfig(level=logging.DEBUG)
settings.PRINT_SYSTEM_LOGS = True

# Ensure that the settings are correct and required files present.
settings.setup()
Expand Down Expand Up @@ -52,4 +53,5 @@ async def test_create_execution():
assert isinstance(vm, AlephFirecrackerProgram)
assert vm.vm_id == 3

await asyncio.wait_for(execution.start(), timeout=30)
await execution.start()
await execution.stop()

0 comments on commit e28fcaa

Please sign in to comment.