-
Notifications
You must be signed in to change notification settings - Fork 2
(MIDRC-1276) Add pre-filtering in funnel query for listing tasks #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
george42-ctds
wants to merge
7
commits into
master
Choose a base branch
from
fix/pre-filter-task-list
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a20510c
(MIDRC-1276) Add pre-filtering in funnel query for listing tasks
george42-ctds 63f36a0
Apply automatic documentation changes
george42-ctds 346f747
Add unit test for missing user_id
george42-ctds 10d8e68
Add description for 'all' parameter
george42-ctds 448b4db
Apply automatic documentation changes
george42-ctds 4802165
Update doc string
george42-ctds 5c7f73b
Apply automatic documentation changes
george42-ctds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -37,6 +37,13 @@ | |
| TAGS_HIDDEN_FROM_USER.remove("_AUTHZ") | ||
|
|
||
|
|
||
| def get_auth_string_for_user(user_id: str) -> str: | ||
| """ | ||
| Get the authz_resource string for a user | ||
| """ | ||
| return f"/services/workflow/gen3-workflow/tasks/{user_id}/TASK_ID_PLACEHOLDER" | ||
|
|
||
|
|
||
| async def get_request_body(request: Request) -> dict: | ||
| """ | ||
| Extract the body from a FastAPI request | ||
|
|
@@ -161,9 +168,7 @@ async def create_task(request: Request, auth=Depends(Auth)) -> dict: | |
| ) | ||
| logger.error(err_msg) | ||
| raise HTTPException(HTTP_400_BAD_REQUEST, err_msg) | ||
| authz_resource = ( | ||
| f"/services/workflow/gen3-workflow/tasks/{user_id}/TASK_ID_PLACEHOLDER" | ||
| ) | ||
| authz_resource = get_auth_string_for_user(user_id) | ||
| body["tags"]["_AUTHZ"] = authz_resource | ||
|
|
||
| if config["EKS_CLUSTER_NAME"]: | ||
|
|
@@ -238,7 +243,9 @@ def apply_view_to_task(view: str, task: dict) -> dict: | |
|
|
||
| @router.get("/tasks", status_code=HTTP_200_OK) | ||
| @router.get("/tasks/", status_code=HTTP_200_OK, include_in_schema=False) | ||
| async def list_tasks(request: Request, auth=Depends(Auth)) -> dict: | ||
| async def list_tasks( | ||
| request: Request, auth=Depends(Auth), all: str | None = None | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Example of how to do it here |
||
| ) -> dict: | ||
| """ | ||
| List the user's GA4GH TES tasks | ||
| """ | ||
|
|
@@ -262,7 +269,18 @@ async def list_tasks(request: Request, auth=Depends(Auth)) -> dict: | |
| requested_view = query_params.get("view") | ||
| query_params["view"] = "FULL" | ||
|
|
||
| # get all the tasks, regardless of access | ||
| if all is None: | ||
| query_params["tag_key"] = "_AUTHZ" | ||
| # get the user_id and construct an authz value | ||
| token_claims = await auth.get_token_claims() | ||
| user_id = token_claims.get("sub") | ||
| if not user_id: | ||
| err_msg = "No user sub in token" | ||
| logger.error(err_msg) | ||
| raise HTTPException(HTTP_401_UNAUTHORIZED, err_msg) | ||
| authz_resource = get_auth_string_for_user(user_id) | ||
| query_params["tag_value"] = authz_resource | ||
|
|
||
| url = f"{config['TES_SERVER_URL']}/tasks" | ||
| res = await make_tes_server_request( | ||
| request.app.async_client, "get", url, params=query_params | ||
|
|
||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.