Skip to content
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

Implement feedback filtering in CLI & SDK #206

Merged
merged 6 commits into from
Jul 25, 2024

Conversation

nullfox
Copy link
Contributor

@nullfox nullfox commented Jul 1, 2024

Screenshot 2024-07-19 at 10 00 56 AM

@nullfox nullfox requested review from nqn, kxtran and wenzhe-log10 July 1, 2024 23:09
Copy link
Collaborator

@kxtran kxtran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % adding test


try:
while True:
fetch_limit = limit if limit else 50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be written as a default arg eg
def _get_feedback_list_graphql(page, task_id, filter, limit=50):


def _get_feedback_list_graphql(page, limit, task_id, filter):
feedback_data = []
current_page = page if page else 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can set page=1 as a default arg (see below)


variables = {
"id": self._log10_config.org_id,
"taskId": task_id or None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value for task_id is empty string, is there significance to None or does it just need to be falsey? Another approach is to default it to None. (Just something that jumped out from a readability standpoint)

"--filter",
default="",
type=str,
help="The filter applied to the feedback. If not provided, feedback will not be filtered.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a bit explanation here, even a simple sentence like "e.g. --filter "coverage > 4"".

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think that an explanation is still needed here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added.

logger.error(e.response.json()["error"])
return []

return list(map(_format_graphql_node, feedback_data))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return list(map(_format_graphql_node, feedback_data))
return [_format_graphql_node(item) for item in feedback_data]

more readable in python sense. Also I realized that we have used list as a function in Feedback class. We should do a follow up to rename that function, so that we don't name function the same as python build-in function.

feedback_data = []
current_page = page if page else 1
if limit:
limit = int(limit)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: thinking to add the default 50 value here.

else:
    limit = 50

so that line 183 could be fetch_limit = limit in line 183. or just directly use limit in the while loop

current_fetched = len(new_data)
current_page += 1

if current_fetched < fetch_limit:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wonder if there's edge case, like when current_fetched = 50 and fetch_limit = 50, so it would go to next iteration?

}


def _get_feedback_list_graphql(page, task_id, filter, limit=50):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you set page=1 as a default?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

btw, what's the API for task_id and filter. should I set the default to None or ""?

"--filter",
default="",
type=str,
help="The filter applied to the feedback. If not provided, feedback will not be filtered.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think that an explanation is still needed here?

@wenzhe-log10 wenzhe-log10 merged commit 09e7448 into main Jul 25, 2024
2 checks passed
@wenzhe-log10 wenzhe-log10 deleted the ben/feedback-filtering-v2 branch July 25, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants