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

Port CQL client from Crystal #4

Merged
merged 11 commits into from
Dec 17, 2024
Merged
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
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ go 1.23.1
require (
github.com/DataDog/datadog-api-client-go/v2 v2.33.0
github.com/DataDog/datadog-go/v5 v5.5.0
github.com/gocql/gocql v0.0.0-20211015133455-b225f9b53fa1
github.com/samber/slog-datadog/v2 v2.8.0
github.com/samber/slog-multi v1.2.4
github.com/scylladb/gocqlx/v3 v3.0.1
k8s.io/api v0.31.3
k8s.io/apimachinery v0.31.3
k8s.io/client-go v0.31.3
Expand All @@ -27,10 +29,12 @@ require (
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -40,6 +44,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/samber/lo v1.47.0 // indirect
github.com/samber/slog-common v0.17.0 // indirect
github.com/scylladb/go-reflectx v1.0.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/mod v0.17.0 // indirect
Expand Down
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw=
github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU=
github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand All @@ -28,11 +32,16 @@ github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1v
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/gocql/gocql v0.0.0-20211015133455-b225f9b53fa1 h1:px9qUCy/RNJNsfCam4m2IxWGxNuimkrioEF0vrrbPsg=
github.com/gocql/gocql v0.0.0-20211015133455-b225f9b53fa1/go.mod h1:3gM2c4D3AnkISwBxGnMMsS8Oy4y2lhbPRsH4xnJrHG8=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
Expand All @@ -45,12 +54,15 @@ github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8=
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
Expand Down Expand Up @@ -86,6 +98,10 @@ github.com/samber/slog-datadog/v2 v2.8.0 h1:U/8LCfACbzQuwkhrty5BA5isUI9a7IyQd++G
github.com/samber/slog-datadog/v2 v2.8.0/go.mod h1:9/OgtLqH2Jfner9ESWi0g4vg7+958xv6EdjATKGpHbM=
github.com/samber/slog-multi v1.2.4 h1:k9x3JAWKJFPKffx+oXZ8TasaNuorIW4tG+TXxkt6Ry4=
github.com/samber/slog-multi v1.2.4/go.mod h1:ACuZ5B6heK57TfMVkVknN2UZHoFfjCwRxR0Q2OXKHlo=
github.com/scylladb/go-reflectx v1.0.1 h1:b917wZM7189pZdlND9PbIJ6NQxfDPfBvUaQ7cjj1iZQ=
github.com/scylladb/go-reflectx v1.0.1/go.mod h1:rWnOfDIRWBGN0miMLIcoPt/Dhi2doCMZqwMCJ3KupFc=
github.com/scylladb/gocqlx/v3 v3.0.1 h1:JBvOUBz62LQ2lbIgJqQbwVMiDftbtrJSi63KVxvRYOQ=
github.com/scylladb/gocqlx/v3 v3.0.1/go.mod h1:EjbSZM0VR2a57ZUxCRQ3v3CSoWIkH1WTMwxeDbFQorY=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
Expand Down
45 changes: 44 additions & 1 deletion pkg/apis/science/v1/types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check failure on line 1 in pkg/apis/science/v1/types.go

View workflow job for this annotation

GitHub Actions / Validate code

File test coverage below threshold

File test coverage below threshold: coverage: 42.9% (21/49); threshold: 70%
* Copyright (c) 2024. ECCO Data & AI Open-Source Project Maintainers.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,8 +19,10 @@
import (
"github.com/SneaksAndData/nexus-core/pkg/util"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"maps"
"math"
"slices"
)

Expand Down Expand Up @@ -57,7 +59,46 @@
FatalExitCodes []int32 `json:"fatalExitCodes,omitempty"`
Command string `json:"command"`
Args []string `json:"args,omitempty"`
MountDatadogSocket bool `json:"mountDatadogSocket,omitempty"`
MountDatadogSocket *bool `json:"mountDatadogSocket,omitempty"`
}

func (spec *MachineLearningAlgorithmSpec) Merge(other *MachineLearningAlgorithmSpec) *MachineLearningAlgorithmSpec {
cloned := spec.DeepCopy()
otherCloned := other.DeepCopy()

cloned.ImageTag = util.CoalesceString(otherCloned.ImageTag, cloned.ImageTag)
cloned.DeadlineSeconds = util.CoalescePointer(otherCloned.DeadlineSeconds, cloned.DeadlineSeconds)
cloned.MaximumRetries = util.CoalescePointer(otherCloned.MaximumRetries, cloned.MaximumRetries)
cloned.Env = util.CoalesceCollection[corev1.EnvVar](otherCloned.Env, cloned.Env)
cloned.EnvFrom = util.CoalesceCollection[corev1.EnvFromSource](otherCloned.EnvFrom, cloned.EnvFrom)
cloned.CpuLimit = util.CoalesceString(otherCloned.CpuLimit, cloned.CpuLimit)
cloned.MemoryLimit = util.CoalesceString(otherCloned.MemoryLimit, cloned.MemoryLimit)
cloned.WorkgroupHost = util.CoalesceString(otherCloned.WorkgroupHost, cloned.WorkgroupHost)
cloned.Workgroup = util.CoalesceString(otherCloned.Workgroup, cloned.Workgroup)
cloned.AdditionalWorkgroups = util.CoalesceCollection[string](otherCloned.AdditionalWorkgroups, cloned.AdditionalWorkgroups)
cloned.MonitoringParameters = util.CoalesceCollection[string](otherCloned.MonitoringParameters, cloned.MonitoringParameters)
cloned.CustomResources = util.CoalesceCollection[string](otherCloned.CustomResources, cloned.CustomResources)
cloned.SpeculativeAttempts = util.CoalescePointer(otherCloned.SpeculativeAttempts, cloned.SpeculativeAttempts)
cloned.TransientExitCodes = util.CoalesceCollection[int32](otherCloned.TransientExitCodes, cloned.TransientExitCodes)
cloned.FatalExitCodes = util.CoalesceCollection[int32](otherCloned.FatalExitCodes, cloned.FatalExitCodes)
cloned.Command = util.CoalesceString(otherCloned.Command, cloned.Command)
cloned.Args = util.CoalesceCollection[string](otherCloned.Args, cloned.Args)
cloned.MountDatadogSocket = util.CoalescePointer(otherCloned.MountDatadogSocket, cloned.MountDatadogSocket)

return cloned
}

func (spec *MachineLearningAlgorithmSpec) SubmissionCost(utilisation float64, rateCost int32) (*int32, error) {
cores, err := resource.ParseQuantity(spec.CpuLimit)
if err != nil {
return nil, err
}
var computedCost = int32(math.Round(cores.AsApproximateFloat64() * math.Log2(1+utilisation) * float64(rateCost)))
if computedCost < 0 {
return &rateCost, nil
}

return &computedCost, nil
}

// NewResourceReadyCondition creates a new condition indicating an overall Mla synchronisation success or failure
Expand Down Expand Up @@ -129,6 +170,8 @@
// Method from sample-controller
func Int32Ptr(i int32) *int32 { return &i }

func BoolPtr(b bool) *bool { return &b }

// GetSecretDiff resolves difference in secret references between two algorithms
func (mla *MachineLearningAlgorithm) GetSecretDiff(other *MachineLearningAlgorithm) []string {
return util.GetConfigResolverDiff(mla.GetSecretNames, other.GetSecretNames)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/science/v1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func newFakeMla(withConfigs bool) *MachineLearningAlgorithm {
FatalExitCodes: []int32{},
Command: "python",
Args: []string{"job.py", "--request-id 111-222-333 --arg1 true"},
MountDatadogSocket: true,
MountDatadogSocket: BoolPtr(true),
},
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/science/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/checkpoint/checkpoint_store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package checkpoint
71 changes: 71 additions & 0 deletions pkg/checkpoint/models/checkpointed_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package models

import (
v1 "github.com/SneaksAndData/nexus-core/pkg/apis/science/v1"
"github.com/scylladb/gocqlx/v3/table"
"time"
)

const (
LifecyclestageNew = "NEW"
LifecyclestageBuffered = "BUFFERED"
LifecyclestageRunning = "RUNNING"
LifecyclestageCompleted = "COMPLETED"
LifecyclestageFailed = "FAILED"
LifecyclestageScheduleTimeout = "SCHEDULING_TIMEOUT"
LifecyclestageDeadlineExceeded = "DEADLINE_EXCEEDED"
LifecyclestageCancelled = "CANCELLED"
)

type CheckpointedRequest struct {
Algorithm string `json:"algorithm"`
Id string `json:"id"`
LifecycleStage string `json:"lifecycle_stage"`
PayloadUri string `json:"payload_uri"`
ResultUri string `json:"result_uri"`
AlgorithmFailureCode string `json:"algorithm_failure_code"`
AlgorithmFailureCause string `json:"algorithm_failure_cause"`
AlgorithmFailureDetails string `json:"algorithm_failure_details"`
ReceivedByHost string `json:"received_by_host"`
ReceivedAt time.Time `json:"received_at"`
SentAt time.Time `json:"sent_at"`
AppliedConfiguration v1.MachineLearningAlgorithmSpec `json:"applied_configuration"`
ConfigurationOverrides v1.MachineLearningAlgorithmSpec `json:"configuration_overrides"`
MonitoringMetadata map[string][]string `json:"monitoring_metadata"`
ContentHash string `json:"content_hash"`
LastModified time.Time `json:"last_modified"`
Tag string `json:"tag"`
ApiVersion string `json:"api_version"`
JobUid string `json:"job_uid"`
ParentJob ParentJobReference `json:"parent_job"`
}

var CheckpointedRequestTable = table.New(table.Metadata{
Name: "checkpoints",
Columns: []string{
"algorithm",
"id",
"lifecycle_stage",
"payload_uri",
"result_uri",
"algorithm_failure_code",
"algorithm_failure_cause",
"algorithm_failure_details",
"received_by_host",
"received_at",
"sent_at",
"applied_configuration",
"configuration_overrides",
"monitoring_metadata",
"content_hash",
"last_modified",
"tag",
"api_version",
"parent_job",
},
PartKey: []string{
"algorithm",
"id",
},
SortKey: []string{},
})
3 changes: 3 additions & 0 deletions pkg/checkpoint/models/parent_job.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package models

type ParentJobReference struct{}
38 changes: 38 additions & 0 deletions pkg/checkpoint/models/submission_buffer_entry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package models

Check failure on line 1 in pkg/checkpoint/models/submission_buffer_entry.go

View workflow job for this annotation

GitHub Actions / Validate code

File test coverage below threshold

File test coverage below threshold: coverage: 0.0% (0/5); threshold: 70%

import (
"encoding/json"
"github.com/scylladb/gocqlx/v3/table"
batchv1 "k8s.io/api/batch/v1"
)

var SubmissionBufferTable = table.New(table.Metadata{
Name: "submission_buffer",
Columns: []string{
"algorithm",
"id",
"template",
},
PartKey: []string{
"algorithm",
"id",
},
SortKey: []string{},
})

type SubmissionBufferEntry struct {
Algorithm string `json:"algorithm"`
Id string `json:"id"`
Template string `json:"template,omitempty"`
}

// SubmissionTemplate returns a Kubernetes Job object generated for the algorithm request
func (sbe *SubmissionBufferEntry) SubmissionTemplate() (*batchv1.Job, error) {
var result *batchv1.Job
err := json.Unmarshal([]byte(sbe.Template), result)
if err != nil {
return nil, err
}

return result, nil
}
8 changes: 8 additions & 0 deletions pkg/checkpoint/payload/blob_store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package payload

import "time"

type BlobStore interface {
SaveTextAsBlob(text string) (string, error)
GetBlobUri(blobPath string, validFor time.Duration) (string, error)
}
60 changes: 60 additions & 0 deletions pkg/checkpoint/request/checkpoint_store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package request

Check failure on line 1 in pkg/checkpoint/request/checkpoint_store.go

View workflow job for this annotation

GitHub Actions / Validate code

File test coverage below threshold

File test coverage below threshold: coverage: 0.0% (0/22); threshold: 70%

import (
"github.com/SneaksAndData/nexus-core/pkg/checkpoint/models"
"github.com/SneaksAndData/nexus-core/pkg/util"
"github.com/scylladb/gocqlx/v3/qb"
"time"
)

type CheckpointStore interface {
UpsertCheckpoint(checkpoint *models.CheckpointedRequest) error
ReadCheckpoint(algorithm string, id string) (*models.CheckpointedRequest, error)
ReadCheckpoints(requestTag string) ([]models.CheckpointedRequest, error)
}

func (cqls *CqlStore) UpsertCheckpoint(checkpoint *models.CheckpointedRequest) error {
cloned, err := util.DeepClone(*checkpoint)
if err != nil {
cqls.logger.V(1).Error(err, "Error when serializing a checkpoint", "algorithm", checkpoint.Algorithm, "id", checkpoint.Id)
return err
}

cloned.LastModified = time.Now()

var query = cqls.cqlSession.Query(models.CheckpointedRequestTable.Insert()).BindStruct(*checkpoint)
if err := query.ExecRelease(); err != nil {
cqls.logger.V(1).Error(err, "Error when inserting a checkpoint", "algorithm", checkpoint.Algorithm, "id", checkpoint.Id)
return err
}

return nil
}

func (cqls *CqlStore) ReadCheckpoint(algorithm string, id string) (*models.CheckpointedRequest, error) {
result := &models.CheckpointedRequest{
Algorithm: algorithm,
Id: id,
}

var query = cqls.cqlSession.Query(models.CheckpointedRequestTable.Get()).BindStruct(*result)
if err := query.GetRelease(result); err != nil {
cqls.logger.V(1).Error(err, "Error when reading a checkpoint", "algorithm", algorithm, "id", id)
return nil, err
}

return result, nil
}

func (cqls *CqlStore) ReadCheckpoints(requestTag string) ([]models.CheckpointedRequest, error) {
var result []models.CheckpointedRequest
query := cqls.cqlSession.Query(models.CheckpointedRequestTable.Select()).BindMap(qb.M{
"tag": requestTag,
})
if err := query.SelectRelease(&result); err != nil {
cqls.logger.V(1).Error(err, "Error when reading checkpoints by tag", "tag", requestTag)
return nil, err
}

return result, nil
}
Loading
Loading