Skip to content

Commit

Permalink
Fix: Write file in sync mode to avoid adding a new dependency. Files …
Browse files Browse the repository at this point in the history
…to write should be so small, so any blocking issue should be here.
  • Loading branch information
nesitor committed Jun 5, 2024
1 parent e37ba59 commit 8fc195c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/aleph/vm/orchestrator/views/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from aleph_message.exceptions import UnknownHashError
from aleph_message.models import ItemHash
from aleph_message.models.execution import BaseExecutableContent
from anyio import asyncPath

from aleph.vm.conf import settings
from aleph.vm.models import VmExecution
Expand Down Expand Up @@ -165,15 +164,17 @@ async def operate_start(request: web.Request, authenticated_sender: str) -> web.
if session_file_content:
return web.Response(status=403, body=f"Session file required for VM with ref {vm_hash}")

Check warning on line 165 in src/aleph/vm/orchestrator/views/operator.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/views/operator.py#L165

Added line #L165 was not covered by tests

session_file_path = asyncPath(vm_session_path / "vm_session.b64")
await session_file_path.write_bytes(session_file_content.file.read())
session_file_path = vm_session_path / "vm_session.b64"

Check warning on line 167 in src/aleph/vm/orchestrator/views/operator.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/views/operator.py#L167

Added line #L167 was not covered by tests
with open(session_file_path, "wb") as session_file:
session_file.write(session_file_content.file.read())

Check warning on line 169 in src/aleph/vm/orchestrator/views/operator.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/views/operator.py#L169

Added line #L169 was not covered by tests

godh_file_content = post.get("godh")

Check warning on line 171 in src/aleph/vm/orchestrator/views/operator.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/views/operator.py#L171

Added line #L171 was not covered by tests
if godh_file_content:
return web.Response(status=403, body=f"GODH file required for VM with ref {vm_hash}")

Check warning on line 173 in src/aleph/vm/orchestrator/views/operator.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/views/operator.py#L173

Added line #L173 was not covered by tests

godh_file_path = asyncPath(vm_session_path / "vm_godh.b64")
await godh_file_path.write_bytes(godh_file_content.file.read())
godh_file_path = vm_session_path / "vm_godh.b64"

Check warning on line 175 in src/aleph/vm/orchestrator/views/operator.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/views/operator.py#L175

Added line #L175 was not covered by tests
with open(godh_file_path, "wb") as godh_file:
godh_file.write(godh_file_content.file.read())

Check warning on line 177 in src/aleph/vm/orchestrator/views/operator.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/views/operator.py#L177

Added line #L177 was not covered by tests

pool.systemd_manager.enable_and_start(execution.controller_service)

Check warning on line 179 in src/aleph/vm/orchestrator/views/operator.py

View check run for this annotation

Codecov / codecov/patch

src/aleph/vm/orchestrator/views/operator.py#L179

Added line #L179 was not covered by tests

Expand Down

0 comments on commit 8fc195c

Please sign in to comment.