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

optimization: step run table #888

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api-contracts/openapi/components/schemas/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ APIResourceMeta:
properties:
id:
type: string
description: "the id of this resource, in UUID format"
description: "the id of this resource, uuid or int"
example: bb214807-246e-43a5-a25d-41761d1cff9e
minLength: 0
maxLength: 36
Expand Down
3 changes: 1 addition & 2 deletions api-contracts/openapi/components/schemas/worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ WorkerLabel:
SemaphoreSlots:
properties:
stepRunId:
type: string
type: integer
description: The step run id.
format: uuid
actionId:
type: string
description: The action id.
Expand Down
3 changes: 1 addition & 2 deletions api-contracts/openapi/paths/log/log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ withStepRun:
required: true
schema:
type: string
format: uuid
minLength: 36
minLength: 0
maxLength: 36
- description: The number to skip
in: query
Expand Down
18 changes: 6 additions & 12 deletions api-contracts/openapi/paths/step-run/step-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ stepRunScoped:
required: true
schema:
type: string
format: uuid
minLength: 36
minLength: 0
maxLength: 36
responses:
"200":
Expand Down Expand Up @@ -72,8 +71,7 @@ rerunStepRun:
required: true
schema:
type: string
format: uuid
minLength: 36
minLength: 0
maxLength: 36
requestBody:
content:
Expand Down Expand Up @@ -126,8 +124,7 @@ cancelStepRun:
required: true
schema:
type: string
format: uuid
minLength: 36
minLength: 0
maxLength: 36
responses:
"200":
Expand Down Expand Up @@ -173,8 +170,7 @@ getSchema:
required: true
schema:
type: string
format: uuid
minLength: 36
minLength: 0
maxLength: 36
responses:
"200":
Expand Down Expand Up @@ -216,8 +212,7 @@ listEvents:
required: true
schema:
type: string
format: uuid
minLength: 36
minLength: 0
maxLength: 36
- description: The number to skip
in: query
Expand Down Expand Up @@ -333,8 +328,7 @@ listArchives:
required: true
schema:
type: string
format: uuid
minLength: 36
minLength: 0
maxLength: 36
- description: The number to skip
in: query
Expand Down
6 changes: 2 additions & 4 deletions api-contracts/openapi/paths/workflow/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,7 @@ workflowRuns:
required: false
schema:
type: string
format: uuid
minLength: 36
minLength: 0
maxLength: 36
- description: A list of workflow run statuses to filter by
in: query
Expand Down Expand Up @@ -523,8 +522,7 @@ workflowRunsMetrics:
required: false
schema:
type: string
format: uuid
minLength: 36
minLength: 0
maxLength: 36
- description: A list of metadata key value pairs to filter by
in: query
Expand Down
5 changes: 1 addition & 4 deletions api/v1/server/handlers/logs/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/hatchet-dev/hatchet/api/v1/server/oas/transformers"
"github.com/hatchet-dev/hatchet/pkg/repository"
"github.com/hatchet-dev/hatchet/pkg/repository/prisma/db"
"github.com/hatchet-dev/hatchet/pkg/repository/prisma/sqlchelpers"
)

func (t *LogService) LogLineList(ctx echo.Context, request gen.LogLineListRequestObject) (gen.LogLineListResponseObject, error) {
Expand All @@ -20,12 +19,10 @@ func (t *LogService) LogLineList(ctx echo.Context, request gen.LogLineListReques
limit := 1000
offset := 0

stepRunId := sqlchelpers.UUIDToStr(stepRun.ID)

listOpts := &repository.ListLogsOpts{
Limit: &limit,
Offset: &offset,
StepRunId: &stepRunId,
StepRunId: &stepRun.ID,
}

if request.Params.Search != nil {
Expand Down
5 changes: 2 additions & 3 deletions api/v1/server/handlers/step-runs/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/hatchet-dev/hatchet/pkg/repository"
"github.com/hatchet-dev/hatchet/pkg/repository/prisma/db"
"github.com/hatchet-dev/hatchet/pkg/repository/prisma/dbsqlc"
"github.com/hatchet-dev/hatchet/pkg/repository/prisma/sqlchelpers"
)

func (t *StepRunService) StepRunUpdateCancel(ctx echo.Context, request gen.StepRunUpdateCancelRequestObject) (gen.StepRunUpdateCancelResponseObject, error) {
Expand All @@ -35,7 +34,7 @@ func (t *StepRunService) StepRunUpdateCancel(ctx echo.Context, request gen.StepR
engineStepRun, err := t.config.EngineRepository.StepRun().GetStepRunForEngine(
ctx.Request().Context(),
tenant.ID,
sqlchelpers.UUIDToStr(stepRun.ID),
stepRun.ID,
)

if err != nil {
Expand All @@ -57,7 +56,7 @@ func (t *StepRunService) StepRunUpdateCancel(ctx echo.Context, request gen.StepR

// wait for a short period of time
for i := 0; i < 5; i++ {
newStepRun, err := t.config.APIRepository.StepRun().GetStepRunById(sqlchelpers.UUIDToStr(stepRun.ID))
newStepRun, err := t.config.APIRepository.StepRun().GetStepRunById(stepRun.ID)

if err != nil {
return nil, fmt.Errorf("could not get step run: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion api/v1/server/handlers/step-runs/list_archives.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (t *StepRunService) StepRunListArchives(ctx echo.Context, request gen.StepR

listRes, err := t.config.APIRepository.StepRun().ListStepRunArchives(
sqlchelpers.UUIDToStr(stepRun.TenantId),
sqlchelpers.UUIDToStr(stepRun.ID),
stepRun.ID,
listOpts,
)

Expand Down
3 changes: 1 addition & 2 deletions api/v1/server/handlers/step-runs/list_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/hatchet-dev/hatchet/api/v1/server/oas/gen"
"github.com/hatchet-dev/hatchet/api/v1/server/oas/transformers"
"github.com/hatchet-dev/hatchet/pkg/repository"
"github.com/hatchet-dev/hatchet/pkg/repository/prisma/sqlchelpers"
)

func (t *StepRunService) StepRunListEvents(ctx echo.Context, request gen.StepRunListEventsRequestObject) (gen.StepRunListEventsResponseObject, error) {
Expand All @@ -33,7 +32,7 @@ func (t *StepRunService) StepRunListEvents(ctx echo.Context, request gen.StepRun
}

listRes, err := t.config.APIRepository.StepRun().ListStepRunEvents(
sqlchelpers.UUIDToStr(stepRun.ID),
stepRun.ID,
listOpts,
)

Expand Down
7 changes: 3 additions & 4 deletions api/v1/server/handlers/step-runs/rerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/hatchet-dev/hatchet/internal/services/shared/tasktypes"
"github.com/hatchet-dev/hatchet/pkg/repository"
"github.com/hatchet-dev/hatchet/pkg/repository/prisma/db"
"github.com/hatchet-dev/hatchet/pkg/repository/prisma/sqlchelpers"
)

func (t *StepRunService) StepRunUpdateRerun(ctx echo.Context, request gen.StepRunUpdateRerunRequestObject) (gen.StepRunUpdateRerunResponseObject, error) {
Expand All @@ -27,7 +26,7 @@ func (t *StepRunService) StepRunUpdateRerun(ctx echo.Context, request gen.StepRu
err := t.config.EngineRepository.StepRun().PreflightCheckReplayStepRun(
ctx.Request().Context(),
tenant.ID,
sqlchelpers.UUIDToStr(stepRun.ID),
stepRun.ID,
)

if err != nil {
Expand Down Expand Up @@ -81,7 +80,7 @@ func (t *StepRunService) StepRunUpdateRerun(ctx echo.Context, request gen.StepRu
engineStepRun, err := t.config.EngineRepository.StepRun().GetStepRunForEngine(
ctx.Request().Context(),
tenant.ID,
sqlchelpers.UUIDToStr(stepRun.ID),
stepRun.ID,
)

if err != nil {
Expand All @@ -103,7 +102,7 @@ func (t *StepRunService) StepRunUpdateRerun(ctx echo.Context, request gen.StepRu

// wait for a short period of time
for i := 0; i < 5; i++ {
result, err = t.config.APIRepository.StepRun().GetStepRunById(sqlchelpers.UUIDToStr(stepRun.ID))
result, err = t.config.APIRepository.StepRun().GetStepRunById(stepRun.ID)

if err != nil {
return nil, fmt.Errorf("could not get step run: %w", err)
Expand Down
11 changes: 9 additions & 2 deletions api/v1/server/handlers/workflows/list_runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -75,8 +76,14 @@ func (t *WorkflowService) WorkflowRunList(ctx echo.Context, request gen.Workflow
}

if request.Params.ParentStepRunId != nil {
parentStepRunIdStr := request.Params.ParentStepRunId.String()
listOpts.ParentStepRunId = &parentStepRunIdStr

parentStepRunIdInt, err := strconv.ParseInt(*request.Params.ParentStepRunId, 10, 64)

if err != nil {
return nil, fmt.Errorf("could not parse step run id: %w", err)
}

listOpts.ParentStepRunId = &parentStepRunIdInt
}

if request.Params.Statuses != nil {
Expand Down
11 changes: 9 additions & 2 deletions api/v1/server/handlers/workflows/metrics_runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package workflows
import (
"context"
"fmt"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -43,8 +44,14 @@ func (t *WorkflowService) WorkflowRunGetMetrics(ctx echo.Context, request gen.Wo
}

if request.Params.ParentStepRunId != nil {
parentStepRunIdStr := request.Params.ParentStepRunId.String()
listOpts.ParentStepRunId = &parentStepRunIdStr

parentStepRunIdInt, err := strconv.ParseInt(*request.Params.ParentStepRunId, 10, 64)

if err != nil {
return nil, fmt.Errorf("could not parse step run id: %w", err)
}

listOpts.ParentStepRunId = &parentStepRunIdInt
}

if request.Params.AdditionalMetadata != nil {
Expand Down
Loading
Loading