-
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
8 changed files
with
48 additions
and
25 deletions.
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
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,18 @@ | ||
from pathlib import Path | ||
|
||
import click | ||
import requests | ||
|
||
|
||
@click.command() | ||
@click.option('-n', '--name') | ||
@click.argument('pipeline_file', type=click.File('r')) | ||
def deploy(name, pipeline_file): | ||
if name is None: | ||
name = Path(pipeline_file.name).stem | ||
resp = requests.post("http://localhost:1416/deploy", json={"name": name, "source_code": str(pipeline_file.read())}) | ||
|
||
if resp.status_code >= 400: | ||
click.echo(f"Error deploying pipeline: {resp.json().get('detail')}") | ||
else: | ||
click.echo(f"Pipeline successfully deployed with name: {resp.json().get('name')}") |
This file was deleted.
Oops, something went wrong.
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,8 +1,24 @@ | ||
import click | ||
import requests | ||
from requests.exceptions import ConnectionError | ||
|
||
|
||
@click.command() | ||
def status(): | ||
r = requests.get("http://localhost:1416/status") | ||
click.echo(r.status_code) | ||
try: | ||
r = requests.get("http://localhost:1416/status") | ||
except ConnectionError: | ||
click.echo("Hayhooks server is not responding. To start one, run `hayooks run`") | ||
return | ||
|
||
if r.status_code >= 400: | ||
body = r.json() | ||
click.echo(f"Hayhooks server is unhealty: [{r.status_code}] {r. json().get('detail')}") | ||
return | ||
|
||
click.echo("Hayhooks server is up and running.") | ||
body = r.json() | ||
if pipes := body.get("pipelines"): | ||
click.echo("\nPipelines deployed:") | ||
for p in pipes: | ||
click.echo(f"- {p}") |
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,5 @@ | ||
from hayhooks.server.handlers import serve | ||
from hayhooks.server.handlers import deploy | ||
from hayhooks.server.handlers import status | ||
|
||
|
||
__all__ = ["serve", "status"] | ||
__all__ = ["deploy", "status"] |
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
from fastapi import HTTPException | ||
from hayhooks.server import app | ||
from hayhooks.server.pipelines import registry | ||
|
||
|
||
@app.get("/status") | ||
async def status(): | ||
return {"status": "Up!"} | ||
pipelines = registry.get_names() | ||
return {"status": "Up!", "pipelines": pipelines} |