Skip to content

Commit

Permalink
feat(fal): introduce fal machine kill
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Nov 19, 2024
1 parent 0c8034e commit 3bebc1d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
43 changes: 43 additions & 0 deletions projects/fal/src/fal/cli/machine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from .parser import FalClientParser


def _kill(args):
from fal.sdk import FalServerlessClient

client = FalServerlessClient(args.host)
with client.connect() as connection:
connection.kill_runner(args.id)


def _add_kill_parser(subparsers, parents):
kill_help = "Kill a machine."
parser = subparsers.add_parser(
"kill",
description=kill_help,
help=kill_help,
parents=parents,
)
parser.add_argument(
"id",
help="Runner ID.",
)
parser.set_defaults(func=_kill)


def add_parser(main_subparsers, parents):
machine_help = "Manage fal machines."
parser = main_subparsers.add_parser(
"machine",
description=machine_help,
help=machine_help,
parents=parents,
)

subparsers = parser.add_subparsers(
title="Commands",
metavar="command",
required=True,
parser_class=FalClientParser,
)

_add_kill_parser(subparsers, parents)
4 changes: 4 additions & 0 deletions projects/fal/src/fal/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,3 +686,7 @@ def list_secrets(self) -> list[ServerlessSecret]:
)
for secret in response.secrets
]

def kill_runner(self, runner_id: str) -> None:
request = isolate_proto.KillRunnerRequest(runner_id=runner_id)
self.stub.KillRunner(request)

0 comments on commit 3bebc1d

Please sign in to comment.