Skip to content

Commit

Permalink
Merge pull request #2117 from Agenta-AI/feature/age-1057-critical-bug…
Browse files Browse the repository at this point in the history
…-agenta-cli-does-not-work-anymore-post-release

[Bug Fix]: agenta CLI does not work anymore post-release (project structure)
  • Loading branch information
mmabrouk authored Oct 12, 2024
2 parents 1dcccf2 + df2a13e commit 6c79093
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 7 additions & 0 deletions agenta-backend/agenta_backend/routers/app_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ async def create_app(
request.state.user_id,
Permission.CREATE_APPLICATION,
)

workspace_id_from_apikey = await db_manager_ee.get_workspace_id_from_apikey(
api_key_from_headers, request.state.user_id
)
if payload.workspace_id is None:
payload.workspace_id = workspace_id_from_apikey

try:
user_org_workspace_data = await get_user_org_and_workspace_id(
request.state.user_id
Expand Down
6 changes: 4 additions & 2 deletions agenta-backend/agenta_backend/routers/variants_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,16 @@ async def start_variant(

if action.action == VariantActionEnum.START:
url: URI = await app_manager.start_variant(
app_variant_db, str(app_variant_db.project_id), envvars
app_variant_db,
str(app_variant_db.project_id),
envvars,
request.state.user_id,
)

# Deploy to production
await db_manager.deploy_to_environment(
environment_name="production",
variant_id=str(app_variant_db.id),
project_id=str(app_variant_db.project_id),
user_uid=request.state.user_id,
)
return url
Expand Down
8 changes: 5 additions & 3 deletions agenta-backend/agenta_backend/services/app_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ async def update_variant_image(
)

# Start variant
await start_variant(app_variant_db, project_id)
await start_variant(app_variant_db, project_id, user_uid=user_uid)


async def update_last_modified_by(
Expand Down Expand Up @@ -313,9 +313,11 @@ async def terminate_and_remove_app_variant(
logger.error(f"Failed to stop and delete service {deployment} {e}")

# If image deletable is True, remove docker image and image db
if image.deletable:
if image is not None and image.deletable:
try:
if isCloudEE():
if isCloudDev() or isOss():
await deployment_manager.remove_image(image)
elif isCloudEE():
await deployment_manager.remove_repository(image.tags) # type: ignore
else:
await deployment_manager.remove_image(image)
Expand Down

0 comments on commit 6c79093

Please sign in to comment.