Skip to content

Commit

Permalink
add --additional-python-path option
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Feb 29, 2024
1 parent 8f86a90 commit 3dd005a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/hayhooks/cli/run/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion src/hayhooks/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 3dd005a

Please sign in to comment.