Skip to content

Commit

Permalink
Fix: VM connector does not start when run locally (#287)
Browse files Browse the repository at this point in the history
* Fix: remove documentation of `use_latest`

Problem: the field does not appear in the VM connector API functions.

* Fix: FastAPI exception when launching the VM connector

Problem: launching the VM connector with `run_vm_connector.sh` yields
an exception because of issues with the return types of the API
endpoints.

Solution: remove `Response` and `StreamingResponse` type hints from
return values as they are not Pydantic models.
  • Loading branch information
odesenfans authored Apr 3, 2023
1 parent 2640562 commit 3f9448c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions vm_connector/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,44 +64,43 @@ async def stream_url_chunks(url):


@app.get("/download/message/{ref}")
async def download_message(ref: str) -> Union[Dict, Response]:
async def download_message(ref: str) -> Dict:
"""
Fetch on Aleph and return a VM function message, after checking its validity.
Used by the VM Supervisor run the code.
:param ref: item_hash of the code file
:param use_latest: should the last amend to the code be used
:return: a file containing the code file
"""

msg = await get_message(hash_=ref)

# TODO: Validate the validity of the message (signature, hashes)
# TODO: Validate the message (signature, hashes)
if not msg:
raise HTTPException(status_code=404, detail="Hash not found")

return msg or Response(status_code=404, content="Hash not found")
return msg


@app.get("/download/code/{ref}")
async def download_code(ref: str) -> Union[StreamingResponse, Response]:
async def download_code(ref: str):
"""
Fetch on Aleph and return a VM code file, after checking its validity.
Used by the VM Supervisor to download function source code.
:param ref: item_hash of the code file
:param use_latest: should the last amend to the code be used
:return: a file containing the code file
"""
return await download_data(ref=ref)


@app.get("/download/data/{ref}")
async def download_data(ref: str) -> Union[StreamingResponse, Response]:
async def download_data(ref: str):
"""
Fetch on Aleph and return a VM data file, after checking its validity.
Used by the VM Supervisor to download state data.
:param ref: item_hash of the data
:param use_latest: should the last amend to the data be used
:return: a file containing the data
"""

Expand All @@ -122,13 +121,12 @@ async def download_data(ref: str) -> Union[StreamingResponse, Response]:


@app.get("/download/runtime/{ref}")
async def download_runtime(ref: str) -> Union[StreamingResponse, Response]:
async def download_runtime(ref: str):
"""
Fetch on Aleph and return a VM runtime, after checking its validity.
Used by the VM Supervisor to download a runtime.
:param ref: item_hash of the runtime
:param use_latest: should the last amend to the runtime be used
:return: a file containing the runtime
"""
return await download_data(ref=ref)
Expand Down

0 comments on commit 3f9448c

Please sign in to comment.