Skip to content

Commit

Permalink
better env var name
Browse files Browse the repository at this point in the history
  • Loading branch information
masci committed Feb 20, 2024
1 parent 3d1c4e2 commit 69d449d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/hayhooks/cli/run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
@click.option('--port', default=1416)
@click.option('--pipelines-dir', default="pipelines.d")
def run(host, port, pipelines_dir):
os.environ["PIPELINES_DIR"] = pipelines_dir
os.environ["HAYHOOKS_PIPELINES_DIR"] = pipelines_dir
uvicorn.run("hayhooks.server:app", host=host, port=port)
20 changes: 11 additions & 9 deletions src/hayhooks/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ def create_app():
app = FastAPI()

# Deploy all pipelines in the pipelines directory
pipelines_dir = os.environ.get("PIPELINES_DIR")
for pipeline_file_path in glob.glob(f"{pipelines_dir}/*.yml"):
name = Path(pipeline_file_path).stem
with open(pipeline_file_path, "r") as pipeline_file:
source_code = pipeline_file.read()

pipeline_defintion = PipelineDefinition(name=name, source_code=source_code)
deployed_pipeline = deploy_pipeline_def(app, pipeline_defintion)
logger.info(f"Deployed pipeline: {deployed_pipeline['name']}")
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"):
name = Path(pipeline_file_path).stem
with open(pipeline_file_path, "r") as pipeline_file:
source_code = pipeline_file.read()

pipeline_defintion = PipelineDefinition(name=name, source_code=source_code)
deployed_pipeline = deploy_pipeline_def(app, pipeline_defintion)
logger.info(f"Deployed pipeline: {deployed_pipeline['name']}")
return app


Expand Down

0 comments on commit 69d449d

Please sign in to comment.