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

Dynamic Pagination in CPT Dashboard #135

Merged
merged 9 commits into from
Dec 13, 2024

Conversation

MVarshini
Copy link
Collaborator

@MVarshini MVarshini commented Nov 19, 2024

Type of change

  • Refactor
  • New feature
  • Bug fix
  • Optimization
  • Documentation Update

Description

The [PROD]_JOBS_API accepts size and offset params

Related Tickets & Documents

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please describe the System Under Test.
  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

@MVarshini MVarshini self-assigned this Nov 19, 2024
@MVarshini MVarshini changed the base branch from main to revamp November 20, 2024 13:39
backend/app/api/v1/commons/hce.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/cpt/cptJobs.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/cpt/maps/hce.py Outdated Show resolved Hide resolved
backend/app/services/search.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

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

I didn't get all the way through, but here's a bunch ...

backend/app/api/v1/commons/hce.py Outdated Show resolved Hide resolved
backend/app/api/v1/commons/hce.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/cpt/cptJobs.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/cpt/cptJobs.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/cpt/cptJobs.py Show resolved Hide resolved
backend/app/api/v1/endpoints/cpt/cptJobs.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/cpt/maps/hce.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/cpt/maps/ocp.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/ocm/ocmJobs.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/ocp/ocpJobs.py Outdated Show resolved Hide resolved
@vishnuchalla vishnuchalla mentioned this pull request Nov 21, 2024
7 tasks
Copy link
Collaborator

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

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

Lots of good cleanup, but I think you added a few bugs while you were at it. 😆

backend/app/api/v1/commons/hce.py Outdated Show resolved Hide resolved
backend/app/api/v1/commons/ocp.py Outdated Show resolved Hide resolved
backend/app/api/v1/commons/quay.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/ocp/ocpJobs.py Outdated Show resolved Hide resolved
@dbutenhof
Copy link
Collaborator

And now that the reformatting is merged ... you've got a bunch of conflicts to resolve here. 😆

Once you've rebased and resolved the conflicts, make sure that you run black again on the results to be safe!

Copy link
Collaborator

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

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

And now that you've merged the black reformatting, I recommend that you make a habit of running black before pushing any commit to a PR. At some point we'll be able to turn on black --check in the CI so we won't accidentally break the conventions -- but even then, doing it proactively is a good idea. (You can turn on git pre-commit hooks if you want, though I've found that can sometimes become annoying and I prefer to do it manually when I'm ready.)

backend/app/api/v1/commons/utils.py Show resolved Hide resolved
backend/app/api/v1/commons/quay.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/cpt/cptJobs.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/ocp/ocpJobs.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/ocp/ocpJobs.py Outdated Show resolved Hide resolved
backend/app/services/search.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

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

A few new comments, but they're more style suggestions; and one remaining unanswered confusion about your logic at #135 (comment); but this is looking good.

backend/app/api/v1/endpoints/ocm/ocmJobs.py Outdated Show resolved Hide resolved
backend/app/api/v1/endpoints/ocm/ocmJobs.py Show resolved Hide resolved
Comment on lines +23 to +28
if len(jobs) == 0:
return {"data": jobs, "total": response["total"]}

jobs[["group"]] = jobs[["group"]].fillna(0)
jobs.fillna("", inplace=True)
if len(jobs) == 0:
return jobs
return jobs

Copy link
Member

Choose a reason for hiding this comment

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

It would reduce the code complexity if you just included those two lines in a len(jobs) != 0 case instead of having an identical return early.

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are a lot of potential refactoring ideas we should pursue to make the somewhat messy codebase more maintainable.

Right now, we've got a long list of PRs we'd really like to land, and we need to focus on the most critical concerns ... starting with landing this PR, #138, and then a follow-on filtering PR which ought to complete the "revamp" branch. Once we land that onto "main" we can churn through my backlog of ilab PRs.

At that point, our focus should be cleaning up the code base (including unit testing, functional testing, lint and format checkers) to make it more maintainable with a viable CI.

As much as I hate being "pragmatic" in things like this, let's not let minor stuff like this bog us down at this point. Maybe leaving these comments in place and open as a reference for later work isn't a bad idea ...

backend/app/api/v1/commons/ocm.py Show resolved Hide resolved
Comment on lines 57 to +60
jbs = cleanJobs
jbs["shortVersion"] = jbs["ocpVersion"].str.slice(0, 4)

return jbs
return {"data": jbs, "total": response["total"]}
Copy link
Member

Choose a reason for hiding this comment

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

What does cleanJobs come from? It may benefit from a comment.

And I do not think jbs makes sense as a variable name. It's just confusing and looks like a typo. Dave also questioned this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

cleanJobs is the result of a pandas dataframe filter to remove rows, although my understanding of the complicated pandas infrastructure is minimal.

What bugs me here is the jbs = cleanJobs to effectively just obscure the name before returning the data using jbs. That's not new with Varshini's changes, though, and I don't think it's practical to push her to rewrite more existing logic than necessary for the revamp. (On the other hand, simply replacing cleanJobs with jbs or dropping the intermediary jbs would make the code easier to read, and it'd be "simple"... it's just that an endless list of "simple" things isn't simple anymore. 🤔 💣 )

Copy link
Member

Choose a reason for hiding this comment

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

We will definitely need to keep a note of this for a future refactor PR.

backend/app/api/v1/endpoints/cpt/cptJobs.py Outdated Show resolved Hide resolved
)
df["version"] = df["version"].apply(
lambda x: x if len(x.split(":")) == 1 else x.split(":")[1][:7]
import pandas as pd
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason the comment for the function has an import between it and the function?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, the import should be at the top. I'm wondering whether isort (which I intent to run when we move into code ownership/cleanup after our PRs are merged) will fix this??? 🤔 In any case, it's a new import and ought to be moved up to the top section.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved the imports to the top

backend/app/api/v1/endpoints/ocm/ocmJobs.py Outdated Show resolved Hide resolved
frontend/src/actions/paginationActions.js Show resolved Hide resolved
Copy link
Collaborator

@dbutenhof dbutenhof left a comment

Choose a reason for hiding this comment

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

I think this is really close, with just a few minor cleanups needed to push it forward so that Varshini can concentrate on finishing the revamp branch and letting us move on.

Comment on lines +23 to +28
if len(jobs) == 0:
return {"data": jobs, "total": response["total"]}

jobs[["group"]] = jobs[["group"]].fillna(0)
jobs.fillna("", inplace=True)
if len(jobs) == 0:
return jobs
return jobs

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are a lot of potential refactoring ideas we should pursue to make the somewhat messy codebase more maintainable.

Right now, we've got a long list of PRs we'd really like to land, and we need to focus on the most critical concerns ... starting with landing this PR, #138, and then a follow-on filtering PR which ought to complete the "revamp" branch. Once we land that onto "main" we can churn through my backlog of ilab PRs.

At that point, our focus should be cleaning up the code base (including unit testing, functional testing, lint and format checkers) to make it more maintainable with a viable CI.

As much as I hate being "pragmatic" in things like this, let's not let minor stuff like this bog us down at this point. Maybe leaving these comments in place and open as a reference for later work isn't a bad idea ...

backend/app/api/v1/commons/ocm.py Show resolved Hide resolved
Comment on lines 57 to +60
jbs = cleanJobs
jbs["shortVersion"] = jbs["ocpVersion"].str.slice(0, 4)

return jbs
return {"data": jbs, "total": response["total"]}
Copy link
Collaborator

Choose a reason for hiding this comment

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

cleanJobs is the result of a pandas dataframe filter to remove rows, although my understanding of the complicated pandas infrastructure is minimal.

What bugs me here is the jbs = cleanJobs to effectively just obscure the name before returning the data using jbs. That's not new with Varshini's changes, though, and I don't think it's practical to push her to rewrite more existing logic than necessary for the revamp. (On the other hand, simply replacing cleanJobs with jbs or dropping the intermediary jbs would make the code easier to read, and it'd be "simple"... it's just that an endless list of "simple" things isn't simple anymore. 🤔 💣 )

backend/app/api/v1/endpoints/cpt/cptJobs.py Outdated Show resolved Hide resolved
)
df["version"] = df["version"].apply(
lambda x: x if len(x.split(":")) == 1 else x.split(":")[1][:7]
import pandas as pd
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, the import should be at the top. I'm wondering whether isort (which I intent to run when we move into code ownership/cleanup after our PRs are merged) will fix this??? 🤔 In any case, it's a new import and ought to be moved up to the top section.

frontend/src/actions/paginationActions.js Show resolved Hide resolved
@dbutenhof dbutenhof mentioned this pull request Dec 12, 2024
7 tasks
Copy link
Member

@jaredoconnell jaredoconnell left a comment

Choose a reason for hiding this comment

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

I just have one new comment. The rest can be addressed later.

Comment on lines 19 to 20


Copy link
Member

Choose a reason for hiding this comment

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

Now that the import is removed, should this gap still be here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting question. Do we need two blank lines here? Did this get run through black again? If not, it would probably be a good idea before we merge this.

Comment on lines 57 to +60
jbs = cleanJobs
jbs["shortVersion"] = jbs["ocpVersion"].str.slice(0, 4)

return jbs
return {"data": jbs, "total": response["total"]}
Copy link
Member

Choose a reason for hiding this comment

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

We will definitely need to keep a note of this for a future refactor PR.

@chentex
Copy link
Member

chentex commented Dec 12, 2024

I tested the Pr locally and gone through the changes, I think we are good to go, let's wait also for @vishnuchalla to take an extra look and test.

@vishnuchalla
Copy link
Collaborator

vishnuchalla commented Dec 13, 2024

Few observations while navigating through the dashboard.

  • When a filter is being applied the row count updates but the table rows are not filtered. Applies for all the tabs. For example, try filtering out using benchmark. This seems like an issue while slicing out the rows in frontend code.
  • Graph data is not being rendered in Quay tab (i.e Error's out in ES query). Works for the rest of the tabs.
  • Pagination works properly only for next page but not when trying to navigate to previous, first and last pages. (i.e. the rows in the table are not getting updated at all). After looking at the logs, this seems like there is no query being sent from frontend to the backend with updated size/offset on a state update.

cc: @dbutenhof @MVarshini @jaredoconnell @chentex @jtaleric

@vishnuchalla
Copy link
Collaborator

vishnuchalla commented Dec 13, 2024

Few observations while navigating through the dashboard.

  • When a filter is being applied the row count updates but the table rows are not filtered. Applies for all the tabs. For example, try filtering out using benchmark. This seems like an issue while slicing out the rows in frontend code.
  • Graph data is not being rendered in Quay tab (i.e Error's out in ES query). Works for the rest of the tabs.
  • Pagination works properly only for next page but not when trying to navigate to previous, first and last pages. (i.e. the rows in the table are not getting updated at all). After looking at the logs, this seems like there is no query being sent from frontend to the backend with updated size/offset on a state update.

cc: @dbutenhof @MVarshini @jaredoconnell @chentex @jtaleric

If we want to take these improvements/bug fixes in follow up PRs and get us unblocked for now, we can get this PR merged into revamp branch. Merging this into staging will introduce bugs and block others from making their changes and promoting things to production. Open for other thoughts too.

@dbutenhof
Copy link
Collaborator

Thanks for the review and testing, @vishnuchalla. (Now we need to encapsulate all that testing into an automated CI ... but we'll get there.)

@MVarshini already has one more PR lined up on the revamp branch for additional issues, plus another branch she's working on now that doesn't yet have a PR. I think we need to get "revamp" to product quality so we can drop it onto main, cut a release, and move on.

All three of the issues you found need to be fixed on revamp before we drop to main and stage it, but not necessarily in this PR unless we can point out changed code that's responsible. Since #138 focuses on backend sorting, it's likely to touch these issues only by accident, but I don't remember the exact scope of the remaining PR so it's possible there's some overlap already?

@dbutenhof
Copy link
Collaborator

I created new issues to record @vishnuchalla's three problems on the REVAMP branch. We should re-evaluate these after @MVarshini's remaining two PRs are stabilized, and fix them if still necessary before dropping revamp onto main for staging.

I'm going to go ahead and merge this PR so she can move forward with #135.

@dbutenhof dbutenhof merged commit d3f6924 into cloud-bulldozer:revamp Dec 13, 2024
1 check passed
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