From 453007a8359dc2bc024e14fb07223929ea9b5061 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Fri, 3 Nov 2023 14:32:35 +0800 Subject: [PATCH] build(tasks): fix "inv run_api_server_with_poetry --init" path error (#78) --- tasks.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tasks.py b/tasks.py index 7db236ce..d67b2a9e 100644 --- a/tasks.py +++ b/tasks.py @@ -1,6 +1,11 @@ +from pathlib import Path + from invoke import task from invoke.context import Context +project_root = Path(__file__).parent.absolute() +api_root = project_root / Path("api") + api_version = "1.0.0-dev" api_image_name = "ask-astro-api" api_container_name = "ask-astro-api" @@ -9,7 +14,7 @@ @task def init_api_server_poetry_env(ctx: Context) -> None: """Initialize the ask-astro API local poetry environment""" - with ctx.cd("api"): + with ctx.cd(api_root): print("Initialize ask-astro API local poetry environment") ctx.run("poetry install") @@ -17,9 +22,10 @@ def init_api_server_poetry_env(ctx: Context) -> None: @task(help={"init": "initialize poetry environment before running server"}) def run_api_server_with_poetry(ctx: Context, init: bool = False) -> None: """Run ask-astro API server with poetry""" - with ctx.cd("api"): + with ctx.cd(api_root): if init: init_api_server_poetry_env(ctx) + print("Starting ask-astro API local poetry environment") ctx.run("poetry run python -m ask_astro.app")