From 3ea029e1d40ebe2a0021ce4ce35da4b2a3eedc43 Mon Sep 17 00:00:00 2001 From: Shahar Glazner Date: Sun, 15 Sep 2024 09:49:35 +0300 Subject: [PATCH] fix: default workflows directory (#1919) --- keep/api/routes/workflows.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/keep/api/routes/workflows.py b/keep/api/routes/workflows.py index 621e6d843..7ed8dfc2b 100644 --- a/keep/api/routes/workflows.py +++ b/keep/api/routes/workflows.py @@ -387,6 +387,19 @@ def get_random_workflow_templates( "KEEP_WORKFLOWS_PATH", os.path.join(os.path.dirname(__file__), "../../../examples/workflows"), ) + if not os.path.exists(default_directory): + # on the container we use the following path + fallback_directory = "/examples/workflows" + logger.warning( + f"{default_directory} does not exist, using fallback: {fallback_directory}" + ) + if os.path.exists(fallback_directory): + default_directory = fallback_directory + else: + logger.error(f"Neither {default_directory} nor {fallback_directory} exist") + raise FileNotFoundError( + f"Neither {default_directory} nor {fallback_directory} exist" + ) workflows = workflowstore.get_random_workflow_templates( tenant_id=tenant_id, workflows_dir=default_directory, limit=6 )