From 3dd005a11c94d586e6ddc9b1c2c2ef25ea125dd9 Mon Sep 17 00:00:00 2001 From: Massimiliano Pippi Date: Thu, 29 Feb 2024 09:53:07 +0100 Subject: [PATCH] add --additional-python-path option --- src/hayhooks/cli/run/__init__.py | 8 +++++++- src/hayhooks/server/app.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hayhooks/cli/run/__init__.py b/src/hayhooks/cli/run/__init__.py index 135a37f..b9ffb2d 100644 --- a/src/hayhooks/cli/run/__init__.py +++ b/src/hayhooks/cli/run/__init__.py @@ -1,14 +1,20 @@ import click import uvicorn import os +import sys @click.command() @click.option('--host', default="localhost") @click.option('--port', default=1416) @click.option('--pipelines-dir', default=os.environ.get("HAYHOOKS_PIPELINES_DIR")) -def run(host, port, pipelines_dir): +@click.option('--additional-python-path', default=os.environ.get("HAYHOOKS_ADDITIONAL_PYTHONPATH")) +def run(host, port, pipelines_dir, additional_python_path): if not pipelines_dir: pipelines_dir = "pipelines.d" os.environ["HAYHOOKS_PIPELINES_DIR"] = pipelines_dir + + if additional_python_path: + sys.path.append(additional_python_path) + uvicorn.run("hayhooks.server:app", host=host, port=port) diff --git a/src/hayhooks/server/app.py b/src/hayhooks/server/app.py index b47734b..efcffb0 100644 --- a/src/hayhooks/server/app.py +++ b/src/hayhooks/server/app.py @@ -18,7 +18,7 @@ def create_app(): pipelines_dir = os.environ.get("HAYHOOKS_PIPELINES_DIR") if pipelines_dir: logger.info(f"Pipelines dir set to: {pipelines_dir}") - for pipeline_file_path in glob.glob(f"{pipelines_dir}/*.yml"): + for pipeline_file_path in glob.glob(f"{pipelines_dir}/*.y*ml"): name = Path(pipeline_file_path).stem with open(pipeline_file_path, "r") as pipeline_file: source_code = pipeline_file.read()