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 vai provider service #441

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
51 changes: 51 additions & 0 deletions provider-service/base/pkg/util/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package util

import (
"fmt"
"github.com/sky-uk/kfp-operator/argo/common"
"regexp"
"strings"
)

var FieldMatcher = regexp.MustCompile(`\S+`)

const OutputSeparator = " "
const StdNumFields = 5
const GoNumFields = 6

type CronSchedule struct {
fields []string
}

func (cs CronSchedule) PrintStandard() string {
return strings.Join(cs.fields[1:], OutputSeparator)
}

func (cs CronSchedule) PrintGo() string {
return strings.Join(cs.fields, OutputSeparator)
}

func ParseCron(schedule string) (CronSchedule, error) {
fields := FieldMatcher.FindAllString(schedule, -1)

if len(fields) > GoNumFields {
return CronSchedule{}, fmt.Errorf("too many fields for go cron schedule")
}
if len(fields) < StdNumFields {
return CronSchedule{}, fmt.Errorf("too few fields for standard cron schedule")
}

if len(fields) == StdNumFields {
return CronSchedule{
fields: append([]string{"0"}, fields...),
}, nil
} else {
return CronSchedule{
fields: fields,
}, nil
}
}

func ResourceNameFromNamespacedName(namespacedName common.NamespacedName) (string, error) {
return namespacedName.SeparatedString("-")
}
53 changes: 53 additions & 0 deletions provider-service/base/pkg/util/util_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//go:build unit

package util

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/sky-uk/kfp-operator/argo/common"
)

var _ = Context("cron parser", func() {
_ = Describe("should accept standard cron schedules", func() {
schedule, err := ParseCron(" a b c d e f ")
Expect(err).NotTo(HaveOccurred())
Expect(schedule.PrintGo()).To(Equal("a b c d e f"))
Expect(schedule.PrintStandard()).To(Equal("b c d e f"))
})

_ = Describe("should accept go cron schedules", func() {
schedule, err := ParseCron(" b c d e f ")
Expect(err).NotTo(HaveOccurred())
Expect(schedule.PrintGo()).To(Equal("0 b c d e f"))
Expect(schedule.PrintStandard()).To(Equal("b c d e f"))
})

_ = Describe("should not parse when fields are missing", func() {
_, err := ParseCron("* * * *")
Expect(err).To(HaveOccurred())
})

_ = Describe("should not parse when too many fields are present", func() {
_, err := ParseCron("* * * * * * *")
Expect(err).To(HaveOccurred())
})
})

var _ = Context("ResourceNameFromNamespacedName", func() {
_ = Describe("should return string separated with hyphens", func() {
result, err := ResourceNameFromNamespacedName(common.NamespacedName{
Namespace: "my-namespace",
Name: "my-name",
})
Expect(err).NotTo(HaveOccurred())
Expect(result).To(Equal("my-namespace-my-name"))
})

_ = Describe("should return error when namespace only set", func() {
_, err := ResourceNameFromNamespacedName(common.NamespacedName{
Namespace: "my-namespace",
})
Expect(err).To(HaveOccurred())
})
})
48 changes: 31 additions & 17 deletions provider-service/vai/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,39 @@ module github.com/sky-uk/kfp-operator/provider-service/vai
go 1.20

require (
cloud.google.com/go/aiplatform v1.48.0
cloud.google.com/go/aiplatform v1.54.0
cloud.google.com/go/pubsub v1.33.0
github.com/go-logr/logr v1.2.3
github.com/go-logr/logr v1.3.0
github.com/golang/mock v1.6.0
github.com/googleapis/gax-go/v2 v2.12.0
github.com/onsi/ginkgo/v2 v2.8.0
github.com/onsi/gomega v1.25.0
github.com/sky-uk/kfp-operator/argo/common v0.0.0-20241107144142-477120a374b9
github.com/sky-uk/kfp-operator/provider-service/base v0.0.0-00010101000000-000000000000
go.uber.org/zap v1.24.0
google.golang.org/api v0.136.0
google.golang.org/api v0.154.0
google.golang.org/protobuf v1.31.0
)

replace github.com/sky-uk/kfp-operator/provider-service/base => ../base

require (
cloud.google.com/go v0.110.6 // indirect
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go v0.110.10 // indirect
cloud.google.com/go/compute v1.23.3 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v1.1.1 // indirect
cloud.google.com/go/longrunning v0.5.1 // indirect
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/longrunning v0.5.4 // indirect
cloud.google.com/go/storage v1.36.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsouza/fake-gcs-server v1.47.7 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
Expand All @@ -41,11 +45,14 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.5 // indirect
github.com/google/renameio/v2 v2.0.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/gorilla/handlers v1.5.2 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -60,6 +67,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/xattr v0.4.9 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
Expand All @@ -73,22 +81,28 @@ require (
github.com/subosito/gotenv v1.4.2 // indirect
github.com/thanhpk/randstr v1.0.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 // indirect
google.golang.org/grpc v1.57.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/grpc v1.60.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading