-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from pathlib import Path | ||
|
||
import click | ||
import requests | ||
from requests import ConnectionError | ||
|
||
|
||
@click.command() | ||
@click.argument('pipeline_name') | ||
def undeploy(pipeline_name): | ||
try: | ||
resp = requests.post(f"http://localhost:1416/undeploy/{pipeline_name}") | ||
|
||
if resp.status_code >= 400: | ||
click.echo(f"Cannot undeploy pipeline: {resp.json().get('detail')}") | ||
else: | ||
click.echo(f"Pipeline successfully undeployed") | ||
except ConnectionError: | ||
click.echo("Hayhooks server is not responding. To start one, run `hayooks run`") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from hayhooks.server.handlers import deploy | ||
from hayhooks.server.handlers import status | ||
from hayhooks.server.handlers import undeploy | ||
|
||
|
||
__all__ = ["deploy", "status"] | ||
__all__ = ["deploy", "status", "undeploy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import cast | ||
|
||
from fastapi import HTTPException | ||
from fastapi.routing import APIRoute | ||
from hayhooks.server import app | ||
from hayhooks.server.pipelines import registry | ||
|
||
|
||
@app.post("/undeploy/{pipeline_name}") | ||
async def deploy(pipeline_name: str): | ||
if pipeline_name not in registry.get_names(): | ||
raise HTTPException(status_code=404) | ||
|
||
new_routes = [] | ||
for route in app.router.routes: | ||
route = cast(APIRoute, route) | ||
if route.name != pipeline_name: | ||
new_routes.append(route) | ||
|
||
app.router.routes = new_routes | ||
app.openapi_schema = None | ||
app.setup() | ||
registry.remove(pipeline_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters