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

chore: bunify postgres_jobs.go #8858

Merged
merged 5 commits into from
Feb 22, 2024
Merged

chore: bunify postgres_jobs.go #8858

merged 5 commits into from
Feb 22, 2024

Conversation

kkunapuli
Copy link
Contributor

@kkunapuli kkunapuli commented Feb 20, 2024

Description

DET-10134 Convert all SQL commands in postgres_jobs.go to Bun SQL commands.

Test Plan

Using devcluster locally, created an experiment. Exec'd into postgres container to confirm a new job exists.

Commentary (optional)

Moving to bun means that we are also slowly simplifying (deprecating?) the db interface, allowing code to move out of the db package and be organized in a more modular way.

I also named /master/internal/db import as internaldb to differentiate between db as a type and db as a package - especially since it was sometimes used in both contexts in the same file.

Checklist

  • Changes have been manually QA'd
  • User-facing API changes need the "User-facing API Change" label.
  • Release notes should be added as a separate file under docs/release-notes/.
    See Release Note for details.
  • Licenses should be included for new code which was copied and/or modified from any external code.

Ticket

DET-10134

@cla-bot cla-bot bot added the cla-signed label Feb 20, 2024
Copy link

netlify bot commented Feb 20, 2024

Deploy Preview for determined-ui canceled.

Name Link
🔨 Latest commit 8458d20
🔍 Latest deploy log https://app.netlify.com/sites/determined-ui/deploys/65d75f6cf299b6000828ed74

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually don't know why this file changed. I did not intentionally run any proto commands to update this file. Although I did run make commands like build/fmt/check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is the reason the change is not rebasable; I suspect I need to overwrite the file with whatever is currently in master?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've never run into this issue with a rebase, though maybe you did something slightly differently. Sounds plausible this is some artifact of git process though.

@@ -19,7 +19,7 @@ import (
"github.com/determined-ai/determined/master/internal/api"
"github.com/determined-ai/determined/master/internal/authz"
"github.com/determined-ai/determined/master/internal/checkpoints"
"github.com/determined-ai/determined/master/internal/db"
internaldb "github.com/determined-ai/determined/master/internal/db"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

named import as internaldb to differentiate between db the type and db the package import; I think this is more clear (especially since db is sometimes used in multiple contexts in the same file) but can undo it if it's against style guidelines

Copy link
Contributor

Choose a reason for hiding this comment

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

I've done the db conflicts with db dance enough that I'm fine with it.

@kkunapuli kkunapuli marked this pull request as ready for review February 20, 2024 16:40
@kkunapuli kkunapuli requested a review from a team as a code owner February 20, 2024 16:40
@@ -19,7 +19,7 @@ import (
"github.com/determined-ai/determined/master/internal/api"
"github.com/determined-ai/determined/master/internal/authz"
"github.com/determined-ai/determined/master/internal/checkpoints"
"github.com/determined-ai/determined/master/internal/db"
internaldb "github.com/determined-ai/determined/master/internal/db"
Copy link
Contributor

Choose a reason for hiding this comment

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

I've done the db conflicts with db dance enough that I'm fine with it.

`, &j, jID); err != nil {
return nil, errors.Wrap(err, "querying job")
func JobByID(ctx context.Context, jobID model.JobID) (*model.Job, error) {
j := model.Job{}
Copy link
Contributor

Choose a reason for hiding this comment

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

style nit: https://github.com/uber-go/guide/blob/master/style.md#use-var-for-zero-value-structs

note, all style is up for discussion so if you disagree don't hesitate

j := model.Job{}
err := Bun().NewSelect().Model(&j).
Where("job_id = ?", jobID).
Scan(context.TODO())
Copy link
Contributor

Choose a reason for hiding this comment

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

use the ctx that is passed.

require.NoError(t, err, "failed to add job")

// Retrieve it back and make sure the mapping is exhaustive.
jOut, err := db.JobByID(jID)
jOut, err := JobByID(context.TODO(), jID)
Copy link
Contributor

Choose a reason for hiding this comment

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

it is fine to use context.Background() for tests. so the TODOs are all just real TODOs.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've never run into this issue with a rebase, though maybe you did something slightly differently. Sounds plausible this is some artifact of git process though.

@stoksc stoksc force-pushed the kunapuli/bunify-postres-jobs branch from e31ab2c to 644bedb Compare February 21, 2024 21:51
Copy link

codecov bot commented Feb 21, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (bccdf0c) 47.47% compared to head (8458d20) 47.47%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8858      +/-   ##
==========================================
- Coverage   47.47%   47.47%   -0.01%     
==========================================
  Files        1066     1066              
  Lines      170207   170209       +2     
  Branches     2243     2241       -2     
==========================================
  Hits        80812    80812              
- Misses      89237    89239       +2     
  Partials      158      158              
Flag Coverage Δ
backend 43.06% <65.71%> (-0.01%) ⬇️
harness 63.74% <ø> (ø)
web 42.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
master/internal/db/postgres_jobs.go 91.30% <92.30%> (-3.94%) ⬇️
master/internal/rm/kubernetesrm/resource_pool.go 0.00% <0.00%> (ø)
master/internal/api_checkpoint.go 64.72% <71.42%> (ø)
master/internal/command/command.go 67.82% <71.42%> (ø)
master/internal/rm/agentrm/resource_pool.go 25.16% <0.00%> (ø)
master/internal/experiment.go 26.70% <20.00%> (ø)

... and 1 file with indirect coverage changes

@kkunapuli kkunapuli merged commit 03b9b30 into main Feb 22, 2024
72 of 86 checks passed
@kkunapuli kkunapuli deleted the kunapuli/bunify-postres-jobs branch February 22, 2024 15:13
maxrussell pushed a commit that referenced this pull request Mar 21, 2024
* chore: bunify postgres_jobs.go

* attempt to restore proto changes

* trying again to restore file

* PR feedback: use var for empty struct and context.Background in tests

* retry ci tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants