-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #501 from phospho-app/dev
Fix onboarding flow when uploading data
- Loading branch information
Showing
34 changed files
with
1,318 additions
and
695 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from app.services.mongo.recipes import run_recipe_types_on_tasks | ||
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException | ||
from propelauth_fastapi import User | ||
|
||
from app.api.platform.models import RunRecipeRequest | ||
from app.security.authentification import ( | ||
propelauth, | ||
verify_if_propelauth_user_can_access_project, | ||
) | ||
from app.core import config | ||
|
||
router = APIRouter(tags=["Recipes"]) | ||
|
||
|
||
@router.post( | ||
"/recipes/{project_id}/run", | ||
response_model=dict, | ||
description="Run multiple recipes on tasks of a project", | ||
) | ||
async def post_run_recipes( | ||
project_id: str, | ||
run_recipe_request: RunRecipeRequest, | ||
background_tasks: BackgroundTasks, | ||
user: User = Depends(propelauth.require_user), | ||
) -> dict: | ||
""" | ||
Run multiple recipes of different types on tasks of a project | ||
""" | ||
org_id = await verify_if_propelauth_user_can_access_project(user, project_id) | ||
org = propelauth.fetch_org(org_id) | ||
org_metadata = org.get("metadata", {}) | ||
customer_id = None | ||
|
||
if "customer_id" in org_metadata.keys(): | ||
customer_id = org_metadata.get("customer_id", None) | ||
|
||
if not customer_id and org_id != config.PHOSPHO_ORG_ID: | ||
raise HTTPException( | ||
status_code=402, | ||
detail="You need to add a payment method to access this service. Please update your payment details: https://platform.phospho.ai/org/settings/billing", | ||
) | ||
|
||
background_tasks.add_task( | ||
run_recipe_types_on_tasks, | ||
org_id=org_id, | ||
project_id=project_id, | ||
recipe_types=run_recipe_request.recipe_type_list, | ||
filters=run_recipe_request.filters, | ||
) | ||
return {"status": "ok"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from typing import Optional | ||
from pydantic import BaseModel | ||
|
||
|
||
class CreateCheckoutRequest(BaseModel): | ||
project_id: Optional[str] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from typing import List, Optional | ||
from phospho.models import ProjectDataFilters | ||
from pydantic import BaseModel | ||
|
||
|
||
class RunRecipeRequest(BaseModel): | ||
recipe_type_list: List[str] | ||
filters: Optional[ProjectDataFilters] = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.