Skip to content

Commit

Permalink
fix: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren committed Dec 2, 2024
1 parent e770b8e commit f791e76
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
13 changes: 0 additions & 13 deletions keep/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
)
from keep.api.routes.auth import groups as auth_groups
from keep.api.routes.auth import permissions, roles, users
from keep.api.routes.dashboard import provision_dashboards
from keep.event_subscriber.event_subscriber import EventSubscriber
from keep.identitymanager.identitymanagerfactory import (
IdentityManagerFactory,
Expand All @@ -61,9 +60,7 @@

# load all providers into cache
from keep.providers.providers_factory import ProvidersFactory
from keep.providers.providers_service import ProvidersService
from keep.workflowmanager.workflowmanager import WorkflowManager
from keep.workflowmanager.workflowstore import WorkflowStore

load_dotenv(find_dotenv())
keep.api.logging.setup_logging()
Expand All @@ -75,7 +72,6 @@
CONSUMER = os.environ.get("CONSUMER", "true") == "true"

AUTH_TYPE = os.environ.get("AUTH_TYPE", IdentityManagerTypes.NOAUTH.value).lower()
PROVISION_RESOURCES = os.environ.get("PROVISION_RESOURCES", "true") == "true"
try:
KEEP_VERSION = metadata.version("keep")
except Exception:
Expand Down Expand Up @@ -185,15 +181,6 @@ async def root():
async def on_startup():
logger.info("Loading providers into cache")
ProvidersFactory.get_all_providers()
if PROVISION_RESOURCES:
# provision providers from env. relevant only on single tenant.
logger.info("Provisioning providers and workflows")
ProvidersService.provision_providers_from_env(SINGLE_TENANT_UUID)
logger.info("Providers loaded successfully")
WorkflowStore.provision_workflows_from_directory(SINGLE_TENANT_UUID)
logger.info("Workflows provisioned successfully")
provision_dashboards(SINGLE_TENANT_UUID)
logger.info("Dashboards provisioned successfully")
# Start the services
logger.info("Starting the services")
# Start the scheduler
Expand Down
15 changes: 15 additions & 0 deletions keep/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
from keep.api.api import AUTH_TYPE
from keep.api.core.db_on_start import migrate_db, try_create_single_tenant
from keep.api.core.dependencies import SINGLE_TENANT_UUID
from keep.api.routes.dashboard import provision_dashboards
from keep.identitymanager.identitymanagerfactory import IdentityManagerTypes
from keep.providers.providers_factory import ProvidersFactory
from keep.providers.providers_service import ProvidersService
from keep.workflowmanager.workflowstore import WorkflowStore

PORT = int(os.environ.get("PORT", 8080))
PROVISION_RESOURCES = os.environ.get("PROVISION_RESOURCES", "true") == "true"

keep.api.logging.setup_logging()
logger = logging.getLogger(__name__)
Expand All @@ -19,6 +23,17 @@ def on_starting(server=None):
logger.info("Keep server starting")

migrate_db()

if PROVISION_RESOURCES:
# provision providers from env. relevant only on single tenant.
logger.info("Provisioning providers and workflows")
ProvidersService.provision_providers_from_env(SINGLE_TENANT_UUID)
logger.info("Providers loaded successfully")
WorkflowStore.provision_workflows_from_directory(SINGLE_TENANT_UUID)
logger.info("Workflows provisioned successfully")
provision_dashboards(SINGLE_TENANT_UUID)
logger.info("Dashboards provisioned successfully")

# Load this early and use preloading
# https://www.joelsleppy.com/blog/gunicorn-application-preloading/
# @tb: 👏 @Matvey-Kuk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"""

import sqlalchemy as sa
import sqlalchemy_utils
import sqlmodel
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "3ad5308e7200"
Expand Down Expand Up @@ -59,7 +56,10 @@ def downgrade() -> None:
existing_nullable=True,
)
batch_op.alter_column(
"settings", existing_type=sa.JSON(), type_=sa.VARCHAR(length=255), nullable=False
"settings",
existing_type=sa.JSON(),
type_=sa.VARCHAR(length=255),
nullable=False,
)

# ### end Alembic commands ###

0 comments on commit f791e76

Please sign in to comment.