feat(backend): Add support for converting v2 recurring run to scheduled workflow in template (#8521)

* add template support for v2 api

* copyright

* add v2 tests

* add proto files and generate clients

* update dockerfile

* update script

* refactor rec_run_id

* copyright info

* move string definition

* small fix to proto

* small refactor

* template takes model instead of api

* template changes

* convert to model in resource manager

* resolve conflicts

* fix integration test typos

* test

* test

* test

* testing

* temp change for debug

* temp change for debug 2

* temp change for debug 3

* temp change for debug 4

* temp change for debug 5

* temp change for debug 6

* revert resource manager change

* add print

* bring back integration tests

* folder name

* delete a file

* remove package debug

* fix bug

* print more variables

* add log

* add log

* small fix

* add log

* more logs

* add test

* add  logs

* test

* add another test

* use old function for Trigger convertion

* change modeltoCRDTrigger function

* removed V1 at the end of function name

* add comments

* removed unnecessary variable

* typo

* small change

* test

* remove logs for debugging

* small bug

* remove logs for debug

* nit and removed unused functions

* remove unused functions  and move var declararion
This commit is contained in:
Lingqing Gan 2022-12-21 14:43:13 -05:00 committed by GitHub
parent 579a02ca0d
commit 7e7e1afcb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
63 changed files with 9475 additions and 647 deletions

View File

@ -1,4 +1,4 @@
# Copyright 2021 The Kubeflow Authors
# Copyright 2021-2022 The Kubeflow Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -23,8 +23,8 @@ RUN ./hack/install-go-licenses.sh
# First, make sure there's no forbidden license.
RUN go-licenses check ./backend/src/apiserver
RUN go-licenses csv ./backend/src/apiserver > /tmp/licenses.csv && \
diff /tmp/licenses.csv backend/third_party_licenses/apiserver.csv && \
go-licenses save ./backend/src/apiserver --save_path /tmp/NOTICES
diff /tmp/licenses.csv backend/third_party_licenses/apiserver.csv && \
go-licenses save ./backend/src/apiserver --save_path /tmp/NOTICES
# 2. Compile preloaded pipeline samples
FROM python:3.7 as compiler

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Copyright 2018-2020 The Kubeflow Authors
# Copyright 2018-2022 The Kubeflow Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -153,12 +153,11 @@ if [ $API_VERSION -eq v1beta1 ]; then
sed -i -- 's/IntervalSecond int64 `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/job_model/api_periodic_schedule.go
sed -i -- 's/MaxConcurrency string `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/job_model/api_job.go
sed -i -- 's/IntervalSecond string `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/job_model/api_periodic_schedule.go
# TODO(gkcalat): Uncomment this block when recurring_run.proto is added.
# else
# sed -i -- 's/MaxConcurrency int64 `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/recurring_run_model/api_recurring_run.go
# sed -i -- 's/IntervalSecond int64 `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/recurring_run_model/api_periodic_schedule.go
# sed -i -- 's/MaxConcurrency string `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/recurring_run_model/api_recurring_run.go
# sed -i -- 's/IntervalSecond string `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/recurring_run_model/api_periodic_schedule.go
else
sed -i -- 's/MaxConcurrency int64 `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/recurring_run_model/api_recurring_run.go
sed -i -- 's/IntervalSecond int64 `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/recurring_run_model/api_periodic_schedule.go
sed -i -- 's/MaxConcurrency string `json:"max_concurrency,omitempty"`/MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/recurring_run_model/api_recurring_run.go
sed -i -- 's/IntervalSecond string `json:"interval_second,omitempty"`/IntervalSecond int64 `json:"interval_second,omitempty,string"`/g' backend/api/${API_VERSION}/go_http_client/recurring_run_model/api_periodic_schedule.go
fi
# Execute the //go:generate directives in the generated code.
cd backend/api && go generate ./...

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,363 @@
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: backend/api/v2beta1/recurring_run.proto
/*
Package go_client is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package go_client
import (
"context"
"io"
"net/http"
"github.com/golang/protobuf/proto"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/grpc-ecosystem/grpc-gateway/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/status"
)
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
func request_RecurringRunService_CreateRecurringRun_0(ctx context.Context, marshaler runtime.Marshaler, client RecurringRunServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq CreateRecurringRunRequest
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.RecurringRun); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.CreateRecurringRun(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_RecurringRunService_GetRecurringRun_0(ctx context.Context, marshaler runtime.Marshaler, client RecurringRunServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetRecurringRunRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["recurring_run_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "recurring_run_id")
}
protoReq.RecurringRunId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "recurring_run_id", err)
}
msg, err := client.GetRecurringRun(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
var (
filter_RecurringRunService_ListRecurringRuns_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_RecurringRunService_ListRecurringRuns_0(ctx context.Context, marshaler runtime.Marshaler, client RecurringRunServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq ListRecurringRunsRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_RecurringRunService_ListRecurringRuns_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.ListRecurringRuns(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_RecurringRunService_EnableRecurringRun_0(ctx context.Context, marshaler runtime.Marshaler, client RecurringRunServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq EnableRecurringRunRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["recurring_run_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "recurring_run_id")
}
protoReq.RecurringRunId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "recurring_run_id", err)
}
msg, err := client.EnableRecurringRun(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_RecurringRunService_DisableRecurringRun_0(ctx context.Context, marshaler runtime.Marshaler, client RecurringRunServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DisableRecurringRunRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["recurring_run_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "recurring_run_id")
}
protoReq.RecurringRunId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "recurring_run_id", err)
}
msg, err := client.DisableRecurringRun(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func request_RecurringRunService_DeleteRecurringRun_0(ctx context.Context, marshaler runtime.Marshaler, client RecurringRunServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DeleteRecurringRunRequest
var metadata runtime.ServerMetadata
var (
val string
ok bool
err error
_ = err
)
val, ok = pathParams["recurring_run_id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "recurring_run_id")
}
protoReq.RecurringRunId, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "recurring_run_id", err)
}
msg, err := client.DeleteRecurringRun(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
// RegisterRecurringRunServiceHandlerFromEndpoint is same as RegisterRecurringRunServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterRecurringRunServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterRecurringRunServiceHandler(ctx, mux, conn)
}
// RegisterRecurringRunServiceHandler registers the http handlers for service RecurringRunService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterRecurringRunServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterRecurringRunServiceHandlerClient(ctx, mux, NewRecurringRunServiceClient(conn))
}
// RegisterRecurringRunServiceHandlerClient registers the http handlers for service RecurringRunService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "RecurringRunServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "RecurringRunServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "RecurringRunServiceClient" to call the correct interceptors.
func RegisterRecurringRunServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RecurringRunServiceClient) error {
mux.Handle("POST", pattern_RecurringRunService_CreateRecurringRun_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_RecurringRunService_CreateRecurringRun_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_RecurringRunService_CreateRecurringRun_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_RecurringRunService_GetRecurringRun_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_RecurringRunService_GetRecurringRun_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_RecurringRunService_GetRecurringRun_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_RecurringRunService_ListRecurringRuns_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_RecurringRunService_ListRecurringRuns_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_RecurringRunService_ListRecurringRuns_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_RecurringRunService_EnableRecurringRun_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_RecurringRunService_EnableRecurringRun_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_RecurringRunService_EnableRecurringRun_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_RecurringRunService_DisableRecurringRun_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_RecurringRunService_DisableRecurringRun_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_RecurringRunService_DisableRecurringRun_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("DELETE", pattern_RecurringRunService_DeleteRecurringRun_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_RecurringRunService_DeleteRecurringRun_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_RecurringRunService_DeleteRecurringRun_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_RecurringRunService_CreateRecurringRun_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "v2beta1", "recurringruns"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_RecurringRunService_GetRecurringRun_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"apis", "v2beta1", "recurringruns", "recurring_run_id"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_RecurringRunService_ListRecurringRuns_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"apis", "v2beta1", "recurringruns"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_RecurringRunService_EnableRecurringRun_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"apis", "v2beta1", "recurringruns", "recurring_run_id"}, "enable", runtime.AssumeColonVerbOpt(true)))
pattern_RecurringRunService_DisableRecurringRun_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"apis", "v2beta1", "recurringruns", "recurring_run_id"}, "disable", runtime.AssumeColonVerbOpt(true)))
pattern_RecurringRunService_DeleteRecurringRun_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"apis", "v2beta1", "recurringruns", "recurring_run_id"}, "", runtime.AssumeColonVerbOpt(true)))
)
var (
forward_RecurringRunService_CreateRecurringRun_0 = runtime.ForwardResponseMessage
forward_RecurringRunService_GetRecurringRun_0 = runtime.ForwardResponseMessage
forward_RecurringRunService_ListRecurringRuns_0 = runtime.ForwardResponseMessage
forward_RecurringRunService_EnableRecurringRun_0 = runtime.ForwardResponseMessage
forward_RecurringRunService_DisableRecurringRun_0 = runtime.ForwardResponseMessage
forward_RecurringRunService_DeleteRecurringRun_0 = runtime.ForwardResponseMessage
)

View File

@ -0,0 +1,117 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_client
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
httptransport "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
"github.com/kubeflow/pipelines/backend/api/v2beta1/go_http_client/recurring_run_client/recurring_run_service"
)
// Default recurring run HTTP client.
var Default = NewHTTPClient(nil)
const (
// DefaultHost is the default Host
// found in Meta (info) section of spec file
DefaultHost string = "localhost"
// DefaultBasePath is the default BasePath
// found in Meta (info) section of spec file
DefaultBasePath string = "/"
)
// DefaultSchemes are the default schemes found in Meta (info) section of spec file
var DefaultSchemes = []string{"http", "https"}
// NewHTTPClient creates a new recurring run HTTP client.
func NewHTTPClient(formats strfmt.Registry) *RecurringRun {
return NewHTTPClientWithConfig(formats, nil)
}
// NewHTTPClientWithConfig creates a new recurring run HTTP client,
// using a customizable transport config.
func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *RecurringRun {
// ensure nullable parameters have default
if cfg == nil {
cfg = DefaultTransportConfig()
}
// create transport and client
transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes)
return New(transport, formats)
}
// New creates a new recurring run client
func New(transport runtime.ClientTransport, formats strfmt.Registry) *RecurringRun {
// ensure nullable parameters have default
if formats == nil {
formats = strfmt.Default
}
cli := new(RecurringRun)
cli.Transport = transport
cli.RecurringRunService = recurring_run_service.New(transport, formats)
return cli
}
// DefaultTransportConfig creates a TransportConfig with the
// default settings taken from the meta section of the spec file.
func DefaultTransportConfig() *TransportConfig {
return &TransportConfig{
Host: DefaultHost,
BasePath: DefaultBasePath,
Schemes: DefaultSchemes,
}
}
// TransportConfig contains the transport related info,
// found in the meta section of the spec file.
type TransportConfig struct {
Host string
BasePath string
Schemes []string
}
// WithHost overrides the default host,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithHost(host string) *TransportConfig {
cfg.Host = host
return cfg
}
// WithBasePath overrides the default basePath,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig {
cfg.BasePath = basePath
return cfg
}
// WithSchemes overrides the default schemes,
// provided by the meta section of the spec file.
func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig {
cfg.Schemes = schemes
return cfg
}
// RecurringRun is a client for recurring run
type RecurringRun struct {
RecurringRunService *recurring_run_service.Client
Transport runtime.ClientTransport
}
// SetTransport changes the transport on the client and all its subresources
func (c *RecurringRun) SetTransport(transport runtime.ClientTransport) {
c.Transport = transport
c.RecurringRunService.SetTransport(transport)
}

View File

@ -0,0 +1,139 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
recurring_run_model "github.com/kubeflow/pipelines/backend/api/v2beta1/go_http_client/recurring_run_model"
)
// NewCreateRecurringRunParams creates a new CreateRecurringRunParams object
// with the default values initialized.
func NewCreateRecurringRunParams() *CreateRecurringRunParams {
var ()
return &CreateRecurringRunParams{
timeout: cr.DefaultTimeout,
}
}
// NewCreateRecurringRunParamsWithTimeout creates a new CreateRecurringRunParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewCreateRecurringRunParamsWithTimeout(timeout time.Duration) *CreateRecurringRunParams {
var ()
return &CreateRecurringRunParams{
timeout: timeout,
}
}
// NewCreateRecurringRunParamsWithContext creates a new CreateRecurringRunParams object
// with the default values initialized, and the ability to set a context for a request
func NewCreateRecurringRunParamsWithContext(ctx context.Context) *CreateRecurringRunParams {
var ()
return &CreateRecurringRunParams{
Context: ctx,
}
}
// NewCreateRecurringRunParamsWithHTTPClient creates a new CreateRecurringRunParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewCreateRecurringRunParamsWithHTTPClient(client *http.Client) *CreateRecurringRunParams {
var ()
return &CreateRecurringRunParams{
HTTPClient: client,
}
}
/*CreateRecurringRunParams contains all the parameters to send to the API endpoint
for the create recurring run operation typically these are written to a http.Request
*/
type CreateRecurringRunParams struct {
/*Body
The recurring run to be created.
*/
Body *recurring_run_model.V2beta1RecurringRun
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the create recurring run params
func (o *CreateRecurringRunParams) WithTimeout(timeout time.Duration) *CreateRecurringRunParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the create recurring run params
func (o *CreateRecurringRunParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the create recurring run params
func (o *CreateRecurringRunParams) WithContext(ctx context.Context) *CreateRecurringRunParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the create recurring run params
func (o *CreateRecurringRunParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the create recurring run params
func (o *CreateRecurringRunParams) WithHTTPClient(client *http.Client) *CreateRecurringRunParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the create recurring run params
func (o *CreateRecurringRunParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithBody adds the body to the create recurring run params
func (o *CreateRecurringRunParams) WithBody(body *recurring_run_model.V2beta1RecurringRun) *CreateRecurringRunParams {
o.SetBody(body)
return o
}
// SetBody adds the body to the create recurring run params
func (o *CreateRecurringRunParams) SetBody(body *recurring_run_model.V2beta1RecurringRun) {
o.Body = body
}
// WriteToRequest writes these params to a swagger request
func (o *CreateRecurringRunParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.Body != nil {
if err := r.SetBodyParam(o.Body); err != nil {
return err
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,67 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
recurring_run_model "github.com/kubeflow/pipelines/backend/api/v2beta1/go_http_client/recurring_run_model"
)
// CreateRecurringRunReader is a Reader for the CreateRecurringRun structure.
type CreateRecurringRunReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *CreateRecurringRunReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewCreateRecurringRunOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("unknown error", response, response.Code())
}
}
// NewCreateRecurringRunOK creates a CreateRecurringRunOK with default headers values
func NewCreateRecurringRunOK() *CreateRecurringRunOK {
return &CreateRecurringRunOK{}
}
/*CreateRecurringRunOK handles this case with default header values.
A successful response.
*/
type CreateRecurringRunOK struct {
Payload *recurring_run_model.V2beta1RecurringRun
}
func (o *CreateRecurringRunOK) Error() string {
return fmt.Sprintf("[POST /apis/v2beta1/recurringruns][%d] createRecurringRunOK %+v", 200, o.Payload)
}
func (o *CreateRecurringRunOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(recurring_run_model.V2beta1RecurringRun)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,136 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
)
// NewDeleteRecurringRunParams creates a new DeleteRecurringRunParams object
// with the default values initialized.
func NewDeleteRecurringRunParams() *DeleteRecurringRunParams {
var ()
return &DeleteRecurringRunParams{
timeout: cr.DefaultTimeout,
}
}
// NewDeleteRecurringRunParamsWithTimeout creates a new DeleteRecurringRunParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewDeleteRecurringRunParamsWithTimeout(timeout time.Duration) *DeleteRecurringRunParams {
var ()
return &DeleteRecurringRunParams{
timeout: timeout,
}
}
// NewDeleteRecurringRunParamsWithContext creates a new DeleteRecurringRunParams object
// with the default values initialized, and the ability to set a context for a request
func NewDeleteRecurringRunParamsWithContext(ctx context.Context) *DeleteRecurringRunParams {
var ()
return &DeleteRecurringRunParams{
Context: ctx,
}
}
// NewDeleteRecurringRunParamsWithHTTPClient creates a new DeleteRecurringRunParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewDeleteRecurringRunParamsWithHTTPClient(client *http.Client) *DeleteRecurringRunParams {
var ()
return &DeleteRecurringRunParams{
HTTPClient: client,
}
}
/*DeleteRecurringRunParams contains all the parameters to send to the API endpoint
for the delete recurring run operation typically these are written to a http.Request
*/
type DeleteRecurringRunParams struct {
/*RecurringRunID
The ID of the recurring run to be deleted.
*/
RecurringRunID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the delete recurring run params
func (o *DeleteRecurringRunParams) WithTimeout(timeout time.Duration) *DeleteRecurringRunParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the delete recurring run params
func (o *DeleteRecurringRunParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the delete recurring run params
func (o *DeleteRecurringRunParams) WithContext(ctx context.Context) *DeleteRecurringRunParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the delete recurring run params
func (o *DeleteRecurringRunParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the delete recurring run params
func (o *DeleteRecurringRunParams) WithHTTPClient(client *http.Client) *DeleteRecurringRunParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the delete recurring run params
func (o *DeleteRecurringRunParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRecurringRunID adds the recurringRunID to the delete recurring run params
func (o *DeleteRecurringRunParams) WithRecurringRunID(recurringRunID string) *DeleteRecurringRunParams {
o.SetRecurringRunID(recurringRunID)
return o
}
// SetRecurringRunID adds the recurringRunId to the delete recurring run params
func (o *DeleteRecurringRunParams) SetRecurringRunID(recurringRunID string) {
o.RecurringRunID = recurringRunID
}
// WriteToRequest writes these params to a swagger request
func (o *DeleteRecurringRunParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param recurring_run_id
if err := r.SetPathParam("recurring_run_id", o.RecurringRunID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,63 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// DeleteRecurringRunReader is a Reader for the DeleteRecurringRun structure.
type DeleteRecurringRunReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DeleteRecurringRunReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewDeleteRecurringRunOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("unknown error", response, response.Code())
}
}
// NewDeleteRecurringRunOK creates a DeleteRecurringRunOK with default headers values
func NewDeleteRecurringRunOK() *DeleteRecurringRunOK {
return &DeleteRecurringRunOK{}
}
/*DeleteRecurringRunOK handles this case with default header values.
A successful response.
*/
type DeleteRecurringRunOK struct {
Payload interface{}
}
func (o *DeleteRecurringRunOK) Error() string {
return fmt.Sprintf("[DELETE /apis/v2beta1/recurringruns/{recurring_run_id}][%d] deleteRecurringRunOK %+v", 200, o.Payload)
}
func (o *DeleteRecurringRunOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,136 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
)
// NewDisableRecurringRunParams creates a new DisableRecurringRunParams object
// with the default values initialized.
func NewDisableRecurringRunParams() *DisableRecurringRunParams {
var ()
return &DisableRecurringRunParams{
timeout: cr.DefaultTimeout,
}
}
// NewDisableRecurringRunParamsWithTimeout creates a new DisableRecurringRunParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewDisableRecurringRunParamsWithTimeout(timeout time.Duration) *DisableRecurringRunParams {
var ()
return &DisableRecurringRunParams{
timeout: timeout,
}
}
// NewDisableRecurringRunParamsWithContext creates a new DisableRecurringRunParams object
// with the default values initialized, and the ability to set a context for a request
func NewDisableRecurringRunParamsWithContext(ctx context.Context) *DisableRecurringRunParams {
var ()
return &DisableRecurringRunParams{
Context: ctx,
}
}
// NewDisableRecurringRunParamsWithHTTPClient creates a new DisableRecurringRunParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewDisableRecurringRunParamsWithHTTPClient(client *http.Client) *DisableRecurringRunParams {
var ()
return &DisableRecurringRunParams{
HTTPClient: client,
}
}
/*DisableRecurringRunParams contains all the parameters to send to the API endpoint
for the disable recurring run operation typically these are written to a http.Request
*/
type DisableRecurringRunParams struct {
/*RecurringRunID
The ID of the recurring runs to be disabled.
*/
RecurringRunID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the disable recurring run params
func (o *DisableRecurringRunParams) WithTimeout(timeout time.Duration) *DisableRecurringRunParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the disable recurring run params
func (o *DisableRecurringRunParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the disable recurring run params
func (o *DisableRecurringRunParams) WithContext(ctx context.Context) *DisableRecurringRunParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the disable recurring run params
func (o *DisableRecurringRunParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the disable recurring run params
func (o *DisableRecurringRunParams) WithHTTPClient(client *http.Client) *DisableRecurringRunParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the disable recurring run params
func (o *DisableRecurringRunParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRecurringRunID adds the recurringRunID to the disable recurring run params
func (o *DisableRecurringRunParams) WithRecurringRunID(recurringRunID string) *DisableRecurringRunParams {
o.SetRecurringRunID(recurringRunID)
return o
}
// SetRecurringRunID adds the recurringRunId to the disable recurring run params
func (o *DisableRecurringRunParams) SetRecurringRunID(recurringRunID string) {
o.RecurringRunID = recurringRunID
}
// WriteToRequest writes these params to a swagger request
func (o *DisableRecurringRunParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param recurring_run_id
if err := r.SetPathParam("recurring_run_id", o.RecurringRunID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,63 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// DisableRecurringRunReader is a Reader for the DisableRecurringRun structure.
type DisableRecurringRunReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *DisableRecurringRunReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewDisableRecurringRunOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("unknown error", response, response.Code())
}
}
// NewDisableRecurringRunOK creates a DisableRecurringRunOK with default headers values
func NewDisableRecurringRunOK() *DisableRecurringRunOK {
return &DisableRecurringRunOK{}
}
/*DisableRecurringRunOK handles this case with default header values.
A successful response.
*/
type DisableRecurringRunOK struct {
Payload interface{}
}
func (o *DisableRecurringRunOK) Error() string {
return fmt.Sprintf("[POST /apis/v2beta1/recurringruns/{recurring_run_id}:disable][%d] disableRecurringRunOK %+v", 200, o.Payload)
}
func (o *DisableRecurringRunOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,136 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
)
// NewEnableRecurringRunParams creates a new EnableRecurringRunParams object
// with the default values initialized.
func NewEnableRecurringRunParams() *EnableRecurringRunParams {
var ()
return &EnableRecurringRunParams{
timeout: cr.DefaultTimeout,
}
}
// NewEnableRecurringRunParamsWithTimeout creates a new EnableRecurringRunParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewEnableRecurringRunParamsWithTimeout(timeout time.Duration) *EnableRecurringRunParams {
var ()
return &EnableRecurringRunParams{
timeout: timeout,
}
}
// NewEnableRecurringRunParamsWithContext creates a new EnableRecurringRunParams object
// with the default values initialized, and the ability to set a context for a request
func NewEnableRecurringRunParamsWithContext(ctx context.Context) *EnableRecurringRunParams {
var ()
return &EnableRecurringRunParams{
Context: ctx,
}
}
// NewEnableRecurringRunParamsWithHTTPClient creates a new EnableRecurringRunParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewEnableRecurringRunParamsWithHTTPClient(client *http.Client) *EnableRecurringRunParams {
var ()
return &EnableRecurringRunParams{
HTTPClient: client,
}
}
/*EnableRecurringRunParams contains all the parameters to send to the API endpoint
for the enable recurring run operation typically these are written to a http.Request
*/
type EnableRecurringRunParams struct {
/*RecurringRunID
The ID of the recurring runs to be enabled.
*/
RecurringRunID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the enable recurring run params
func (o *EnableRecurringRunParams) WithTimeout(timeout time.Duration) *EnableRecurringRunParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the enable recurring run params
func (o *EnableRecurringRunParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the enable recurring run params
func (o *EnableRecurringRunParams) WithContext(ctx context.Context) *EnableRecurringRunParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the enable recurring run params
func (o *EnableRecurringRunParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the enable recurring run params
func (o *EnableRecurringRunParams) WithHTTPClient(client *http.Client) *EnableRecurringRunParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the enable recurring run params
func (o *EnableRecurringRunParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRecurringRunID adds the recurringRunID to the enable recurring run params
func (o *EnableRecurringRunParams) WithRecurringRunID(recurringRunID string) *EnableRecurringRunParams {
o.SetRecurringRunID(recurringRunID)
return o
}
// SetRecurringRunID adds the recurringRunId to the enable recurring run params
func (o *EnableRecurringRunParams) SetRecurringRunID(recurringRunID string) {
o.RecurringRunID = recurringRunID
}
// WriteToRequest writes these params to a swagger request
func (o *EnableRecurringRunParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param recurring_run_id
if err := r.SetPathParam("recurring_run_id", o.RecurringRunID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,63 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// EnableRecurringRunReader is a Reader for the EnableRecurringRun structure.
type EnableRecurringRunReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *EnableRecurringRunReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewEnableRecurringRunOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("unknown error", response, response.Code())
}
}
// NewEnableRecurringRunOK creates a EnableRecurringRunOK with default headers values
func NewEnableRecurringRunOK() *EnableRecurringRunOK {
return &EnableRecurringRunOK{}
}
/*EnableRecurringRunOK handles this case with default header values.
A successful response.
*/
type EnableRecurringRunOK struct {
Payload interface{}
}
func (o *EnableRecurringRunOK) Error() string {
return fmt.Sprintf("[POST /apis/v2beta1/recurringruns/{recurring_run_id}:enable][%d] enableRecurringRunOK %+v", 200, o.Payload)
}
func (o *EnableRecurringRunOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
// response payload
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,136 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
strfmt "github.com/go-openapi/strfmt"
)
// NewGetRecurringRunParams creates a new GetRecurringRunParams object
// with the default values initialized.
func NewGetRecurringRunParams() *GetRecurringRunParams {
var ()
return &GetRecurringRunParams{
timeout: cr.DefaultTimeout,
}
}
// NewGetRecurringRunParamsWithTimeout creates a new GetRecurringRunParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewGetRecurringRunParamsWithTimeout(timeout time.Duration) *GetRecurringRunParams {
var ()
return &GetRecurringRunParams{
timeout: timeout,
}
}
// NewGetRecurringRunParamsWithContext creates a new GetRecurringRunParams object
// with the default values initialized, and the ability to set a context for a request
func NewGetRecurringRunParamsWithContext(ctx context.Context) *GetRecurringRunParams {
var ()
return &GetRecurringRunParams{
Context: ctx,
}
}
// NewGetRecurringRunParamsWithHTTPClient creates a new GetRecurringRunParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewGetRecurringRunParamsWithHTTPClient(client *http.Client) *GetRecurringRunParams {
var ()
return &GetRecurringRunParams{
HTTPClient: client,
}
}
/*GetRecurringRunParams contains all the parameters to send to the API endpoint
for the get recurring run operation typically these are written to a http.Request
*/
type GetRecurringRunParams struct {
/*RecurringRunID
The ID of the recurring run to be retrieved.
*/
RecurringRunID string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the get recurring run params
func (o *GetRecurringRunParams) WithTimeout(timeout time.Duration) *GetRecurringRunParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the get recurring run params
func (o *GetRecurringRunParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the get recurring run params
func (o *GetRecurringRunParams) WithContext(ctx context.Context) *GetRecurringRunParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the get recurring run params
func (o *GetRecurringRunParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the get recurring run params
func (o *GetRecurringRunParams) WithHTTPClient(client *http.Client) *GetRecurringRunParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the get recurring run params
func (o *GetRecurringRunParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithRecurringRunID adds the recurringRunID to the get recurring run params
func (o *GetRecurringRunParams) WithRecurringRunID(recurringRunID string) *GetRecurringRunParams {
o.SetRecurringRunID(recurringRunID)
return o
}
// SetRecurringRunID adds the recurringRunId to the get recurring run params
func (o *GetRecurringRunParams) SetRecurringRunID(recurringRunID string) {
o.RecurringRunID = recurringRunID
}
// WriteToRequest writes these params to a swagger request
func (o *GetRecurringRunParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
// path param recurring_run_id
if err := r.SetPathParam("recurring_run_id", o.RecurringRunID); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,67 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
recurring_run_model "github.com/kubeflow/pipelines/backend/api/v2beta1/go_http_client/recurring_run_model"
)
// GetRecurringRunReader is a Reader for the GetRecurringRun structure.
type GetRecurringRunReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *GetRecurringRunReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewGetRecurringRunOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("unknown error", response, response.Code())
}
}
// NewGetRecurringRunOK creates a GetRecurringRunOK with default headers values
func NewGetRecurringRunOK() *GetRecurringRunOK {
return &GetRecurringRunOK{}
}
/*GetRecurringRunOK handles this case with default header values.
A successful response.
*/
type GetRecurringRunOK struct {
Payload *recurring_run_model.V2beta1RecurringRun
}
func (o *GetRecurringRunOK) Error() string {
return fmt.Sprintf("[GET /apis/v2beta1/recurringruns/{recurring_run_id}][%d] getRecurringRunOK %+v", 200, o.Payload)
}
func (o *GetRecurringRunOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(recurring_run_model.V2beta1RecurringRun)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,314 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"net/http"
"time"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
cr "github.com/go-openapi/runtime/client"
"github.com/go-openapi/swag"
strfmt "github.com/go-openapi/strfmt"
)
// NewListRecurringRunsParams creates a new ListRecurringRunsParams object
// with the default values initialized.
func NewListRecurringRunsParams() *ListRecurringRunsParams {
var ()
return &ListRecurringRunsParams{
timeout: cr.DefaultTimeout,
}
}
// NewListRecurringRunsParamsWithTimeout creates a new ListRecurringRunsParams object
// with the default values initialized, and the ability to set a timeout on a request
func NewListRecurringRunsParamsWithTimeout(timeout time.Duration) *ListRecurringRunsParams {
var ()
return &ListRecurringRunsParams{
timeout: timeout,
}
}
// NewListRecurringRunsParamsWithContext creates a new ListRecurringRunsParams object
// with the default values initialized, and the ability to set a context for a request
func NewListRecurringRunsParamsWithContext(ctx context.Context) *ListRecurringRunsParams {
var ()
return &ListRecurringRunsParams{
Context: ctx,
}
}
// NewListRecurringRunsParamsWithHTTPClient creates a new ListRecurringRunsParams object
// with the default values initialized, and the ability to set a custom HTTPClient for a request
func NewListRecurringRunsParamsWithHTTPClient(client *http.Client) *ListRecurringRunsParams {
var ()
return &ListRecurringRunsParams{
HTTPClient: client,
}
}
/*ListRecurringRunsParams contains all the parameters to send to the API endpoint
for the list recurring runs operation typically these are written to a http.Request
*/
type ListRecurringRunsParams struct {
/*ExperimentID
The ID of the experiment to be retrieved. If empty, list recurring runs across all experiments.
*/
ExperimentID *string
/*Filter
A url-encoded, JSON-serialized Filter protocol buffer (see
[filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)).
*/
Filter *string
/*Namespace
Optional input. The namespace the recurring runs belong to.
*/
Namespace *string
/*PageSize
The number of recurring runs to be listed per page. If there are more recurring runs
than this number, the response message will contain a nextPageToken field you can use
to fetch the next page.
*/
PageSize *int32
/*PageToken
A page token to request the next page of results. The token is acquired
from the nextPageToken field of the response from the previous
ListRecurringRuns call or can be omitted when fetching the first page.
*/
PageToken *string
/*SortBy
Can be formatted as "field_name", "field_name asc" or "field_name desc".
Ascending by default.
*/
SortBy *string
timeout time.Duration
Context context.Context
HTTPClient *http.Client
}
// WithTimeout adds the timeout to the list recurring runs params
func (o *ListRecurringRunsParams) WithTimeout(timeout time.Duration) *ListRecurringRunsParams {
o.SetTimeout(timeout)
return o
}
// SetTimeout adds the timeout to the list recurring runs params
func (o *ListRecurringRunsParams) SetTimeout(timeout time.Duration) {
o.timeout = timeout
}
// WithContext adds the context to the list recurring runs params
func (o *ListRecurringRunsParams) WithContext(ctx context.Context) *ListRecurringRunsParams {
o.SetContext(ctx)
return o
}
// SetContext adds the context to the list recurring runs params
func (o *ListRecurringRunsParams) SetContext(ctx context.Context) {
o.Context = ctx
}
// WithHTTPClient adds the HTTPClient to the list recurring runs params
func (o *ListRecurringRunsParams) WithHTTPClient(client *http.Client) *ListRecurringRunsParams {
o.SetHTTPClient(client)
return o
}
// SetHTTPClient adds the HTTPClient to the list recurring runs params
func (o *ListRecurringRunsParams) SetHTTPClient(client *http.Client) {
o.HTTPClient = client
}
// WithExperimentID adds the experimentID to the list recurring runs params
func (o *ListRecurringRunsParams) WithExperimentID(experimentID *string) *ListRecurringRunsParams {
o.SetExperimentID(experimentID)
return o
}
// SetExperimentID adds the experimentId to the list recurring runs params
func (o *ListRecurringRunsParams) SetExperimentID(experimentID *string) {
o.ExperimentID = experimentID
}
// WithFilter adds the filter to the list recurring runs params
func (o *ListRecurringRunsParams) WithFilter(filter *string) *ListRecurringRunsParams {
o.SetFilter(filter)
return o
}
// SetFilter adds the filter to the list recurring runs params
func (o *ListRecurringRunsParams) SetFilter(filter *string) {
o.Filter = filter
}
// WithNamespace adds the namespace to the list recurring runs params
func (o *ListRecurringRunsParams) WithNamespace(namespace *string) *ListRecurringRunsParams {
o.SetNamespace(namespace)
return o
}
// SetNamespace adds the namespace to the list recurring runs params
func (o *ListRecurringRunsParams) SetNamespace(namespace *string) {
o.Namespace = namespace
}
// WithPageSize adds the pageSize to the list recurring runs params
func (o *ListRecurringRunsParams) WithPageSize(pageSize *int32) *ListRecurringRunsParams {
o.SetPageSize(pageSize)
return o
}
// SetPageSize adds the pageSize to the list recurring runs params
func (o *ListRecurringRunsParams) SetPageSize(pageSize *int32) {
o.PageSize = pageSize
}
// WithPageToken adds the pageToken to the list recurring runs params
func (o *ListRecurringRunsParams) WithPageToken(pageToken *string) *ListRecurringRunsParams {
o.SetPageToken(pageToken)
return o
}
// SetPageToken adds the pageToken to the list recurring runs params
func (o *ListRecurringRunsParams) SetPageToken(pageToken *string) {
o.PageToken = pageToken
}
// WithSortBy adds the sortBy to the list recurring runs params
func (o *ListRecurringRunsParams) WithSortBy(sortBy *string) *ListRecurringRunsParams {
o.SetSortBy(sortBy)
return o
}
// SetSortBy adds the sortBy to the list recurring runs params
func (o *ListRecurringRunsParams) SetSortBy(sortBy *string) {
o.SortBy = sortBy
}
// WriteToRequest writes these params to a swagger request
func (o *ListRecurringRunsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
if err := r.SetTimeout(o.timeout); err != nil {
return err
}
var res []error
if o.ExperimentID != nil {
// query param experiment_id
var qrExperimentID string
if o.ExperimentID != nil {
qrExperimentID = *o.ExperimentID
}
qExperimentID := qrExperimentID
if qExperimentID != "" {
if err := r.SetQueryParam("experiment_id", qExperimentID); err != nil {
return err
}
}
}
if o.Filter != nil {
// query param filter
var qrFilter string
if o.Filter != nil {
qrFilter = *o.Filter
}
qFilter := qrFilter
if qFilter != "" {
if err := r.SetQueryParam("filter", qFilter); err != nil {
return err
}
}
}
if o.Namespace != nil {
// query param namespace
var qrNamespace string
if o.Namespace != nil {
qrNamespace = *o.Namespace
}
qNamespace := qrNamespace
if qNamespace != "" {
if err := r.SetQueryParam("namespace", qNamespace); err != nil {
return err
}
}
}
if o.PageSize != nil {
// query param page_size
var qrPageSize int32
if o.PageSize != nil {
qrPageSize = *o.PageSize
}
qPageSize := swag.FormatInt32(qrPageSize)
if qPageSize != "" {
if err := r.SetQueryParam("page_size", qPageSize); err != nil {
return err
}
}
}
if o.PageToken != nil {
// query param page_token
var qrPageToken string
if o.PageToken != nil {
qrPageToken = *o.PageToken
}
qPageToken := qrPageToken
if qPageToken != "" {
if err := r.SetQueryParam("page_token", qPageToken); err != nil {
return err
}
}
}
if o.SortBy != nil {
// query param sort_by
var qrSortBy string
if o.SortBy != nil {
qrSortBy = *o.SortBy
}
qSortBy := qrSortBy
if qSortBy != "" {
if err := r.SetQueryParam("sort_by", qSortBy); err != nil {
return err
}
}
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,67 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"fmt"
"io"
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
recurring_run_model "github.com/kubeflow/pipelines/backend/api/v2beta1/go_http_client/recurring_run_model"
)
// ListRecurringRunsReader is a Reader for the ListRecurringRuns structure.
type ListRecurringRunsReader struct {
formats strfmt.Registry
}
// ReadResponse reads a server response into the received o.
func (o *ListRecurringRunsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
switch response.Code() {
case 200:
result := NewListRecurringRunsOK()
if err := result.readResponse(response, consumer, o.formats); err != nil {
return nil, err
}
return result, nil
default:
return nil, runtime.NewAPIError("unknown error", response, response.Code())
}
}
// NewListRecurringRunsOK creates a ListRecurringRunsOK with default headers values
func NewListRecurringRunsOK() *ListRecurringRunsOK {
return &ListRecurringRunsOK{}
}
/*ListRecurringRunsOK handles this case with default header values.
A successful response.
*/
type ListRecurringRunsOK struct {
Payload *recurring_run_model.V2beta1ListRecurringRunsResponse
}
func (o *ListRecurringRunsOK) Error() string {
return fmt.Sprintf("[GET /apis/v2beta1/recurringruns][%d] listRecurringRunsOK %+v", 200, o.Payload)
}
func (o *ListRecurringRunsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
o.Payload = new(recurring_run_model.V2beta1ListRecurringRunsResponse)
// response payload
if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
return err
}
return nil
}

View File

@ -0,0 +1,198 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_service
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// New creates a new recurring run service API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client {
return &Client{transport: transport, formats: formats}
}
/*
Client for recurring run service API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
/*
CreateRecurringRun creates a new recurring run in an experiment given the experiment ID
*/
func (a *Client) CreateRecurringRun(params *CreateRecurringRunParams) (*CreateRecurringRunOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateRecurringRunParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "CreateRecurringRun",
Method: "POST",
PathPattern: "/apis/v2beta1/recurringruns",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &CreateRecurringRunReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*CreateRecurringRunOK), nil
}
/*
DeleteRecurringRun deletes a recurring run
*/
func (a *Client) DeleteRecurringRun(params *DeleteRecurringRunParams) (*DeleteRecurringRunOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteRecurringRunParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "DeleteRecurringRun",
Method: "DELETE",
PathPattern: "/apis/v2beta1/recurringruns/{recurring_run_id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &DeleteRecurringRunReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*DeleteRecurringRunOK), nil
}
/*
DisableRecurringRun stops a recurring run and all its associated runs the recurring run is not deleted
*/
func (a *Client) DisableRecurringRun(params *DisableRecurringRunParams) (*DisableRecurringRunOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewDisableRecurringRunParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "DisableRecurringRun",
Method: "POST",
PathPattern: "/apis/v2beta1/recurringruns/{recurring_run_id}:disable",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &DisableRecurringRunReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*DisableRecurringRunOK), nil
}
/*
EnableRecurringRun restarts a recurring run that was previously stopped all runs associated with the recurring run will continue
*/
func (a *Client) EnableRecurringRun(params *EnableRecurringRunParams) (*EnableRecurringRunOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewEnableRecurringRunParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "EnableRecurringRun",
Method: "POST",
PathPattern: "/apis/v2beta1/recurringruns/{recurring_run_id}:enable",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &EnableRecurringRunReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*EnableRecurringRunOK), nil
}
/*
GetRecurringRun finds a specific recurring run by ID
*/
func (a *Client) GetRecurringRun(params *GetRecurringRunParams) (*GetRecurringRunOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetRecurringRunParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "GetRecurringRun",
Method: "GET",
PathPattern: "/apis/v2beta1/recurringruns/{recurring_run_id}",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &GetRecurringRunReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*GetRecurringRunOK), nil
}
/*
ListRecurringRuns finds all recurring runs given experiment and namespace if experiment ID is not specified find all recurring runs across all experiments
*/
func (a *Client) ListRecurringRuns(params *ListRecurringRunsParams) (*ListRecurringRunsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewListRecurringRunsParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "ListRecurringRuns",
Method: "GET",
PathPattern: "/apis/v2beta1/recurringruns",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"http", "https"},
Params: params,
Reader: &ListRecurringRunsReader{formats: a.formats},
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*ListRecurringRunsOK), nil
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}

View File

@ -0,0 +1,65 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
// ProtobufNullValue `NullValue` is a singleton enumeration to represent the null value for the
// `Value` type union.
//
// The JSON representation for `NullValue` is JSON `null`.
//
// - NULL_VALUE: Null value.
// swagger:model protobufNullValue
type ProtobufNullValue string
const (
// ProtobufNullValueNULLVALUE captures enum value "NULL_VALUE"
ProtobufNullValueNULLVALUE ProtobufNullValue = "NULL_VALUE"
)
// for schema
var protobufNullValueEnum []interface{}
func init() {
var res []ProtobufNullValue
if err := json.Unmarshal([]byte(`["NULL_VALUE"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
protobufNullValueEnum = append(protobufNullValueEnum, v)
}
}
func (m ProtobufNullValue) validateProtobufNullValueEnum(path, location string, value ProtobufNullValue) error {
if err := validate.Enum(path, location, value, protobufNullValueEnum); err != nil {
return err
}
return nil
}
// Validate validates this protobuf null value
func (m ProtobufNullValue) Validate(formats strfmt.Registry) error {
var res []error
// value enum
if err := m.validateProtobufNullValueEnum("", "body", m); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,70 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
// RecurringRunMode Required input.
// User setting to enable or disable the recurring run.
// Only used for creation of recurring runs. Later updates use enable/disable API.
//
// - DISABLE: The recurring run won't schedule any run if disabled.
// swagger:model RecurringRunMode
type RecurringRunMode string
const (
// RecurringRunModeMODEUNSPECIFIED captures enum value "MODE_UNSPECIFIED"
RecurringRunModeMODEUNSPECIFIED RecurringRunMode = "MODE_UNSPECIFIED"
// RecurringRunModeENABLE captures enum value "ENABLE"
RecurringRunModeENABLE RecurringRunMode = "ENABLE"
// RecurringRunModeDISABLE captures enum value "DISABLE"
RecurringRunModeDISABLE RecurringRunMode = "DISABLE"
)
// for schema
var recurringRunModeEnum []interface{}
func init() {
var res []RecurringRunMode
if err := json.Unmarshal([]byte(`["MODE_UNSPECIFIED","ENABLE","DISABLE"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
recurringRunModeEnum = append(recurringRunModeEnum, v)
}
}
func (m RecurringRunMode) validateRecurringRunModeEnum(path, location string, value RecurringRunMode) error {
if err := validate.Enum(path, location, value, recurringRunModeEnum); err != nil {
return err
}
return nil
}
// Validate validates this recurring run mode
func (m RecurringRunMode) Validate(formats strfmt.Registry) error {
var res []error
// value enum
if err := m.validateRecurringRunModeEnum("", "body", m); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,93 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// V2beta1CronSchedule CronSchedule allow scheduling the recurring run with unix-like cron.
// swagger:model v2beta1CronSchedule
type V2beta1CronSchedule struct {
// The cron string. For details how to compose a cron, visit
// ttps://en.wikipedia.org/wiki/Cron
Cron string `json:"cron,omitempty"`
// The end time of the cron job.
// Format: date-time
EndTime strfmt.DateTime `json:"end_time,omitempty"`
// The start time of the cron job.
// Format: date-time
StartTime strfmt.DateTime `json:"start_time,omitempty"`
}
// Validate validates this v2beta1 cron schedule
func (m *V2beta1CronSchedule) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEndTime(formats); err != nil {
res = append(res, err)
}
if err := m.validateStartTime(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V2beta1CronSchedule) validateEndTime(formats strfmt.Registry) error {
if swag.IsZero(m.EndTime) { // not required
return nil
}
if err := validate.FormatOf("end_time", "body", "date-time", m.EndTime.String(), formats); err != nil {
return err
}
return nil
}
func (m *V2beta1CronSchedule) validateStartTime(formats strfmt.Registry) error {
if swag.IsZero(m.StartTime) { // not required
return nil
}
if err := validate.FormatOf("start_time", "body", "date-time", m.StartTime.String(), formats); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *V2beta1CronSchedule) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V2beta1CronSchedule) UnmarshalBinary(b []byte) error {
var res V2beta1CronSchedule
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,86 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"strconv"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
)
// V2beta1ListRecurringRunsResponse v2beta1 list recurring runs response
// swagger:model v2beta1ListRecurringRunsResponse
type V2beta1ListRecurringRunsResponse struct {
// The token to list the next page of recurring runs.
NextPageToken string `json:"next_page_token,omitempty"`
// A list of recurring runs returned.
RecurringRuns []*V2beta1RecurringRun `json:"recurringRuns"`
// The total number of recurring runs for the given query.
TotalSize int32 `json:"total_size,omitempty"`
}
// Validate validates this v2beta1 list recurring runs response
func (m *V2beta1ListRecurringRunsResponse) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateRecurringRuns(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V2beta1ListRecurringRunsResponse) validateRecurringRuns(formats strfmt.Registry) error {
if swag.IsZero(m.RecurringRuns) { // not required
return nil
}
for i := 0; i < len(m.RecurringRuns); i++ {
if swag.IsZero(m.RecurringRuns[i]) { // not required
continue
}
if m.RecurringRuns[i] != nil {
if err := m.RecurringRuns[i].Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("recurringRuns" + "." + strconv.Itoa(i))
}
return err
}
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V2beta1ListRecurringRunsResponse) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V2beta1ListRecurringRunsResponse) UnmarshalBinary(b []byte) error {
var res V2beta1ListRecurringRunsResponse
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,92 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// V2beta1PeriodicSchedule PeriodicSchedule allow scheduling the recurring run periodically with certain interval.
// swagger:model v2beta1PeriodicSchedule
type V2beta1PeriodicSchedule struct {
// The end time of the periodic recurring run.
// Format: date-time
EndTime strfmt.DateTime `json:"end_time,omitempty"`
// The time interval between the starting time of consecutive recurring runs.
IntervalSecond int64 `json:"interval_second,omitempty,string"`
// The start time of the periodic recurring run.
// Format: date-time
StartTime strfmt.DateTime `json:"start_time,omitempty"`
}
// Validate validates this v2beta1 periodic schedule
func (m *V2beta1PeriodicSchedule) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateEndTime(formats); err != nil {
res = append(res, err)
}
if err := m.validateStartTime(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V2beta1PeriodicSchedule) validateEndTime(formats strfmt.Registry) error {
if swag.IsZero(m.EndTime) { // not required
return nil
}
if err := validate.FormatOf("end_time", "body", "date-time", m.EndTime.String(), formats); err != nil {
return err
}
return nil
}
func (m *V2beta1PeriodicSchedule) validateStartTime(formats strfmt.Registry) error {
if swag.IsZero(m.StartTime) { // not required
return nil
}
if err := validate.FormatOf("start_time", "body", "date-time", m.StartTime.String(), formats); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *V2beta1PeriodicSchedule) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V2beta1PeriodicSchedule) UnmarshalBinary(b []byte) error {
var res V2beta1PeriodicSchedule
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,224 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// V2beta1RecurringRun v2beta1 recurring run
// swagger:model v2beta1RecurringRun
type V2beta1RecurringRun struct {
// Output. The time this recurring run was created.
// Format: date-time
CreatedAt strfmt.DateTime `json:"created_at,omitempty"`
// Optional input field. Describes the purpose of the recurring run.
Description string `json:"description,omitempty"`
// Required input field. Recurring run name provided by user. Not unique.
DisplayName string `json:"display_name,omitempty"`
// In case any error happens retrieving a recurring run field, only recurring run ID
// and the error message is returned. Client has the flexibility of choosing
// how to handle the error. This is especially useful during listing call.
Error string `json:"error,omitempty"`
// ID of the experiment this recurring run belongs to.
ExperimentID string `json:"experiment_id,omitempty"`
// Required input field.
// Specifies how many runs can be executed concurrently. Range [1-10].
MaxConcurrency int64 `json:"max_concurrency,omitempty,string"`
// mode
Mode RecurringRunMode `json:"mode,omitempty"`
// Namespace this recurring run belongs to.
Namespace string `json:"namespace,omitempty"`
// Optional input field. Whether the recurring run should catch up if behind schedule.
// If true, the recurring run will only schedule the latest interval if behind schedule.
// If false, the recurring run will catch up on each past interval.
NoCatchup bool `json:"no_catchup,omitempty"`
// The ID of the pipeline user uploaded before.
PipelineID string `json:"pipeline_id,omitempty"`
// The pipeline spec.
PipelineSpec interface{} `json:"pipeline_spec,omitempty"`
// Output. Unique run ID generated by API server.
RecurringRunID string `json:"recurring_run_id,omitempty"`
// Runtime config of the pipeline.
RuntimeConfig *V2beta1RuntimeConfig `json:"runtime_config,omitempty"`
// Optional input field. Specifies which Kubernetes service account this recurring run uses.
ServiceAccount string `json:"service_account,omitempty"`
// status
Status V2beta1RecurringRunStatus `json:"status,omitempty"`
// Required input field.
// Specifies how a run is triggered. Support cron mode or periodic mode.
Trigger *V2beta1Trigger `json:"trigger,omitempty"`
// Output. The last time this recurring run was updated.
// Format: date-time
UpdatedAt strfmt.DateTime `json:"updated_at,omitempty"`
}
// Validate validates this v2beta1 recurring run
func (m *V2beta1RecurringRun) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCreatedAt(formats); err != nil {
res = append(res, err)
}
if err := m.validateMode(formats); err != nil {
res = append(res, err)
}
if err := m.validateRuntimeConfig(formats); err != nil {
res = append(res, err)
}
if err := m.validateStatus(formats); err != nil {
res = append(res, err)
}
if err := m.validateTrigger(formats); err != nil {
res = append(res, err)
}
if err := m.validateUpdatedAt(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V2beta1RecurringRun) validateCreatedAt(formats strfmt.Registry) error {
if swag.IsZero(m.CreatedAt) { // not required
return nil
}
if err := validate.FormatOf("created_at", "body", "date-time", m.CreatedAt.String(), formats); err != nil {
return err
}
return nil
}
func (m *V2beta1RecurringRun) validateMode(formats strfmt.Registry) error {
if swag.IsZero(m.Mode) { // not required
return nil
}
if err := m.Mode.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("mode")
}
return err
}
return nil
}
func (m *V2beta1RecurringRun) validateRuntimeConfig(formats strfmt.Registry) error {
if swag.IsZero(m.RuntimeConfig) { // not required
return nil
}
if m.RuntimeConfig != nil {
if err := m.RuntimeConfig.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("runtime_config")
}
return err
}
}
return nil
}
func (m *V2beta1RecurringRun) validateStatus(formats strfmt.Registry) error {
if swag.IsZero(m.Status) { // not required
return nil
}
if err := m.Status.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("status")
}
return err
}
return nil
}
func (m *V2beta1RecurringRun) validateTrigger(formats strfmt.Registry) error {
if swag.IsZero(m.Trigger) { // not required
return nil
}
if m.Trigger != nil {
if err := m.Trigger.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("trigger")
}
return err
}
}
return nil
}
func (m *V2beta1RecurringRun) validateUpdatedAt(formats strfmt.Registry) error {
if swag.IsZero(m.UpdatedAt) { // not required
return nil
}
if err := validate.FormatOf("updated_at", "body", "date-time", m.UpdatedAt.String(), formats); err != nil {
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *V2beta1RecurringRun) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V2beta1RecurringRun) UnmarshalBinary(b []byte) error {
var res V2beta1RecurringRun
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,66 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"encoding/json"
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)
// V2beta1RecurringRunStatus Output. The status of the recurring run.
// swagger:model v2beta1RecurringRunStatus
type V2beta1RecurringRunStatus string
const (
// V2beta1RecurringRunStatusSTATUSUNSPECIFIED captures enum value "STATUS_UNSPECIFIED"
V2beta1RecurringRunStatusSTATUSUNSPECIFIED V2beta1RecurringRunStatus = "STATUS_UNSPECIFIED"
// V2beta1RecurringRunStatusENABLED captures enum value "ENABLED"
V2beta1RecurringRunStatusENABLED V2beta1RecurringRunStatus = "ENABLED"
// V2beta1RecurringRunStatusDISABLED captures enum value "DISABLED"
V2beta1RecurringRunStatusDISABLED V2beta1RecurringRunStatus = "DISABLED"
)
// for schema
var v2beta1RecurringRunStatusEnum []interface{}
func init() {
var res []V2beta1RecurringRunStatus
if err := json.Unmarshal([]byte(`["STATUS_UNSPECIFIED","ENABLED","DISABLED"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
v2beta1RecurringRunStatusEnum = append(v2beta1RecurringRunStatusEnum, v)
}
}
func (m V2beta1RecurringRunStatus) validateV2beta1RecurringRunStatusEnum(path, location string, value V2beta1RecurringRunStatus) error {
if err := validate.Enum(path, location, value, v2beta1RecurringRunStatusEnum); err != nil {
return err
}
return nil
}
// Validate validates this v2beta1 recurring run status
func (m V2beta1RecurringRunStatus) Validate(formats strfmt.Registry) error {
var res []error
// value enum
if err := m.validateV2beta1RecurringRunStatusEnum("", "body", m); err != nil {
return err
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@ -0,0 +1,50 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// V2beta1RuntimeConfig The runtime config of a run or recurring run.
// swagger:model v2beta1RuntimeConfig
type V2beta1RuntimeConfig struct {
// The runtime parameters. The parameters will be used to replace
// the placeholders at runtime.
Parameters map[string]interface{} `json:"parameters,omitempty"`
// A path in a object store bucket which will be treated as the root
// output directory of this run. It is used by the system to
// generate the paths of output artifacts.
// Ref:(https://www.kubeflow.org/docs/components/pipelines/pipeline-root/)
PipelineRoot string `json:"pipeline_root,omitempty"`
}
// Validate validates this v2beta1 runtime config
func (m *V2beta1RuntimeConfig) Validate(formats strfmt.Registry) error {
return nil
}
// MarshalBinary interface implementation
func (m *V2beta1RuntimeConfig) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V2beta1RuntimeConfig) UnmarshalBinary(b []byte) error {
var res V2beta1RuntimeConfig
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,96 @@
// Code generated by go-swagger; DO NOT EDIT.
package recurring_run_model
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
)
// V2beta1Trigger Trigger defines what starts a pipeline run.
// swagger:model v2beta1Trigger
type V2beta1Trigger struct {
// cron schedule
CronSchedule *V2beta1CronSchedule `json:"cron_schedule,omitempty"`
// periodic schedule
PeriodicSchedule *V2beta1PeriodicSchedule `json:"periodic_schedule,omitempty"`
}
// Validate validates this v2beta1 trigger
func (m *V2beta1Trigger) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCronSchedule(formats); err != nil {
res = append(res, err)
}
if err := m.validatePeriodicSchedule(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *V2beta1Trigger) validateCronSchedule(formats strfmt.Registry) error {
if swag.IsZero(m.CronSchedule) { // not required
return nil
}
if m.CronSchedule != nil {
if err := m.CronSchedule.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("cron_schedule")
}
return err
}
}
return nil
}
func (m *V2beta1Trigger) validatePeriodicSchedule(formats strfmt.Registry) error {
if swag.IsZero(m.PeriodicSchedule) { // not required
return nil
}
if m.PeriodicSchedule != nil {
if err := m.PeriodicSchedule.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("periodic_schedule")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *V2beta1Trigger) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *V2beta1Trigger) UnmarshalBinary(b []byte) error {
var res V2beta1Trigger
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}

View File

@ -0,0 +1,10 @@
# RecurringRunMode
Required input. User setting to enable or disable the recurring run. Only used for creation of recurring runs. Later updates use enable/disable API. - DISABLE: The recurring run won't schedule any run if disabled.
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,384 @@
# kfp_server_api.RecurringRunServiceApi
All URIs are relative to *http://localhost*
Method | HTTP request | Description
------------- | ------------- | -------------
[**create_recurring_run**](RecurringRunServiceApi.md#create_recurring_run) | **POST** /apis/v2beta1/recurringruns | Creates a new recurring run in an experiment, given the experiment ID.
[**delete_recurring_run**](RecurringRunServiceApi.md#delete_recurring_run) | **DELETE** /apis/v2beta1/recurringruns/{recurring_run_id} | Deletes a recurring run.
[**disable_recurring_run**](RecurringRunServiceApi.md#disable_recurring_run) | **POST** /apis/v2beta1/recurringruns/{recurring_run_id}:disable | Stops a recurring run and all its associated runs. The recurring run is not deleted.
[**enable_recurring_run**](RecurringRunServiceApi.md#enable_recurring_run) | **POST** /apis/v2beta1/recurringruns/{recurring_run_id}:enable | Restarts a recurring run that was previously stopped. All runs associated with the recurring run will continue.
[**get_recurring_run**](RecurringRunServiceApi.md#get_recurring_run) | **GET** /apis/v2beta1/recurringruns/{recurring_run_id} | Finds a specific recurring run by ID.
[**list_recurring_runs**](RecurringRunServiceApi.md#list_recurring_runs) | **GET** /apis/v2beta1/recurringruns | Finds all recurring runs given experiment and namespace. If experiment ID is not specified, find all recurring runs across all experiments.
# **create_recurring_run**
> V2beta1RecurringRun create_recurring_run(body)
Creates a new recurring run in an experiment, given the experiment ID.
### Example
```python
from __future__ import print_function
import time
import kfp_server_api
from kfp_server_api.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = kfp_server_api.Configuration(
host = "http://localhost"
)
# Enter a context with an instance of the API client
with kfp_server_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = kfp_server_api.RecurringRunServiceApi(api_client)
body = kfp_server_api.V2beta1RecurringRun() # V2beta1RecurringRun | The recurring run to be created.
try:
# Creates a new recurring run in an experiment, given the experiment ID.
api_response = api_instance.create_recurring_run(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling RecurringRunServiceApi->create_recurring_run: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**body** | [**V2beta1RecurringRun**](V2beta1RecurringRun.md)| The recurring run to be created. |
### Return type
[**V2beta1RecurringRun**](V2beta1RecurringRun.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | A successful response. | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **delete_recurring_run**
> object delete_recurring_run(recurring_run_id)
Deletes a recurring run.
### Example
```python
from __future__ import print_function
import time
import kfp_server_api
from kfp_server_api.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = kfp_server_api.Configuration(
host = "http://localhost"
)
# Enter a context with an instance of the API client
with kfp_server_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = kfp_server_api.RecurringRunServiceApi(api_client)
recurring_run_id = 'recurring_run_id_example' # str | The ID of the recurring run to be deleted.
try:
# Deletes a recurring run.
api_response = api_instance.delete_recurring_run(recurring_run_id)
pprint(api_response)
except ApiException as e:
print("Exception when calling RecurringRunServiceApi->delete_recurring_run: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**recurring_run_id** | **str**| The ID of the recurring run to be deleted. |
### Return type
**object**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | A successful response. | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **disable_recurring_run**
> object disable_recurring_run(recurring_run_id)
Stops a recurring run and all its associated runs. The recurring run is not deleted.
### Example
```python
from __future__ import print_function
import time
import kfp_server_api
from kfp_server_api.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = kfp_server_api.Configuration(
host = "http://localhost"
)
# Enter a context with an instance of the API client
with kfp_server_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = kfp_server_api.RecurringRunServiceApi(api_client)
recurring_run_id = 'recurring_run_id_example' # str | The ID of the recurring runs to be disabled.
try:
# Stops a recurring run and all its associated runs. The recurring run is not deleted.
api_response = api_instance.disable_recurring_run(recurring_run_id)
pprint(api_response)
except ApiException as e:
print("Exception when calling RecurringRunServiceApi->disable_recurring_run: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**recurring_run_id** | **str**| The ID of the recurring runs to be disabled. |
### Return type
**object**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | A successful response. | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **enable_recurring_run**
> object enable_recurring_run(recurring_run_id)
Restarts a recurring run that was previously stopped. All runs associated with the recurring run will continue.
### Example
```python
from __future__ import print_function
import time
import kfp_server_api
from kfp_server_api.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = kfp_server_api.Configuration(
host = "http://localhost"
)
# Enter a context with an instance of the API client
with kfp_server_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = kfp_server_api.RecurringRunServiceApi(api_client)
recurring_run_id = 'recurring_run_id_example' # str | The ID of the recurring runs to be enabled.
try:
# Restarts a recurring run that was previously stopped. All runs associated with the recurring run will continue.
api_response = api_instance.enable_recurring_run(recurring_run_id)
pprint(api_response)
except ApiException as e:
print("Exception when calling RecurringRunServiceApi->enable_recurring_run: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**recurring_run_id** | **str**| The ID of the recurring runs to be enabled. |
### Return type
**object**
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | A successful response. | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **get_recurring_run**
> V2beta1RecurringRun get_recurring_run(recurring_run_id)
Finds a specific recurring run by ID.
### Example
```python
from __future__ import print_function
import time
import kfp_server_api
from kfp_server_api.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = kfp_server_api.Configuration(
host = "http://localhost"
)
# Enter a context with an instance of the API client
with kfp_server_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = kfp_server_api.RecurringRunServiceApi(api_client)
recurring_run_id = 'recurring_run_id_example' # str | The ID of the recurring run to be retrieved.
try:
# Finds a specific recurring run by ID.
api_response = api_instance.get_recurring_run(recurring_run_id)
pprint(api_response)
except ApiException as e:
print("Exception when calling RecurringRunServiceApi->get_recurring_run: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**recurring_run_id** | **str**| The ID of the recurring run to be retrieved. |
### Return type
[**V2beta1RecurringRun**](V2beta1RecurringRun.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | A successful response. | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
# **list_recurring_runs**
> V2beta1ListRecurringRunsResponse list_recurring_runs(page_token=page_token, page_size=page_size, sort_by=sort_by, namespace=namespace, filter=filter, experiment_id=experiment_id)
Finds all recurring runs given experiment and namespace. If experiment ID is not specified, find all recurring runs across all experiments.
### Example
```python
from __future__ import print_function
import time
import kfp_server_api
from kfp_server_api.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = kfp_server_api.Configuration(
host = "http://localhost"
)
# Enter a context with an instance of the API client
with kfp_server_api.ApiClient() as api_client:
# Create an instance of the API class
api_instance = kfp_server_api.RecurringRunServiceApi(api_client)
page_token = 'page_token_example' # str | A page token to request the next page of results. The token is acquired from the nextPageToken field of the response from the previous ListRecurringRuns call or can be omitted when fetching the first page. (optional)
page_size = 56 # int | The number of recurring runs to be listed per page. If there are more recurring runs than this number, the response message will contain a nextPageToken field you can use to fetch the next page. (optional)
sort_by = 'sort_by_example' # str | Can be formatted as \"field_name\", \"field_name asc\" or \"field_name desc\". Ascending by default. (optional)
namespace = 'namespace_example' # str | Optional input. The namespace the recurring runs belong to. (optional)
filter = 'filter_example' # str | A url-encoded, JSON-serialized Filter protocol buffer (see [filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)). (optional)
experiment_id = 'experiment_id_example' # str | The ID of the experiment to be retrieved. If empty, list recurring runs across all experiments. (optional)
try:
# Finds all recurring runs given experiment and namespace. If experiment ID is not specified, find all recurring runs across all experiments.
api_response = api_instance.list_recurring_runs(page_token=page_token, page_size=page_size, sort_by=sort_by, namespace=namespace, filter=filter, experiment_id=experiment_id)
pprint(api_response)
except ApiException as e:
print("Exception when calling RecurringRunServiceApi->list_recurring_runs: %s\n" % e)
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**page_token** | **str**| A page token to request the next page of results. The token is acquired from the nextPageToken field of the response from the previous ListRecurringRuns call or can be omitted when fetching the first page. | [optional]
**page_size** | **int**| The number of recurring runs to be listed per page. If there are more recurring runs than this number, the response message will contain a nextPageToken field you can use to fetch the next page. | [optional]
**sort_by** | **str**| Can be formatted as \&quot;field_name\&quot;, \&quot;field_name asc\&quot; or \&quot;field_name desc\&quot;. Ascending by default. | [optional]
**namespace** | **str**| Optional input. The namespace the recurring runs belong to. | [optional]
**filter** | **str**| A url-encoded, JSON-serialized Filter protocol buffer (see [filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)). | [optional]
**experiment_id** | **str**| The ID of the experiment to be retrieved. If empty, list recurring runs across all experiments. | [optional]
### Return type
[**V2beta1ListRecurringRunsResponse**](V2beta1ListRecurringRunsResponse.md)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: Not defined
- **Accept**: application/json
### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
**200** | A successful response. | - |
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

View File

@ -0,0 +1,13 @@
# V2beta1CronSchedule
CronSchedule allow scheduling the recurring run with unix-like cron.
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**start_time** | **datetime** | The start time of the cron job. | [optional]
**end_time** | **datetime** | The end time of the cron job. | [optional]
**cron** | **str** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# V2beta1ListRecurringRunsResponse
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**recurring_runs** | [**list[V2beta1RecurringRun]**](V2beta1RecurringRun.md) | A list of recurring runs returned. | [optional]
**total_size** | **int** | The total number of recurring runs for the given query. | [optional]
**next_page_token** | **str** | The token to list the next page of recurring runs. | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,13 @@
# V2beta1PeriodicSchedule
PeriodicSchedule allow scheduling the recurring run periodically with certain interval.
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**start_time** | **datetime** | The start time of the periodic recurring run. | [optional]
**end_time** | **datetime** | The end time of the periodic recurring run. | [optional]
**interval_second** | **str** | The time interval between the starting time of consecutive recurring runs. | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,26 @@
# V2beta1RecurringRun
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**recurring_run_id** | **str** | Output. Unique run ID generated by API server. | [optional]
**display_name** | **str** | Required input field. Recurring run name provided by user. Not unique. | [optional]
**description** | **str** | Optional input field. Describes the purpose of the recurring run. | [optional]
**pipeline_id** | **str** | The ID of the pipeline user uploaded before. | [optional]
**pipeline_spec** | [**object**](.md) | The pipeline spec. | [optional]
**runtime_config** | [**V2beta1RuntimeConfig**](V2beta1RuntimeConfig.md) | | [optional]
**service_account** | **str** | Optional input field. Specifies which Kubernetes service account this recurring run uses. | [optional]
**max_concurrency** | **str** | Required input field. Specifies how many runs can be executed concurrently. Range [1-10]. | [optional]
**trigger** | [**V2beta1Trigger**](V2beta1Trigger.md) | | [optional]
**mode** | [**RecurringRunMode**](RecurringRunMode.md) | | [optional]
**created_at** | **datetime** | Output. The time this recurring run was created. | [optional]
**updated_at** | **datetime** | Output. The last time this recurring run was updated. | [optional]
**status** | [**V2beta1RecurringRunStatus**](V2beta1RecurringRunStatus.md) | | [optional]
**error** | **str** | In case any error happens retrieving a recurring run field, only recurring run ID and the error message is returned. Client has the flexibility of choosing how to handle the error. This is especially useful during listing call. | [optional]
**no_catchup** | **bool** | Optional input field. Whether the recurring run should catch up if behind schedule. If true, the recurring run will only schedule the latest interval if behind schedule. If false, the recurring run will catch up on each past interval. | [optional]
**namespace** | **str** | Namespace this recurring run belongs to. | [optional]
**experiment_id** | **str** | ID of the experiment this recurring run belongs to. | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,10 @@
# V2beta1RecurringRunStatus
Output. The status of the recurring run.
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,12 @@
# V2beta1Trigger
Trigger defines what starts a pipeline run.
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**cron_schedule** | [**V2beta1CronSchedule**](V2beta1CronSchedule.md) | | [optional]
**periodic_schedule** | [**V2beta1PeriodicSchedule**](V2beta1PeriodicSchedule.md) | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -0,0 +1,804 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import re # noqa: F401
# python 2 and python 3 compatibility library
import six
from kfp_server_api.api_client import ApiClient
from kfp_server_api.exceptions import ( # noqa: F401
ApiTypeError,
ApiValueError
)
class RecurringRunServiceApi(object):
"""NOTE: This class is auto generated by OpenAPI Generator
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
def __init__(self, api_client=None):
if api_client is None:
api_client = ApiClient()
self.api_client = api_client
def create_recurring_run(self, body, **kwargs): # noqa: E501
"""Creates a new recurring run in an experiment, given the experiment ID. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.create_recurring_run(body, async_req=True)
>>> result = thread.get()
:param body: The recurring run to be created. (required)
:type body: V2beta1RecurringRun
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: V2beta1RecurringRun
"""
kwargs['_return_http_data_only'] = True
return self.create_recurring_run_with_http_info(body, **kwargs) # noqa: E501
def create_recurring_run_with_http_info(self, body, **kwargs): # noqa: E501
"""Creates a new recurring run in an experiment, given the experiment ID. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.create_recurring_run_with_http_info(body, async_req=True)
>>> result = thread.get()
:param body: The recurring run to be created. (required)
:type body: V2beta1RecurringRun
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
and headers
:type _return_http_data_only: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:type _preload_content: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(V2beta1RecurringRun, status_code(int), headers(HTTPHeaderDict))
"""
local_var_params = locals()
all_params = [
'body'
]
all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout'
]
)
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method create_recurring_run" % key
)
local_var_params[key] = val
del local_var_params['kwargs']
# verify the required parameter 'body' is set
if self.api_client.client_side_validation and ('body' not in local_var_params or # noqa: E501
local_var_params['body'] is None): # noqa: E501
raise ApiValueError("Missing the required parameter `body` when calling `create_recurring_run`") # noqa: E501
collection_formats = {}
path_params = {}
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
if 'body' in local_var_params:
body_params = local_var_params['body']
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501
['application/json']) # noqa: E501
# Authentication setting
auth_settings = [] # noqa: E501
return self.api_client.call_api(
'/apis/v2beta1/recurringruns', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='V2beta1RecurringRun', # noqa: E501
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats=collection_formats)
def delete_recurring_run(self, recurring_run_id, **kwargs): # noqa: E501
"""Deletes a recurring run. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.delete_recurring_run(recurring_run_id, async_req=True)
>>> result = thread.get()
:param recurring_run_id: The ID of the recurring run to be deleted. (required)
:type recurring_run_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: object
"""
kwargs['_return_http_data_only'] = True
return self.delete_recurring_run_with_http_info(recurring_run_id, **kwargs) # noqa: E501
def delete_recurring_run_with_http_info(self, recurring_run_id, **kwargs): # noqa: E501
"""Deletes a recurring run. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.delete_recurring_run_with_http_info(recurring_run_id, async_req=True)
>>> result = thread.get()
:param recurring_run_id: The ID of the recurring run to be deleted. (required)
:type recurring_run_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
and headers
:type _return_http_data_only: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:type _preload_content: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(object, status_code(int), headers(HTTPHeaderDict))
"""
local_var_params = locals()
all_params = [
'recurring_run_id'
]
all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout'
]
)
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method delete_recurring_run" % key
)
local_var_params[key] = val
del local_var_params['kwargs']
# verify the required parameter 'recurring_run_id' is set
if self.api_client.client_side_validation and ('recurring_run_id' not in local_var_params or # noqa: E501
local_var_params['recurring_run_id'] is None): # noqa: E501
raise ApiValueError("Missing the required parameter `recurring_run_id` when calling `delete_recurring_run`") # noqa: E501
collection_formats = {}
path_params = {}
if 'recurring_run_id' in local_var_params:
path_params['recurring_run_id'] = local_var_params['recurring_run_id'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = [] # noqa: E501
return self.api_client.call_api(
'/apis/v2beta1/recurringruns/{recurring_run_id}', 'DELETE',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='object', # noqa: E501
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats=collection_formats)
def disable_recurring_run(self, recurring_run_id, **kwargs): # noqa: E501
"""Stops a recurring run and all its associated runs. The recurring run is not deleted. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.disable_recurring_run(recurring_run_id, async_req=True)
>>> result = thread.get()
:param recurring_run_id: The ID of the recurring runs to be disabled. (required)
:type recurring_run_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: object
"""
kwargs['_return_http_data_only'] = True
return self.disable_recurring_run_with_http_info(recurring_run_id, **kwargs) # noqa: E501
def disable_recurring_run_with_http_info(self, recurring_run_id, **kwargs): # noqa: E501
"""Stops a recurring run and all its associated runs. The recurring run is not deleted. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.disable_recurring_run_with_http_info(recurring_run_id, async_req=True)
>>> result = thread.get()
:param recurring_run_id: The ID of the recurring runs to be disabled. (required)
:type recurring_run_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
and headers
:type _return_http_data_only: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:type _preload_content: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(object, status_code(int), headers(HTTPHeaderDict))
"""
local_var_params = locals()
all_params = [
'recurring_run_id'
]
all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout'
]
)
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method disable_recurring_run" % key
)
local_var_params[key] = val
del local_var_params['kwargs']
# verify the required parameter 'recurring_run_id' is set
if self.api_client.client_side_validation and ('recurring_run_id' not in local_var_params or # noqa: E501
local_var_params['recurring_run_id'] is None): # noqa: E501
raise ApiValueError("Missing the required parameter `recurring_run_id` when calling `disable_recurring_run`") # noqa: E501
collection_formats = {}
path_params = {}
if 'recurring_run_id' in local_var_params:
path_params['recurring_run_id'] = local_var_params['recurring_run_id'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = [] # noqa: E501
return self.api_client.call_api(
'/apis/v2beta1/recurringruns/{recurring_run_id}:disable', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='object', # noqa: E501
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats=collection_formats)
def enable_recurring_run(self, recurring_run_id, **kwargs): # noqa: E501
"""Restarts a recurring run that was previously stopped. All runs associated with the recurring run will continue. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.enable_recurring_run(recurring_run_id, async_req=True)
>>> result = thread.get()
:param recurring_run_id: The ID of the recurring runs to be enabled. (required)
:type recurring_run_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: object
"""
kwargs['_return_http_data_only'] = True
return self.enable_recurring_run_with_http_info(recurring_run_id, **kwargs) # noqa: E501
def enable_recurring_run_with_http_info(self, recurring_run_id, **kwargs): # noqa: E501
"""Restarts a recurring run that was previously stopped. All runs associated with the recurring run will continue. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.enable_recurring_run_with_http_info(recurring_run_id, async_req=True)
>>> result = thread.get()
:param recurring_run_id: The ID of the recurring runs to be enabled. (required)
:type recurring_run_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
and headers
:type _return_http_data_only: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:type _preload_content: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(object, status_code(int), headers(HTTPHeaderDict))
"""
local_var_params = locals()
all_params = [
'recurring_run_id'
]
all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout'
]
)
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method enable_recurring_run" % key
)
local_var_params[key] = val
del local_var_params['kwargs']
# verify the required parameter 'recurring_run_id' is set
if self.api_client.client_side_validation and ('recurring_run_id' not in local_var_params or # noqa: E501
local_var_params['recurring_run_id'] is None): # noqa: E501
raise ApiValueError("Missing the required parameter `recurring_run_id` when calling `enable_recurring_run`") # noqa: E501
collection_formats = {}
path_params = {}
if 'recurring_run_id' in local_var_params:
path_params['recurring_run_id'] = local_var_params['recurring_run_id'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = [] # noqa: E501
return self.api_client.call_api(
'/apis/v2beta1/recurringruns/{recurring_run_id}:enable', 'POST',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='object', # noqa: E501
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats=collection_formats)
def get_recurring_run(self, recurring_run_id, **kwargs): # noqa: E501
"""Finds a specific recurring run by ID. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_recurring_run(recurring_run_id, async_req=True)
>>> result = thread.get()
:param recurring_run_id: The ID of the recurring run to be retrieved. (required)
:type recurring_run_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: V2beta1RecurringRun
"""
kwargs['_return_http_data_only'] = True
return self.get_recurring_run_with_http_info(recurring_run_id, **kwargs) # noqa: E501
def get_recurring_run_with_http_info(self, recurring_run_id, **kwargs): # noqa: E501
"""Finds a specific recurring run by ID. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.get_recurring_run_with_http_info(recurring_run_id, async_req=True)
>>> result = thread.get()
:param recurring_run_id: The ID of the recurring run to be retrieved. (required)
:type recurring_run_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
and headers
:type _return_http_data_only: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:type _preload_content: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(V2beta1RecurringRun, status_code(int), headers(HTTPHeaderDict))
"""
local_var_params = locals()
all_params = [
'recurring_run_id'
]
all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout'
]
)
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method get_recurring_run" % key
)
local_var_params[key] = val
del local_var_params['kwargs']
# verify the required parameter 'recurring_run_id' is set
if self.api_client.client_side_validation and ('recurring_run_id' not in local_var_params or # noqa: E501
local_var_params['recurring_run_id'] is None): # noqa: E501
raise ApiValueError("Missing the required parameter `recurring_run_id` when calling `get_recurring_run`") # noqa: E501
collection_formats = {}
path_params = {}
if 'recurring_run_id' in local_var_params:
path_params['recurring_run_id'] = local_var_params['recurring_run_id'] # noqa: E501
query_params = []
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = [] # noqa: E501
return self.api_client.call_api(
'/apis/v2beta1/recurringruns/{recurring_run_id}', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='V2beta1RecurringRun', # noqa: E501
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats=collection_formats)
def list_recurring_runs(self, **kwargs): # noqa: E501
"""Finds all recurring runs given experiment and namespace. If experiment ID is not specified, find all recurring runs across all experiments. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.list_recurring_runs(async_req=True)
>>> result = thread.get()
:param page_token: A page token to request the next page of results. The token is acquired from the nextPageToken field of the response from the previous ListRecurringRuns call or can be omitted when fetching the first page.
:type page_token: str
:param page_size: The number of recurring runs to be listed per page. If there are more recurring runs than this number, the response message will contain a nextPageToken field you can use to fetch the next page.
:type page_size: int
:param sort_by: Can be formatted as \"field_name\", \"field_name asc\" or \"field_name desc\". Ascending by default.
:type sort_by: str
:param namespace: Optional input. The namespace the recurring runs belong to.
:type namespace: str
:param filter: A url-encoded, JSON-serialized Filter protocol buffer (see [filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)).
:type filter: str
:param experiment_id: The ID of the experiment to be retrieved. If empty, list recurring runs across all experiments.
:type experiment_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: V2beta1ListRecurringRunsResponse
"""
kwargs['_return_http_data_only'] = True
return self.list_recurring_runs_with_http_info(**kwargs) # noqa: E501
def list_recurring_runs_with_http_info(self, **kwargs): # noqa: E501
"""Finds all recurring runs given experiment and namespace. If experiment ID is not specified, find all recurring runs across all experiments. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.list_recurring_runs_with_http_info(async_req=True)
>>> result = thread.get()
:param page_token: A page token to request the next page of results. The token is acquired from the nextPageToken field of the response from the previous ListRecurringRuns call or can be omitted when fetching the first page.
:type page_token: str
:param page_size: The number of recurring runs to be listed per page. If there are more recurring runs than this number, the response message will contain a nextPageToken field you can use to fetch the next page.
:type page_size: int
:param sort_by: Can be formatted as \"field_name\", \"field_name asc\" or \"field_name desc\". Ascending by default.
:type sort_by: str
:param namespace: Optional input. The namespace the recurring runs belong to.
:type namespace: str
:param filter: A url-encoded, JSON-serialized Filter protocol buffer (see [filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)).
:type filter: str
:param experiment_id: The ID of the experiment to be retrieved. If empty, list recurring runs across all experiments.
:type experiment_id: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _return_http_data_only: response data without head status code
and headers
:type _return_http_data_only: bool, optional
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
:type _preload_content: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(V2beta1ListRecurringRunsResponse, status_code(int), headers(HTTPHeaderDict))
"""
local_var_params = locals()
all_params = [
'page_token',
'page_size',
'sort_by',
'namespace',
'filter',
'experiment_id'
]
all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout'
]
)
for key, val in six.iteritems(local_var_params['kwargs']):
if key not in all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method list_recurring_runs" % key
)
local_var_params[key] = val
del local_var_params['kwargs']
collection_formats = {}
path_params = {}
query_params = []
if 'page_token' in local_var_params and local_var_params['page_token'] is not None: # noqa: E501
query_params.append(('page_token', local_var_params['page_token'])) # noqa: E501
if 'page_size' in local_var_params and local_var_params['page_size'] is not None: # noqa: E501
query_params.append(('page_size', local_var_params['page_size'])) # noqa: E501
if 'sort_by' in local_var_params and local_var_params['sort_by'] is not None: # noqa: E501
query_params.append(('sort_by', local_var_params['sort_by'])) # noqa: E501
if 'namespace' in local_var_params and local_var_params['namespace'] is not None: # noqa: E501
query_params.append(('namespace', local_var_params['namespace'])) # noqa: E501
if 'filter' in local_var_params and local_var_params['filter'] is not None: # noqa: E501
query_params.append(('filter', local_var_params['filter'])) # noqa: E501
if 'experiment_id' in local_var_params and local_var_params['experiment_id'] is not None: # noqa: E501
query_params.append(('experiment_id', local_var_params['experiment_id'])) # noqa: E501
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501
# Authentication setting
auth_settings = [] # noqa: E501
return self.api_client.call_api(
'/apis/v2beta1/recurringruns', 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='V2beta1ListRecurringRunsResponse', # noqa: E501
auth_settings=auth_settings,
async_req=local_var_params.get('async_req'),
_return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501
_preload_content=local_var_params.get('_preload_content', True),
_request_timeout=local_var_params.get('_request_timeout'),
collection_formats=collection_formats)

View File

@ -0,0 +1,101 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from kfp_server_api.configuration import Configuration
class RecurringRunMode(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
allowed enum values
"""
MODE_UNSPECIFIED = "MODE_UNSPECIFIED"
ENABLE = "ENABLE"
DISABLE = "DISABLE"
allowable_values = [MODE_UNSPECIFIED, ENABLE, DISABLE] # noqa: E501
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
}
attribute_map = {
}
def __init__(self, local_vars_configuration=None): # noqa: E501
"""RecurringRunMode - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self.discriminator = None
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, RecurringRunMode):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, RecurringRunMode):
return True
return self.to_dict() != other.to_dict()

View File

@ -0,0 +1,176 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from kfp_server_api.configuration import Configuration
class V2beta1CronSchedule(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
'start_time': 'datetime',
'end_time': 'datetime',
'cron': 'str'
}
attribute_map = {
'start_time': 'start_time',
'end_time': 'end_time',
'cron': 'cron'
}
def __init__(self, start_time=None, end_time=None, cron=None, local_vars_configuration=None): # noqa: E501
"""V2beta1CronSchedule - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self._start_time = None
self._end_time = None
self._cron = None
self.discriminator = None
if start_time is not None:
self.start_time = start_time
if end_time is not None:
self.end_time = end_time
if cron is not None:
self.cron = cron
@property
def start_time(self):
"""Gets the start_time of this V2beta1CronSchedule. # noqa: E501
The start time of the cron job. # noqa: E501
:return: The start_time of this V2beta1CronSchedule. # noqa: E501
:rtype: datetime
"""
return self._start_time
@start_time.setter
def start_time(self, start_time):
"""Sets the start_time of this V2beta1CronSchedule.
The start time of the cron job. # noqa: E501
:param start_time: The start_time of this V2beta1CronSchedule. # noqa: E501
:type start_time: datetime
"""
self._start_time = start_time
@property
def end_time(self):
"""Gets the end_time of this V2beta1CronSchedule. # noqa: E501
The end time of the cron job. # noqa: E501
:return: The end_time of this V2beta1CronSchedule. # noqa: E501
:rtype: datetime
"""
return self._end_time
@end_time.setter
def end_time(self, end_time):
"""Sets the end_time of this V2beta1CronSchedule.
The end time of the cron job. # noqa: E501
:param end_time: The end_time of this V2beta1CronSchedule. # noqa: E501
:type end_time: datetime
"""
self._end_time = end_time
@property
def cron(self):
"""Gets the cron of this V2beta1CronSchedule. # noqa: E501
:return: The cron of this V2beta1CronSchedule. # noqa: E501
:rtype: str
"""
return self._cron
@cron.setter
def cron(self, cron):
"""Sets the cron of this V2beta1CronSchedule.
:param cron: The cron of this V2beta1CronSchedule. # noqa: E501
:type cron: str
"""
self._cron = cron
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, V2beta1CronSchedule):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, V2beta1CronSchedule):
return True
return self.to_dict() != other.to_dict()

View File

@ -0,0 +1,178 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from kfp_server_api.configuration import Configuration
class V2beta1ListRecurringRunsResponse(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
'recurring_runs': 'list[V2beta1RecurringRun]',
'total_size': 'int',
'next_page_token': 'str'
}
attribute_map = {
'recurring_runs': 'recurringRuns',
'total_size': 'total_size',
'next_page_token': 'next_page_token'
}
def __init__(self, recurring_runs=None, total_size=None, next_page_token=None, local_vars_configuration=None): # noqa: E501
"""V2beta1ListRecurringRunsResponse - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self._recurring_runs = None
self._total_size = None
self._next_page_token = None
self.discriminator = None
if recurring_runs is not None:
self.recurring_runs = recurring_runs
if total_size is not None:
self.total_size = total_size
if next_page_token is not None:
self.next_page_token = next_page_token
@property
def recurring_runs(self):
"""Gets the recurring_runs of this V2beta1ListRecurringRunsResponse. # noqa: E501
A list of recurring runs returned. # noqa: E501
:return: The recurring_runs of this V2beta1ListRecurringRunsResponse. # noqa: E501
:rtype: list[V2beta1RecurringRun]
"""
return self._recurring_runs
@recurring_runs.setter
def recurring_runs(self, recurring_runs):
"""Sets the recurring_runs of this V2beta1ListRecurringRunsResponse.
A list of recurring runs returned. # noqa: E501
:param recurring_runs: The recurring_runs of this V2beta1ListRecurringRunsResponse. # noqa: E501
:type recurring_runs: list[V2beta1RecurringRun]
"""
self._recurring_runs = recurring_runs
@property
def total_size(self):
"""Gets the total_size of this V2beta1ListRecurringRunsResponse. # noqa: E501
The total number of recurring runs for the given query. # noqa: E501
:return: The total_size of this V2beta1ListRecurringRunsResponse. # noqa: E501
:rtype: int
"""
return self._total_size
@total_size.setter
def total_size(self, total_size):
"""Sets the total_size of this V2beta1ListRecurringRunsResponse.
The total number of recurring runs for the given query. # noqa: E501
:param total_size: The total_size of this V2beta1ListRecurringRunsResponse. # noqa: E501
:type total_size: int
"""
self._total_size = total_size
@property
def next_page_token(self):
"""Gets the next_page_token of this V2beta1ListRecurringRunsResponse. # noqa: E501
The token to list the next page of recurring runs. # noqa: E501
:return: The next_page_token of this V2beta1ListRecurringRunsResponse. # noqa: E501
:rtype: str
"""
return self._next_page_token
@next_page_token.setter
def next_page_token(self, next_page_token):
"""Sets the next_page_token of this V2beta1ListRecurringRunsResponse.
The token to list the next page of recurring runs. # noqa: E501
:param next_page_token: The next_page_token of this V2beta1ListRecurringRunsResponse. # noqa: E501
:type next_page_token: str
"""
self._next_page_token = next_page_token
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, V2beta1ListRecurringRunsResponse):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, V2beta1ListRecurringRunsResponse):
return True
return self.to_dict() != other.to_dict()

View File

@ -0,0 +1,178 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from kfp_server_api.configuration import Configuration
class V2beta1PeriodicSchedule(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
'start_time': 'datetime',
'end_time': 'datetime',
'interval_second': 'str'
}
attribute_map = {
'start_time': 'start_time',
'end_time': 'end_time',
'interval_second': 'interval_second'
}
def __init__(self, start_time=None, end_time=None, interval_second=None, local_vars_configuration=None): # noqa: E501
"""V2beta1PeriodicSchedule - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self._start_time = None
self._end_time = None
self._interval_second = None
self.discriminator = None
if start_time is not None:
self.start_time = start_time
if end_time is not None:
self.end_time = end_time
if interval_second is not None:
self.interval_second = interval_second
@property
def start_time(self):
"""Gets the start_time of this V2beta1PeriodicSchedule. # noqa: E501
The start time of the periodic recurring run. # noqa: E501
:return: The start_time of this V2beta1PeriodicSchedule. # noqa: E501
:rtype: datetime
"""
return self._start_time
@start_time.setter
def start_time(self, start_time):
"""Sets the start_time of this V2beta1PeriodicSchedule.
The start time of the periodic recurring run. # noqa: E501
:param start_time: The start_time of this V2beta1PeriodicSchedule. # noqa: E501
:type start_time: datetime
"""
self._start_time = start_time
@property
def end_time(self):
"""Gets the end_time of this V2beta1PeriodicSchedule. # noqa: E501
The end time of the periodic recurring run. # noqa: E501
:return: The end_time of this V2beta1PeriodicSchedule. # noqa: E501
:rtype: datetime
"""
return self._end_time
@end_time.setter
def end_time(self, end_time):
"""Sets the end_time of this V2beta1PeriodicSchedule.
The end time of the periodic recurring run. # noqa: E501
:param end_time: The end_time of this V2beta1PeriodicSchedule. # noqa: E501
:type end_time: datetime
"""
self._end_time = end_time
@property
def interval_second(self):
"""Gets the interval_second of this V2beta1PeriodicSchedule. # noqa: E501
The time interval between the starting time of consecutive recurring runs. # noqa: E501
:return: The interval_second of this V2beta1PeriodicSchedule. # noqa: E501
:rtype: str
"""
return self._interval_second
@interval_second.setter
def interval_second(self, interval_second):
"""Sets the interval_second of this V2beta1PeriodicSchedule.
The time interval between the starting time of consecutive recurring runs. # noqa: E501
:param interval_second: The interval_second of this V2beta1PeriodicSchedule. # noqa: E501
:type interval_second: str
"""
self._interval_second = interval_second
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, V2beta1PeriodicSchedule):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, V2beta1PeriodicSchedule):
return True
return self.to_dict() != other.to_dict()

View File

@ -0,0 +1,562 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from kfp_server_api.configuration import Configuration
class V2beta1RecurringRun(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
'recurring_run_id': 'str',
'display_name': 'str',
'description': 'str',
'pipeline_id': 'str',
'pipeline_spec': 'object',
'runtime_config': 'V2beta1RuntimeConfig',
'service_account': 'str',
'max_concurrency': 'str',
'trigger': 'V2beta1Trigger',
'mode': 'RecurringRunMode',
'created_at': 'datetime',
'updated_at': 'datetime',
'status': 'V2beta1RecurringRunStatus',
'error': 'str',
'no_catchup': 'bool',
'namespace': 'str',
'experiment_id': 'str'
}
attribute_map = {
'recurring_run_id': 'recurring_run_id',
'display_name': 'display_name',
'description': 'description',
'pipeline_id': 'pipeline_id',
'pipeline_spec': 'pipeline_spec',
'runtime_config': 'runtime_config',
'service_account': 'service_account',
'max_concurrency': 'max_concurrency',
'trigger': 'trigger',
'mode': 'mode',
'created_at': 'created_at',
'updated_at': 'updated_at',
'status': 'status',
'error': 'error',
'no_catchup': 'no_catchup',
'namespace': 'namespace',
'experiment_id': 'experiment_id'
}
def __init__(self, recurring_run_id=None, display_name=None, description=None, pipeline_id=None, pipeline_spec=None, runtime_config=None, service_account=None, max_concurrency=None, trigger=None, mode=None, created_at=None, updated_at=None, status=None, error=None, no_catchup=None, namespace=None, experiment_id=None, local_vars_configuration=None): # noqa: E501
"""V2beta1RecurringRun - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self._recurring_run_id = None
self._display_name = None
self._description = None
self._pipeline_id = None
self._pipeline_spec = None
self._runtime_config = None
self._service_account = None
self._max_concurrency = None
self._trigger = None
self._mode = None
self._created_at = None
self._updated_at = None
self._status = None
self._error = None
self._no_catchup = None
self._namespace = None
self._experiment_id = None
self.discriminator = None
if recurring_run_id is not None:
self.recurring_run_id = recurring_run_id
if display_name is not None:
self.display_name = display_name
if description is not None:
self.description = description
if pipeline_id is not None:
self.pipeline_id = pipeline_id
if pipeline_spec is not None:
self.pipeline_spec = pipeline_spec
if runtime_config is not None:
self.runtime_config = runtime_config
if service_account is not None:
self.service_account = service_account
if max_concurrency is not None:
self.max_concurrency = max_concurrency
if trigger is not None:
self.trigger = trigger
if mode is not None:
self.mode = mode
if created_at is not None:
self.created_at = created_at
if updated_at is not None:
self.updated_at = updated_at
if status is not None:
self.status = status
if error is not None:
self.error = error
if no_catchup is not None:
self.no_catchup = no_catchup
if namespace is not None:
self.namespace = namespace
if experiment_id is not None:
self.experiment_id = experiment_id
@property
def recurring_run_id(self):
"""Gets the recurring_run_id of this V2beta1RecurringRun. # noqa: E501
Output. Unique run ID generated by API server. # noqa: E501
:return: The recurring_run_id of this V2beta1RecurringRun. # noqa: E501
:rtype: str
"""
return self._recurring_run_id
@recurring_run_id.setter
def recurring_run_id(self, recurring_run_id):
"""Sets the recurring_run_id of this V2beta1RecurringRun.
Output. Unique run ID generated by API server. # noqa: E501
:param recurring_run_id: The recurring_run_id of this V2beta1RecurringRun. # noqa: E501
:type recurring_run_id: str
"""
self._recurring_run_id = recurring_run_id
@property
def display_name(self):
"""Gets the display_name of this V2beta1RecurringRun. # noqa: E501
Required input field. Recurring run name provided by user. Not unique. # noqa: E501
:return: The display_name of this V2beta1RecurringRun. # noqa: E501
:rtype: str
"""
return self._display_name
@display_name.setter
def display_name(self, display_name):
"""Sets the display_name of this V2beta1RecurringRun.
Required input field. Recurring run name provided by user. Not unique. # noqa: E501
:param display_name: The display_name of this V2beta1RecurringRun. # noqa: E501
:type display_name: str
"""
self._display_name = display_name
@property
def description(self):
"""Gets the description of this V2beta1RecurringRun. # noqa: E501
Optional input field. Describes the purpose of the recurring run. # noqa: E501
:return: The description of this V2beta1RecurringRun. # noqa: E501
:rtype: str
"""
return self._description
@description.setter
def description(self, description):
"""Sets the description of this V2beta1RecurringRun.
Optional input field. Describes the purpose of the recurring run. # noqa: E501
:param description: The description of this V2beta1RecurringRun. # noqa: E501
:type description: str
"""
self._description = description
@property
def pipeline_id(self):
"""Gets the pipeline_id of this V2beta1RecurringRun. # noqa: E501
The ID of the pipeline user uploaded before. # noqa: E501
:return: The pipeline_id of this V2beta1RecurringRun. # noqa: E501
:rtype: str
"""
return self._pipeline_id
@pipeline_id.setter
def pipeline_id(self, pipeline_id):
"""Sets the pipeline_id of this V2beta1RecurringRun.
The ID of the pipeline user uploaded before. # noqa: E501
:param pipeline_id: The pipeline_id of this V2beta1RecurringRun. # noqa: E501
:type pipeline_id: str
"""
self._pipeline_id = pipeline_id
@property
def pipeline_spec(self):
"""Gets the pipeline_spec of this V2beta1RecurringRun. # noqa: E501
The pipeline spec. # noqa: E501
:return: The pipeline_spec of this V2beta1RecurringRun. # noqa: E501
:rtype: object
"""
return self._pipeline_spec
@pipeline_spec.setter
def pipeline_spec(self, pipeline_spec):
"""Sets the pipeline_spec of this V2beta1RecurringRun.
The pipeline spec. # noqa: E501
:param pipeline_spec: The pipeline_spec of this V2beta1RecurringRun. # noqa: E501
:type pipeline_spec: object
"""
self._pipeline_spec = pipeline_spec
@property
def runtime_config(self):
"""Gets the runtime_config of this V2beta1RecurringRun. # noqa: E501
:return: The runtime_config of this V2beta1RecurringRun. # noqa: E501
:rtype: V2beta1RuntimeConfig
"""
return self._runtime_config
@runtime_config.setter
def runtime_config(self, runtime_config):
"""Sets the runtime_config of this V2beta1RecurringRun.
:param runtime_config: The runtime_config of this V2beta1RecurringRun. # noqa: E501
:type runtime_config: V2beta1RuntimeConfig
"""
self._runtime_config = runtime_config
@property
def service_account(self):
"""Gets the service_account of this V2beta1RecurringRun. # noqa: E501
Optional input field. Specifies which Kubernetes service account this recurring run uses. # noqa: E501
:return: The service_account of this V2beta1RecurringRun. # noqa: E501
:rtype: str
"""
return self._service_account
@service_account.setter
def service_account(self, service_account):
"""Sets the service_account of this V2beta1RecurringRun.
Optional input field. Specifies which Kubernetes service account this recurring run uses. # noqa: E501
:param service_account: The service_account of this V2beta1RecurringRun. # noqa: E501
:type service_account: str
"""
self._service_account = service_account
@property
def max_concurrency(self):
"""Gets the max_concurrency of this V2beta1RecurringRun. # noqa: E501
Required input field. Specifies how many runs can be executed concurrently. Range [1-10]. # noqa: E501
:return: The max_concurrency of this V2beta1RecurringRun. # noqa: E501
:rtype: str
"""
return self._max_concurrency
@max_concurrency.setter
def max_concurrency(self, max_concurrency):
"""Sets the max_concurrency of this V2beta1RecurringRun.
Required input field. Specifies how many runs can be executed concurrently. Range [1-10]. # noqa: E501
:param max_concurrency: The max_concurrency of this V2beta1RecurringRun. # noqa: E501
:type max_concurrency: str
"""
self._max_concurrency = max_concurrency
@property
def trigger(self):
"""Gets the trigger of this V2beta1RecurringRun. # noqa: E501
:return: The trigger of this V2beta1RecurringRun. # noqa: E501
:rtype: V2beta1Trigger
"""
return self._trigger
@trigger.setter
def trigger(self, trigger):
"""Sets the trigger of this V2beta1RecurringRun.
:param trigger: The trigger of this V2beta1RecurringRun. # noqa: E501
:type trigger: V2beta1Trigger
"""
self._trigger = trigger
@property
def mode(self):
"""Gets the mode of this V2beta1RecurringRun. # noqa: E501
:return: The mode of this V2beta1RecurringRun. # noqa: E501
:rtype: RecurringRunMode
"""
return self._mode
@mode.setter
def mode(self, mode):
"""Sets the mode of this V2beta1RecurringRun.
:param mode: The mode of this V2beta1RecurringRun. # noqa: E501
:type mode: RecurringRunMode
"""
self._mode = mode
@property
def created_at(self):
"""Gets the created_at of this V2beta1RecurringRun. # noqa: E501
Output. The time this recurring run was created. # noqa: E501
:return: The created_at of this V2beta1RecurringRun. # noqa: E501
:rtype: datetime
"""
return self._created_at
@created_at.setter
def created_at(self, created_at):
"""Sets the created_at of this V2beta1RecurringRun.
Output. The time this recurring run was created. # noqa: E501
:param created_at: The created_at of this V2beta1RecurringRun. # noqa: E501
:type created_at: datetime
"""
self._created_at = created_at
@property
def updated_at(self):
"""Gets the updated_at of this V2beta1RecurringRun. # noqa: E501
Output. The last time this recurring run was updated. # noqa: E501
:return: The updated_at of this V2beta1RecurringRun. # noqa: E501
:rtype: datetime
"""
return self._updated_at
@updated_at.setter
def updated_at(self, updated_at):
"""Sets the updated_at of this V2beta1RecurringRun.
Output. The last time this recurring run was updated. # noqa: E501
:param updated_at: The updated_at of this V2beta1RecurringRun. # noqa: E501
:type updated_at: datetime
"""
self._updated_at = updated_at
@property
def status(self):
"""Gets the status of this V2beta1RecurringRun. # noqa: E501
:return: The status of this V2beta1RecurringRun. # noqa: E501
:rtype: V2beta1RecurringRunStatus
"""
return self._status
@status.setter
def status(self, status):
"""Sets the status of this V2beta1RecurringRun.
:param status: The status of this V2beta1RecurringRun. # noqa: E501
:type status: V2beta1RecurringRunStatus
"""
self._status = status
@property
def error(self):
"""Gets the error of this V2beta1RecurringRun. # noqa: E501
In case any error happens retrieving a recurring run field, only recurring run ID and the error message is returned. Client has the flexibility of choosing how to handle the error. This is especially useful during listing call. # noqa: E501
:return: The error of this V2beta1RecurringRun. # noqa: E501
:rtype: str
"""
return self._error
@error.setter
def error(self, error):
"""Sets the error of this V2beta1RecurringRun.
In case any error happens retrieving a recurring run field, only recurring run ID and the error message is returned. Client has the flexibility of choosing how to handle the error. This is especially useful during listing call. # noqa: E501
:param error: The error of this V2beta1RecurringRun. # noqa: E501
:type error: str
"""
self._error = error
@property
def no_catchup(self):
"""Gets the no_catchup of this V2beta1RecurringRun. # noqa: E501
Optional input field. Whether the recurring run should catch up if behind schedule. If true, the recurring run will only schedule the latest interval if behind schedule. If false, the recurring run will catch up on each past interval. # noqa: E501
:return: The no_catchup of this V2beta1RecurringRun. # noqa: E501
:rtype: bool
"""
return self._no_catchup
@no_catchup.setter
def no_catchup(self, no_catchup):
"""Sets the no_catchup of this V2beta1RecurringRun.
Optional input field. Whether the recurring run should catch up if behind schedule. If true, the recurring run will only schedule the latest interval if behind schedule. If false, the recurring run will catch up on each past interval. # noqa: E501
:param no_catchup: The no_catchup of this V2beta1RecurringRun. # noqa: E501
:type no_catchup: bool
"""
self._no_catchup = no_catchup
@property
def namespace(self):
"""Gets the namespace of this V2beta1RecurringRun. # noqa: E501
Namespace this recurring run belongs to. # noqa: E501
:return: The namespace of this V2beta1RecurringRun. # noqa: E501
:rtype: str
"""
return self._namespace
@namespace.setter
def namespace(self, namespace):
"""Sets the namespace of this V2beta1RecurringRun.
Namespace this recurring run belongs to. # noqa: E501
:param namespace: The namespace of this V2beta1RecurringRun. # noqa: E501
:type namespace: str
"""
self._namespace = namespace
@property
def experiment_id(self):
"""Gets the experiment_id of this V2beta1RecurringRun. # noqa: E501
ID of the experiment this recurring run belongs to. # noqa: E501
:return: The experiment_id of this V2beta1RecurringRun. # noqa: E501
:rtype: str
"""
return self._experiment_id
@experiment_id.setter
def experiment_id(self, experiment_id):
"""Sets the experiment_id of this V2beta1RecurringRun.
ID of the experiment this recurring run belongs to. # noqa: E501
:param experiment_id: The experiment_id of this V2beta1RecurringRun. # noqa: E501
:type experiment_id: str
"""
self._experiment_id = experiment_id
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, V2beta1RecurringRun):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, V2beta1RecurringRun):
return True
return self.to_dict() != other.to_dict()

View File

@ -0,0 +1,101 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from kfp_server_api.configuration import Configuration
class V2beta1RecurringRunStatus(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
allowed enum values
"""
STATUS_UNSPECIFIED = "STATUS_UNSPECIFIED"
ENABLED = "ENABLED"
DISABLED = "DISABLED"
allowable_values = [STATUS_UNSPECIFIED, ENABLED, DISABLED] # noqa: E501
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
}
attribute_map = {
}
def __init__(self, local_vars_configuration=None): # noqa: E501
"""V2beta1RecurringRunStatus - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self.discriminator = None
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, V2beta1RecurringRunStatus):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, V2beta1RecurringRunStatus):
return True
return self.to_dict() != other.to_dict()

View File

@ -0,0 +1,146 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
import pprint
import re # noqa: F401
import six
from kfp_server_api.configuration import Configuration
class V2beta1Trigger(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""
"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {
'cron_schedule': 'V2beta1CronSchedule',
'periodic_schedule': 'V2beta1PeriodicSchedule'
}
attribute_map = {
'cron_schedule': 'cron_schedule',
'periodic_schedule': 'periodic_schedule'
}
def __init__(self, cron_schedule=None, periodic_schedule=None, local_vars_configuration=None): # noqa: E501
"""V2beta1Trigger - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration
self._cron_schedule = None
self._periodic_schedule = None
self.discriminator = None
if cron_schedule is not None:
self.cron_schedule = cron_schedule
if periodic_schedule is not None:
self.periodic_schedule = periodic_schedule
@property
def cron_schedule(self):
"""Gets the cron_schedule of this V2beta1Trigger. # noqa: E501
:return: The cron_schedule of this V2beta1Trigger. # noqa: E501
:rtype: V2beta1CronSchedule
"""
return self._cron_schedule
@cron_schedule.setter
def cron_schedule(self, cron_schedule):
"""Sets the cron_schedule of this V2beta1Trigger.
:param cron_schedule: The cron_schedule of this V2beta1Trigger. # noqa: E501
:type cron_schedule: V2beta1CronSchedule
"""
self._cron_schedule = cron_schedule
@property
def periodic_schedule(self):
"""Gets the periodic_schedule of this V2beta1Trigger. # noqa: E501
:return: The periodic_schedule of this V2beta1Trigger. # noqa: E501
:rtype: V2beta1PeriodicSchedule
"""
return self._periodic_schedule
@periodic_schedule.setter
def periodic_schedule(self, periodic_schedule):
"""Sets the periodic_schedule of this V2beta1Trigger.
:param periodic_schedule: The periodic_schedule of this V2beta1Trigger. # noqa: E501
:type periodic_schedule: V2beta1PeriodicSchedule
"""
self._periodic_schedule = periodic_schedule
def to_dict(self):
"""Returns the model properties as a dict"""
result = {}
for attr, _ in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value
return result
def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())
def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()
def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, V2beta1Trigger):
return False
return self.to_dict() == other.to_dict()
def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, V2beta1Trigger):
return True
return self.to_dict() != other.to_dict()

View File

@ -0,0 +1,51 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import kfp_server_api
from kfp_server_api.models.recurring_run_mode import RecurringRunMode # noqa: E501
from kfp_server_api.rest import ApiException
class TestRecurringRunMode(unittest.TestCase):
"""RecurringRunMode unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test RecurringRunMode
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = kfp_server_api.models.recurring_run_mode.RecurringRunMode() # noqa: E501
if include_optional :
return RecurringRunMode(
)
else :
return RecurringRunMode(
)
def testRecurringRunMode(self):
"""Test RecurringRunMode"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,75 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import kfp_server_api
from kfp_server_api.api.recurring_run_service_api import RecurringRunServiceApi # noqa: E501
from kfp_server_api.rest import ApiException
class TestRecurringRunServiceApi(unittest.TestCase):
"""RecurringRunServiceApi unit test stubs"""
def setUp(self):
self.api = kfp_server_api.api.recurring_run_service_api.RecurringRunServiceApi() # noqa: E501
def tearDown(self):
pass
def test_create_recurring_run(self):
"""Test case for create_recurring_run
Creates a new recurring run in an experiment, given the experiment ID. # noqa: E501
"""
pass
def test_delete_recurring_run(self):
"""Test case for delete_recurring_run
Deletes a recurring run. # noqa: E501
"""
pass
def test_disable_recurring_run(self):
"""Test case for disable_recurring_run
Stops a recurring run and all its associated runs. The recurring run is not deleted. # noqa: E501
"""
pass
def test_enable_recurring_run(self):
"""Test case for enable_recurring_run
Restarts a recurring run that was previously stopped. All runs associated with the recurring run will continue. # noqa: E501
"""
pass
def test_get_recurring_run(self):
"""Test case for get_recurring_run
Finds a specific recurring run by ID. # noqa: E501
"""
pass
def test_list_recurring_runs(self):
"""Test case for list_recurring_runs
Finds all recurring runs given experiment and namespace. If experiment ID is not specified, find all recurring runs across all experiments. # noqa: E501
"""
pass
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,54 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import kfp_server_api
from kfp_server_api.models.v2beta1_cron_schedule import V2beta1CronSchedule # noqa: E501
from kfp_server_api.rest import ApiException
class TestV2beta1CronSchedule(unittest.TestCase):
"""V2beta1CronSchedule unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test V2beta1CronSchedule
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = kfp_server_api.models.v2beta1_cron_schedule.V2beta1CronSchedule() # noqa: E501
if include_optional :
return V2beta1CronSchedule(
start_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
end_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
cron = '0'
)
else :
return V2beta1CronSchedule(
)
def testV2beta1CronSchedule(self):
"""Test V2beta1CronSchedule"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,85 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import kfp_server_api
from kfp_server_api.models.v2beta1_list_recurring_runs_response import V2beta1ListRecurringRunsResponse # noqa: E501
from kfp_server_api.rest import ApiException
class TestV2beta1ListRecurringRunsResponse(unittest.TestCase):
"""V2beta1ListRecurringRunsResponse unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test V2beta1ListRecurringRunsResponse
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = kfp_server_api.models.v2beta1_list_recurring_runs_response.V2beta1ListRecurringRunsResponse() # noqa: E501
if include_optional :
return V2beta1ListRecurringRunsResponse(
recurring_runs = [
kfp_server_api.models.v2beta1_recurring_run.v2beta1RecurringRun(
recurring_run_id = '0',
display_name = '0',
description = '0',
pipeline_id = '0',
pipeline_spec = kfp_server_api.models.pipeline_spec.pipeline_spec(),
runtime_config = kfp_server_api.models.v2beta1_runtime_config.v2beta1RuntimeConfig(
parameters = {
'key' : None
},
pipeline_root = '0', ),
service_account = '0',
max_concurrency = '0',
trigger = kfp_server_api.models.v2beta1_trigger.v2beta1Trigger(
cron_schedule = kfp_server_api.models.v2beta1_cron_schedule.v2beta1CronSchedule(
start_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
end_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
cron = '0', ),
periodic_schedule = kfp_server_api.models.v2beta1_periodic_schedule.v2beta1PeriodicSchedule(
start_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
end_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
interval_second = '0', ), ),
mode = 'MODE_UNSPECIFIED',
created_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
status = 'STATUS_UNSPECIFIED',
error = '0',
no_catchup = True,
namespace = '0',
experiment_id = '0', )
],
total_size = 56,
next_page_token = '0'
)
else :
return V2beta1ListRecurringRunsResponse(
)
def testV2beta1ListRecurringRunsResponse(self):
"""Test V2beta1ListRecurringRunsResponse"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,54 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import kfp_server_api
from kfp_server_api.models.v2beta1_periodic_schedule import V2beta1PeriodicSchedule # noqa: E501
from kfp_server_api.rest import ApiException
class TestV2beta1PeriodicSchedule(unittest.TestCase):
"""V2beta1PeriodicSchedule unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test V2beta1PeriodicSchedule
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = kfp_server_api.models.v2beta1_periodic_schedule.V2beta1PeriodicSchedule() # noqa: E501
if include_optional :
return V2beta1PeriodicSchedule(
start_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
end_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
interval_second = '0'
)
else :
return V2beta1PeriodicSchedule(
)
def testV2beta1PeriodicSchedule(self):
"""Test V2beta1PeriodicSchedule"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,80 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import kfp_server_api
from kfp_server_api.models.v2beta1_recurring_run import V2beta1RecurringRun # noqa: E501
from kfp_server_api.rest import ApiException
class TestV2beta1RecurringRun(unittest.TestCase):
"""V2beta1RecurringRun unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test V2beta1RecurringRun
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = kfp_server_api.models.v2beta1_recurring_run.V2beta1RecurringRun() # noqa: E501
if include_optional :
return V2beta1RecurringRun(
recurring_run_id = '0',
display_name = '0',
description = '0',
pipeline_id = '0',
pipeline_spec = kfp_server_api.models.pipeline_spec.pipeline_spec(),
runtime_config = kfp_server_api.models.v2beta1_runtime_config.v2beta1RuntimeConfig(
parameters = {
'key' : None
},
pipeline_root = '0', ),
service_account = '0',
max_concurrency = '0',
trigger = kfp_server_api.models.v2beta1_trigger.v2beta1Trigger(
cron_schedule = kfp_server_api.models.v2beta1_cron_schedule.v2beta1CronSchedule(
start_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
end_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
cron = '0', ),
periodic_schedule = kfp_server_api.models.v2beta1_periodic_schedule.v2beta1PeriodicSchedule(
start_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
end_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
interval_second = '0', ), ),
mode = 'MODE_UNSPECIFIED',
created_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
updated_at = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
status = 'STATUS_UNSPECIFIED',
error = '0',
no_catchup = True,
namespace = '0',
experiment_id = '0'
)
else :
return V2beta1RecurringRun(
)
def testV2beta1RecurringRun(self):
"""Test V2beta1RecurringRun"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,51 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import kfp_server_api
from kfp_server_api.models.v2beta1_recurring_run_status import V2beta1RecurringRunStatus # noqa: E501
from kfp_server_api.rest import ApiException
class TestV2beta1RecurringRunStatus(unittest.TestCase):
"""V2beta1RecurringRunStatus unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test V2beta1RecurringRunStatus
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = kfp_server_api.models.v2beta1_recurring_run_status.V2beta1RecurringRunStatus() # noqa: E501
if include_optional :
return V2beta1RecurringRunStatus(
)
else :
return V2beta1RecurringRunStatus(
)
def testV2beta1RecurringRunStatus(self):
"""Test V2beta1RecurringRunStatus"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,59 @@
# coding: utf-8
"""
Kubeflow Pipelines API
This file contains REST API specification for Kubeflow Pipelines. The file is autogenerated from the swagger definition.
Contact: kubeflow-pipelines@google.com
Generated by: https://openapi-generator.tech
"""
from __future__ import absolute_import
import unittest
import datetime
import kfp_server_api
from kfp_server_api.models.v2beta1_trigger import V2beta1Trigger # noqa: E501
from kfp_server_api.rest import ApiException
class TestV2beta1Trigger(unittest.TestCase):
"""V2beta1Trigger unit test stubs"""
def setUp(self):
pass
def tearDown(self):
pass
def make_instance(self, include_optional):
"""Test V2beta1Trigger
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = kfp_server_api.models.v2beta1_trigger.V2beta1Trigger() # noqa: E501
if include_optional :
return V2beta1Trigger(
cron_schedule = kfp_server_api.models.v2beta1_cron_schedule.v2beta1CronSchedule(
start_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
end_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
cron = '0', ),
periodic_schedule = kfp_server_api.models.v2beta1_periodic_schedule.v2beta1PeriodicSchedule(
start_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
end_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
interval_second = '0', )
)
else :
return V2beta1Trigger(
)
def testV2beta1Trigger(self):
"""Test V2beta1Trigger"""
inst_req_only = self.make_instance(include_optional=False)
inst_req_and_optional = self.make_instance(include_optional=True)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,241 @@
// Copyright 2022 The Kubeflow Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
option go_package = "github.com/kubeflow/pipelines/backend/api/v2beta1/go_client";
package v2beta1;
import "backend/api/v2beta1/runtime_config.proto";
import "google/protobuf/struct.proto";
import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
service RecurringRunService {
// Creates a new recurring run in an experiment, given the experiment ID.
rpc CreateRecurringRun(CreateRecurringRunRequest) returns (RecurringRun) {
option (google.api.http) = {
post: "/apis/v2beta1/recurringruns"
body: "recurring_run"
};
}
// Finds a specific recurring run by ID.
rpc GetRecurringRun(GetRecurringRunRequest) returns (RecurringRun) {
option (google.api.http) = {
get: "/apis/v2beta1/recurringruns/{recurring_run_id}"
};
}
// Finds all recurring runs given experiment and namespace.
// If experiment ID is not specified, find all recurring runs across all experiments.
rpc ListRecurringRuns(ListRecurringRunsRequest) returns (ListRecurringRunsResponse) {
option (google.api.http) = {
get: "/apis/v2beta1/recurringruns"
};
}
// Restarts a recurring run that was previously stopped. All runs associated with the
// recurring run will continue.
rpc EnableRecurringRun(EnableRecurringRunRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/apis/v2beta1/recurringruns/{recurring_run_id}:enable"
};
}
// Stops a recurring run and all its associated runs. The recurring run is not deleted.
rpc DisableRecurringRun(DisableRecurringRunRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post: "/apis/v2beta1/recurringruns/{recurring_run_id}:disable"
};
}
// Deletes a recurring run.
rpc DeleteRecurringRun(DeleteRecurringRunRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete: "/apis/v2beta1/recurringruns/{recurring_run_id}"
};
}
}
message CreateRecurringRunRequest {
// The recurring run to be created.
RecurringRun recurring_run = 1;
}
message GetRecurringRunRequest {
// The ID of the recurring run to be retrieved.
string recurring_run_id = 1;
}
message ListRecurringRunsRequest {
// A page token to request the next page of results. The token is acquired
// from the nextPageToken field of the response from the previous
// ListRecurringRuns call or can be omitted when fetching the first page.
string page_token = 1;
// The number of recurring runs to be listed per page. If there are more recurring runs
// than this number, the response message will contain a nextPageToken field you can use
// to fetch the next page.
int32 page_size = 2;
// Can be formatted as "field_name", "field_name asc" or "field_name desc".
// Ascending by default.
string sort_by = 3;
// Optional input. The namespace the recurring runs belong to.
string namespace = 4;
// A url-encoded, JSON-serialized Filter protocol buffer (see
// [filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)).
string filter = 5;
// The ID of the experiment to be retrieved. If empty, list recurring runs across all experiments.
string experiment_id = 6;
}
message ListRecurringRunsResponse {
// A list of recurring runs returned.
repeated RecurringRun recurringRuns = 1;
// The total number of recurring runs for the given query.
int32 total_size = 2;
// The token to list the next page of recurring runs.
string next_page_token = 3;
}
message EnableRecurringRunRequest {
// The ID of the recurring runs to be enabled.
string recurring_run_id = 1;
}
message DisableRecurringRunRequest {
// The ID of the recurring runs to be disabled.
string recurring_run_id = 1;
}
message DeleteRecurringRunRequest {
// The ID of the recurring run to be deleted.
string recurring_run_id = 1;
}
// CronSchedule allow scheduling the recurring run with unix-like cron.
message CronSchedule {
// The start time of the cron job.
google.protobuf.Timestamp start_time = 1;
// The end time of the cron job.
google.protobuf.Timestamp end_time = 2;
// The cron string. For details how to compose a cron, visit
// ttps://en.wikipedia.org/wiki/Cron
string cron = 3;
}
// PeriodicSchedule allow scheduling the recurring run periodically with certain interval.
message PeriodicSchedule {
// The start time of the periodic recurring run.
google.protobuf.Timestamp start_time = 1;
// The end time of the periodic recurring run.
google.protobuf.Timestamp end_time = 2;
// The time interval between the starting time of consecutive recurring runs.
int64 interval_second = 3;
}
// Trigger defines what starts a pipeline run.
message Trigger {
oneof trigger {
CronSchedule cron_schedule = 1;
PeriodicSchedule periodic_schedule = 2;
}
}
message RecurringRun {
// Output. Unique run ID generated by API server.
string recurring_run_id = 1;
// Required input field. Recurring run name provided by user. Not unique.
string display_name = 2;
// Optional input field. Describes the purpose of the recurring run.
string description = 3;
// Required input field. Specifies the source of the pipeline spec for this
// recurring run. Can be either a pipeline id, or a pipeline spec.
oneof pipeline_source {
// The ID of the pipeline user uploaded before.
string pipeline_id = 4;
// The pipeline spec.
google.protobuf.Struct pipeline_spec = 5;
}
// Runtime config of the pipeline.
RuntimeConfig runtime_config = 6;
// Optional input field. Specifies which Kubernetes service account this recurring run uses.
string service_account = 7;
// Required input field.
// Specifies how many runs can be executed concurrently. Range [1-10].
int64 max_concurrency = 8;
// Required input field.
// Specifies how a run is triggered. Support cron mode or periodic mode.
Trigger trigger = 9;
// Required input.
// User setting to enable or disable the recurring run.
// Only used for creation of recurring runs. Later updates use enable/disable API.
enum Mode {
MODE_UNSPECIFIED = 0;
ENABLE = 1;
// The recurring run won't schedule any run if disabled.
DISABLE = 2;
}
Mode mode = 10;
// Output. The time this recurring run was created.
google.protobuf.Timestamp created_at = 11;
// Output. The last time this recurring run was updated.
google.protobuf.Timestamp updated_at = 12;
// Output. The status of the recurring run.
enum Status {
STATUS_UNSPECIFIED = 0;
ENABLED = 1;
DISABLED = 3;
}
Status status = 13;
// In case any error happens retrieving a recurring run field, only recurring run ID
// and the error message is returned. Client has the flexibility of choosing
// how to handle the error. This is especially useful during listing call.
string error = 14;
// Optional input field. Whether the recurring run should catch up if behind schedule.
// If true, the recurring run will only schedule the latest interval if behind schedule.
// If false, the recurring run will catch up on each past interval.
bool no_catchup = 15;
// Namespace this recurring run belongs to.
string namespace = 16;
// ID of the experiment this recurring run belongs to.
string experiment_id = 17;
}

View File

@ -30,4 +30,4 @@ message RuntimeConfig {
// generate the paths of output artifacts.
// Ref:(https://www.kubeflow.org/docs/components/pipelines/pipeline-root/)
string pipeline_root = 2;
}
}

View File

@ -0,0 +1,405 @@
{
"swagger": "2.0",
"info": {
"title": "backend/api/v2beta1/recurring_run.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/apis/v2beta1/recurringruns": {
"get": {
"summary": "Finds all recurring runs given experiment and namespace. \nIf experiment ID is not specified, find all recurring runs across all experiments.",
"operationId": "ListRecurringRuns",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v2beta1ListRecurringRunsResponse"
}
}
},
"parameters": [
{
"name": "page_token",
"description": "A page token to request the next page of results. The token is acquired\nfrom the nextPageToken field of the response from the previous\nListRecurringRuns call or can be omitted when fetching the first page.",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "page_size",
"description": "The number of recurring runs to be listed per page. If there are more recurring runs \nthan this number, the response message will contain a nextPageToken field you can use\nto fetch the next page.",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
},
{
"name": "sort_by",
"description": "Can be formatted as \"field_name\", \"field_name asc\" or \"field_name desc\".\nAscending by default.",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "namespace",
"description": "Optional input. The namespace the recurring runs belong to.",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "filter",
"description": "A url-encoded, JSON-serialized Filter protocol buffer (see\n[filter.proto](https://github.com/kubeflow/pipelines/blob/master/backend/api/filter.proto)).",
"in": "query",
"required": false,
"type": "string"
},
{
"name": "experiment_id",
"description": "The ID of the experiment to be retrieved. If empty, list recurring runs across all experiments.",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"RecurringRunService"
]
},
"post": {
"summary": "Creates a new recurring run in an experiment, given the experiment ID.",
"operationId": "CreateRecurringRun",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v2beta1RecurringRun"
}
}
},
"parameters": [
{
"name": "body",
"description": "The recurring run to be created.",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/v2beta1RecurringRun"
}
}
],
"tags": [
"RecurringRunService"
]
}
},
"/apis/v2beta1/recurringruns/{recurring_run_id}": {
"get": {
"summary": "Finds a specific recurring run by ID.",
"operationId": "GetRecurringRun",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/v2beta1RecurringRun"
}
}
},
"parameters": [
{
"name": "recurring_run_id",
"description": "The ID of the recurring run to be retrieved.",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"RecurringRunService"
]
},
"delete": {
"summary": "Deletes a recurring run.",
"operationId": "DeleteRecurringRun",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"properties": {}
}
}
},
"parameters": [
{
"name": "recurring_run_id",
"description": "The ID of the recurring run to be deleted.",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"RecurringRunService"
]
}
},
"/apis/v2beta1/recurringruns/{recurring_run_id}:disable": {
"post": {
"summary": "Stops a recurring run and all its associated runs. The recurring run is not deleted.",
"operationId": "DisableRecurringRun",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"properties": {}
}
}
},
"parameters": [
{
"name": "recurring_run_id",
"description": "The ID of the recurring runs to be disabled.",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"RecurringRunService"
]
}
},
"/apis/v2beta1/recurringruns/{recurring_run_id}:enable": {
"post": {
"summary": "Restarts a recurring run that was previously stopped. All runs associated with the \nrecurring run will continue.",
"operationId": "EnableRecurringRun",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"properties": {}
}
}
},
"parameters": [
{
"name": "recurring_run_id",
"description": "The ID of the recurring runs to be enabled.",
"in": "path",
"required": true,
"type": "string"
}
],
"tags": [
"RecurringRunService"
]
}
}
},
"definitions": {
"RecurringRunMode": {
"type": "string",
"enum": [
"MODE_UNSPECIFIED",
"ENABLE",
"DISABLE"
],
"default": "MODE_UNSPECIFIED",
"description": "Required input.\nUser setting to enable or disable the recurring run. \nOnly used for creation of recurring runs. Later updates use enable/disable API.\n\n - DISABLE: The recurring run won't schedule any run if disabled."
},
"protobufNullValue": {
"type": "string",
"enum": [
"NULL_VALUE"
],
"default": "NULL_VALUE",
"description": "`NullValue` is a singleton enumeration to represent the null value for the\n`Value` type union.\n\n The JSON representation for `NullValue` is JSON `null`.\n\n - NULL_VALUE: Null value."
},
"v2beta1CronSchedule": {
"type": "object",
"properties": {
"start_time": {
"type": "string",
"format": "date-time",
"description": "The start time of the cron job."
},
"end_time": {
"type": "string",
"format": "date-time",
"description": "The end time of the cron job."
},
"cron": {
"type": "string",
"title": "The cron string. For details how to compose a cron, visit\nttps://en.wikipedia.org/wiki/Cron"
}
},
"description": "CronSchedule allow scheduling the recurring run with unix-like cron."
},
"v2beta1ListRecurringRunsResponse": {
"type": "object",
"properties": {
"recurringRuns": {
"type": "array",
"items": {
"$ref": "#/definitions/v2beta1RecurringRun"
},
"description": "A list of recurring runs returned."
},
"total_size": {
"type": "integer",
"format": "int32",
"description": "The total number of recurring runs for the given query."
},
"next_page_token": {
"type": "string",
"description": "The token to list the next page of recurring runs."
}
}
},
"v2beta1PeriodicSchedule": {
"type": "object",
"properties": {
"start_time": {
"type": "string",
"format": "date-time",
"description": "The start time of the periodic recurring run."
},
"end_time": {
"type": "string",
"format": "date-time",
"description": "The end time of the periodic recurring run."
},
"interval_second": {
"type": "string",
"format": "int64",
"description": "The time interval between the starting time of consecutive recurring runs."
}
},
"description": "PeriodicSchedule allow scheduling the recurring run periodically with certain interval."
},
"v2beta1RecurringRun": {
"type": "object",
"properties": {
"recurring_run_id": {
"type": "string",
"description": "Output. Unique run ID generated by API server."
},
"display_name": {
"type": "string",
"description": "Required input field. Recurring run name provided by user. Not unique."
},
"description": {
"type": "string",
"description": "Optional input field. Describes the purpose of the recurring run."
},
"pipeline_id": {
"type": "string",
"description": "The ID of the pipeline user uploaded before."
},
"pipeline_spec": {
"type": "object",
"description": "The pipeline spec."
},
"runtime_config": {
"$ref": "#/definitions/v2beta1RuntimeConfig",
"description": "Runtime config of the pipeline."
},
"service_account": {
"type": "string",
"description": "Optional input field. Specifies which Kubernetes service account this recurring run uses."
},
"max_concurrency": {
"type": "string",
"format": "int64",
"description": "Required input field.\nSpecifies how many runs can be executed concurrently. Range [1-10]."
},
"trigger": {
"$ref": "#/definitions/v2beta1Trigger",
"description": "Required input field.\nSpecifies how a run is triggered. Support cron mode or periodic mode."
},
"mode": {
"$ref": "#/definitions/RecurringRunMode"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "Output. The time this recurring run was created."
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "Output. The last time this recurring run was updated."
},
"status": {
"$ref": "#/definitions/v2beta1RecurringRunStatus"
},
"error": {
"type": "string",
"description": "In case any error happens retrieving a recurring run field, only recurring run ID\nand the error message is returned. Client has the flexibility of choosing\nhow to handle the error. This is especially useful during listing call."
},
"no_catchup": {
"type": "boolean",
"format": "boolean",
"description": "Optional input field. Whether the recurring run should catch up if behind schedule.\nIf true, the recurring run will only schedule the latest interval if behind schedule.\nIf false, the recurring run will catch up on each past interval."
},
"namespace": {
"type": "string",
"description": "Namespace this recurring run belongs to."
},
"experiment_id": {
"type": "string",
"description": "ID of the experiment this recurring run belongs to."
}
}
},
"v2beta1RecurringRunStatus": {
"type": "string",
"enum": [
"STATUS_UNSPECIFIED",
"ENABLED",
"DISABLED"
],
"default": "STATUS_UNSPECIFIED",
"description": "Output. The status of the recurring run."
},
"v2beta1RuntimeConfig": {
"type": "object",
"properties": {
"parameters": {
"type": "object",
"additionalProperties": {
"type": "object"
},
"description": "The runtime parameters. The parameters will be used to replace \nthe placeholders at runtime."
},
"pipeline_root": {
"type": "string",
"title": "A path in a object store bucket which will be treated as the root\noutput directory of this run. It is used by the system to\ngenerate the paths of output artifacts. \nRef:(https://www.kubeflow.org/docs/components/pipelines/pipeline-root/)"
}
},
"description": "The runtime config of a run or recurring run."
},
"v2beta1Trigger": {
"type": "object",
"properties": {
"cron_schedule": {
"$ref": "#/definitions/v2beta1CronSchedule"
},
"periodic_schedule": {
"$ref": "#/definitions/v2beta1PeriodicSchedule"
}
},
"description": "Trigger defines what starts a pipeline run."
}
}
}

View File

@ -20,8 +20,8 @@ import (
"github.com/kubeflow/pipelines/backend/src/apiserver/template"
apiV1beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
apiV2beta1 "github.com/kubeflow/pipelines/backend/api/v2beta1/go_client"
apiv1beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
apiv2beta1 "github.com/kubeflow/pipelines/backend/api/v2beta1/go_client"
"github.com/kubeflow/pipelines/backend/src/apiserver/common"
"github.com/kubeflow/pipelines/backend/src/apiserver/model"
"github.com/kubeflow/pipelines/backend/src/common/util"
@ -33,21 +33,21 @@ func (r *ResourceManager) ToModelExperiment(inputExperiment interface{}) (*model
name := ""
description := ""
switch inputExperiment.(type) {
case *apiV1beta1.Experiment:
v1Experiment := inputExperiment.(*apiV1beta1.Experiment)
case *apiv1beta1.Experiment:
v1Experiment := inputExperiment.(*apiv1beta1.Experiment)
name = v1Experiment.GetName()
description = v1Experiment.GetDescription()
resourceReferences := v1Experiment.GetResourceReferences()
if resourceReferences != nil {
if len(resourceReferences) != 1 ||
resourceReferences[0].Key.Type != apiV1beta1.ResourceType_NAMESPACE ||
resourceReferences[0].Relationship != apiV1beta1.Relationship_OWNER {
resourceReferences[0].Key.Type != apiv1beta1.ResourceType_NAMESPACE ||
resourceReferences[0].Relationship != apiv1beta1.Relationship_OWNER {
return nil, util.NewInternalServerError(errors.New("Invalid resource references for experiment"), "Unable to convert to model experiment.")
}
namespace = resourceReferences[0].Key.Id
}
case *apiV2beta1.Experiment:
v2Experiment := inputExperiment.(*apiV2beta1.Experiment)
case *apiv2beta1.Experiment:
v2Experiment := inputExperiment.(*apiv2beta1.Experiment)
name = v2Experiment.GetDisplayName()
namespace = v2Experiment.GetNamespace()
description = v2Experiment.GetDescription()
@ -61,7 +61,7 @@ func (r *ResourceManager) ToModelExperiment(inputExperiment interface{}) (*model
}, nil
}
func (r *ResourceManager) ToModelRunMetric(metric *apiV1beta1.RunMetric, runUUID string) *model.RunMetric {
func (r *ResourceManager) ToModelRunMetric(metric *apiv1beta1.RunMetric, runUUID string) *model.RunMetric {
return &model.RunMetric{
RunUUID: runUUID,
Name: metric.GetName(),
@ -73,7 +73,7 @@ func (r *ResourceManager) ToModelRunMetric(metric *apiV1beta1.RunMetric, runUUID
// The input run might not contain workflowSpecManifest and pipelineSpecManifest, but instead a pipeline ID.
// The caller would retrieve manifest and pass in.
func (r *ResourceManager) ToModelRunDetail(run *apiV1beta1.Run, runId string, workflow util.ExecutionSpec, manifest string, templateType template.TemplateType) (*model.RunDetail, error) {
func (r *ResourceManager) ToModelRunDetail(run *apiv1beta1.Run, runId string, workflow util.ExecutionSpec, manifest string, templateType template.TemplateType) (*model.RunDetail, error) {
resourceReferences, err := r.toModelResourceReferences(runId, common.Run, run.GetResourceReferences())
if err != nil {
return nil, util.Wrap(err, "Unable to convert resource references.")
@ -110,6 +110,7 @@ func (r *ResourceManager) ToModelRunDetail(run *apiV1beta1.Run, runId string, wo
}
if templateType == template.V1 {
// Input template if of V1 type (argo)
params, err := apiParametersToModelParameters(run.GetPipelineSpec().GetParameters())
if err != nil {
return nil, util.Wrap(err, "Unable to parse the V1 parameter.")
@ -120,7 +121,8 @@ func (r *ResourceManager) ToModelRunDetail(run *apiV1beta1.Run, runId string, wo
return runDetail, nil
} else if templateType == template.V2 {
params, err := runtimeConfigToModelParameters(run.GetPipelineSpec().GetRuntimeConfig())
// Input template if of V2 type (IR)
params, err := runtimeConfigToModelParametersV1(run.GetPipelineSpec().GetRuntimeConfig())
if err != nil {
return nil, util.Wrap(err, "Unable to parse the V2 parameter.")
}
@ -130,22 +132,124 @@ func (r *ResourceManager) ToModelRunDetail(run *apiV1beta1.Run, runId string, wo
return runDetail, nil
} else {
return nil, fmt.Errorf("failed to generate RunDetail with templateType %s", templateType)
return nil, fmt.Errorf("failed to generate RunDetail with templateType %s.", templateType)
}
}
func (r *ResourceManager) ToModelJob(job *apiV1beta1.Job, swf *util.ScheduledWorkflow, manifest string, templateType template.TemplateType) (*model.Job, error) {
resourceReferences, err := r.toModelResourceReferences(string(swf.UID), common.Job, job.GetResourceReferences())
if err != nil {
return nil, util.Wrap(err, "Error to convert resource references.")
}
var pipelineName string
if job.GetPipelineSpec().GetPipelineId() != "" {
pipelineName, err = r.getResourceName(common.Pipeline, job.GetPipelineSpec().GetPipelineId())
func (r *ResourceManager) ToModelJob(jobInterface interface{}, manifest string, templateType template.TemplateType) (*model.Job, error) {
modelJob := &model.Job{}
switch jobInterface.(type) {
case *apiv1beta1.Job:
apiJob := jobInterface.(*apiv1beta1.Job)
// Add a reference to the default experiment if run does not already have a containing experiment
ref, err := r.getDefaultExperimentIfNoExperiment(apiJob.GetResourceReferences())
if err != nil {
return nil, util.Wrap(err, "Error getting the pipeline name")
return nil, err
}
if ref != nil {
apiJob.ResourceReferences = append(apiJob.GetResourceReferences(), ref)
}
namespace, err := r.getNamespaceFromExperiment(apiJob.GetResourceReferences())
if err != nil {
return nil, err
}
// Create model Resource References
resourceReferences, err := r.toModelResourceReferences("", common.Job, apiJob.GetResourceReferences())
if err != nil {
return nil, util.Wrap(err, "Error converting resource references.")
}
// Retrieve Pipeline name
var pipelineName string
if apiJob.GetPipelineSpec().GetPipelineId() != "" {
pipelineName, err = r.getResourceName(common.Pipeline, apiJob.GetPipelineSpec().GetPipelineId())
if err != nil {
return nil, util.Wrap(err, "Error getting the pipeline name.")
}
}
modelJob.Name = apiJob.Name
modelJob.DisplayName = apiJob.Name
modelJob.Description = apiJob.Description
modelJob.Enabled = apiJob.Enabled
modelJob.Namespace = namespace
modelJob.Trigger = toModelTriggerV1(apiJob.Trigger)
modelJob.MaxConcurrency = apiJob.MaxConcurrency
modelJob.NoCatchup = apiJob.NoCatchup
modelJob.ResourceReferences = resourceReferences
modelJob.ServiceAccount = apiJob.ServiceAccount
modelJob.PipelineSpec = model.PipelineSpec{
PipelineId: apiJob.GetPipelineSpec().GetPipelineId(),
PipelineName: pipelineName,
}
if templateType == template.V1 {
// Input template if of V1 type (argo)
params, err := apiParametersToModelParameters(apiJob.GetPipelineSpec().GetParameters())
if err != nil {
return nil, util.Wrap(err, "Unable to parse the parameters.")
}
modelJob.Parameters = params
modelJob.WorkflowSpecManifest = manifest
} else if templateType == template.V2 {
// Input template if of V2 type (IR)
params, err := runtimeConfigToModelParametersV1(apiJob.GetPipelineSpec().GetRuntimeConfig())
if err != nil {
return nil, util.Wrap(err, "Unable to parse the parameters inside runtimeConfig.")
}
modelJob.PipelineSpecManifest = manifest
modelJob.PipelineSpec.RuntimeConfig.Parameters = params
modelJob.PipelineSpec.RuntimeConfig.PipelineRoot = apiJob.GetPipelineSpec().GetRuntimeConfig().GetPipelineRoot()
} else {
return nil, fmt.Errorf("failed to generate ModelJob with templateType %s", templateType)
}
case *apiv2beta1.RecurringRun:
apiRecurringRun := jobInterface.(*apiv2beta1.RecurringRun)
// Retrieve Pipeline name
var pipelineName string
var err error
if apiRecurringRun.GetPipelineId() != "" {
pipelineName, err = r.getResourceName(common.Pipeline, apiRecurringRun.GetPipelineId())
if err != nil {
return nil, util.Wrap(err, "Error getting the pipeline name.")
}
}
modelJob.DisplayName = apiRecurringRun.DisplayName
modelJob.Name = apiRecurringRun.DisplayName
modelJob.Description = apiRecurringRun.Description
modelJob.Enabled = modeToModelEnabled(apiRecurringRun.Mode)
modelJob.Trigger, err = toModelTriggerV2(apiRecurringRun.Trigger)
if err != nil {
return nil, util.Wrap(err, "Cannot convert RecurringRun Trigger.")
}
modelJob.MaxConcurrency = apiRecurringRun.MaxConcurrency
modelJob.NoCatchup = apiRecurringRun.NoCatchup
modelJob.ServiceAccount = apiRecurringRun.ServiceAccount
namespace, err := r.GetNamespaceFromExperimentID(apiRecurringRun.ExperimentId)
modelJob.Namespace = namespace
modelJob.PipelineSpec = model.PipelineSpec{
PipelineId: apiRecurringRun.GetPipelineId(),
PipelineName: pipelineName,
}
params, err := runtimeConfigToModelParameters(apiRecurringRun.GetRuntimeConfig())
if err != nil {
return nil, util.Wrap(err, "Unable to parse the parameters inside runtimeConfig.")
}
modelJob.PipelineSpecManifest = manifest
modelJob.PipelineSpec.RuntimeConfig.Parameters = params
modelJob.PipelineSpec.RuntimeConfig.PipelineRoot = apiRecurringRun.GetRuntimeConfig().GetPipelineRoot()
default:
return nil, util.NewInvalidInputError("Wrong Api Job type.")
}
return modelJob, nil
}
func (r *ResourceManager) updateModelJobWithNewScheduledWorkflow(modelJob *model.Job, swf *util.ScheduledWorkflow) error {
modelJob.UUID = string(swf.UID)
modelJob.Name = swf.Name
modelJob.Namespace = swf.Namespace
modelJob.Conditions = swf.ConditionSummary()
r.updateJobResourceReferences(string(swf.UID), modelJob)
serviceAccount := ""
if swf.Spec.Workflow != nil {
execSpec, err := util.ScheduleSpecToExecutionSpec(util.ArgoWorkflow, swf.Spec.Workflow)
@ -153,49 +257,50 @@ func (r *ResourceManager) ToModelJob(job *apiV1beta1.Job, swf *util.ScheduledWor
serviceAccount = execSpec.ServiceAccount()
}
}
modelJob := &model.Job{
UUID: string(swf.UID),
DisplayName: job.Name,
Name: swf.Name,
Namespace: swf.Namespace,
ServiceAccount: serviceAccount,
Description: job.Description,
Conditions: swf.ConditionSummary(),
Enabled: job.Enabled,
Trigger: toModelTrigger(job.Trigger),
MaxConcurrency: job.MaxConcurrency,
NoCatchup: job.NoCatchup,
ResourceReferences: resourceReferences,
PipelineSpec: model.PipelineSpec{
PipelineId: job.GetPipelineSpec().GetPipelineId(),
PipelineName: pipelineName,
}}
if templateType == template.V1 {
params, err := apiParametersToModelParameters(job.GetPipelineSpec().GetParameters())
if err != nil {
return nil, util.Wrap(err, "Unable to parse the parameters.")
}
modelJob.Parameters = params
modelJob.WorkflowSpecManifest = manifest
return modelJob, nil
} else if templateType == template.V2 {
params, err := runtimeConfigToModelParameters(job.GetPipelineSpec().GetRuntimeConfig())
if err != nil {
return nil, util.Wrap(err, "Unable to parse the parameters inside runtimeConfig.")
}
modelJob.PipelineSpecManifest = manifest
modelJob.PipelineSpec.RuntimeConfig.Parameters = params
modelJob.PipelineSpec.RuntimeConfig.PipelineRoot = job.GetPipelineSpec().GetRuntimeConfig().GetPipelineRoot()
return modelJob, nil
modelJob.ServiceAccount = serviceAccount
return nil
}
func modeToModelEnabled(v2APIMode apiv2beta1.RecurringRun_Mode) bool {
// Returns false if status is disable or unspecified.
if v2APIMode == apiv2beta1.RecurringRun_ENABLE {
return true
} else {
return nil, fmt.Errorf("failed to generate ModelJob with templateType %s", templateType)
return false
}
}
func (r *ResourceManager) ToModelPipelineVersion(version *apiV1beta1.PipelineVersion) (*model.PipelineVersion, error) {
func toModelTriggerV2(v2APITrigger *apiv2beta1.Trigger) (model.Trigger, error) {
modelTrigger := model.Trigger{}
if v2APITrigger == nil {
return modelTrigger, nil
}
if v2APITrigger.GetCronSchedule() != nil {
cronSchedule := v2APITrigger.GetCronSchedule()
modelTrigger.CronSchedule = model.CronSchedule{Cron: &cronSchedule.Cron}
if cronSchedule.StartTime != nil {
modelTrigger.CronScheduleStartTimeInSec = &cronSchedule.StartTime.Seconds
}
if cronSchedule.EndTime != nil {
modelTrigger.CronScheduleEndTimeInSec = &cronSchedule.EndTime.Seconds
}
}
if v2APITrigger.GetPeriodicSchedule() != nil {
periodicSchedule := v2APITrigger.GetPeriodicSchedule()
modelTrigger.PeriodicSchedule = model.PeriodicSchedule{
IntervalSecond: &periodicSchedule.IntervalSecond}
if v2APITrigger.GetPeriodicSchedule().StartTime != nil {
modelTrigger.PeriodicScheduleStartTimeInSec = &periodicSchedule.StartTime.Seconds
}
if v2APITrigger.GetPeriodicSchedule().EndTime != nil {
modelTrigger.PeriodicScheduleEndTimeInSec = &periodicSchedule.EndTime.Seconds
}
}
return modelTrigger, nil
}
func (r *ResourceManager) ToModelPipelineVersion(version *apiv1beta1.PipelineVersion) (*model.PipelineVersion, error) {
paramStr, err := apiParametersToModelParameters(version.Parameters)
if err != nil {
return nil, err
@ -203,7 +308,7 @@ func (r *ResourceManager) ToModelPipelineVersion(version *apiV1beta1.PipelineVer
var pipelineId string
for _, resourceReference := range version.ResourceReferences {
if resourceReference.Key.Type == apiV1beta1.ResourceType_PIPELINE {
if resourceReference.Key.Type == apiv1beta1.ResourceType_PIPELINE {
pipelineId = resourceReference.Key.Id
}
}
@ -218,7 +323,7 @@ func (r *ResourceManager) ToModelPipelineVersion(version *apiV1beta1.PipelineVer
}, nil
}
func toModelTrigger(trigger *apiV1beta1.Trigger) model.Trigger {
func toModelTriggerV1(trigger *apiv1beta1.Trigger) model.Trigger {
modelTrigger := model.Trigger{}
if trigger == nil {
return modelTrigger
@ -248,7 +353,7 @@ func toModelTrigger(trigger *apiV1beta1.Trigger) model.Trigger {
return modelTrigger
}
func apiParametersToModelParameters(apiParams []*apiV1beta1.Parameter) (string, error) {
func apiParametersToModelParameters(apiParams []*apiv1beta1.Parameter) (string, error) {
if apiParams == nil || len(apiParams) == 0 {
return "", nil
}
@ -267,7 +372,18 @@ func apiParametersToModelParameters(apiParams []*apiV1beta1.Parameter) (string,
return string(paramsBytes), nil
}
func runtimeConfigToModelParameters(runtimeConfig *apiV1beta1.PipelineSpec_RuntimeConfig) (string, error) {
func runtimeConfigToModelParametersV1(runtimeConfig *apiv1beta1.PipelineSpec_RuntimeConfig) (string, error) {
if runtimeConfig == nil {
return "", nil
}
paramsBytes, err := json.Marshal(runtimeConfig.GetParameters())
if err != nil {
return "", util.NewInternalServerError(err, "Failed to marshal RuntimeConfig API parameters as string.")
}
return string(paramsBytes), nil
}
func runtimeConfigToModelParameters(runtimeConfig *apiv2beta1.RuntimeConfig) (string, error) {
if runtimeConfig == nil {
return "", nil
}
@ -279,7 +395,7 @@ func runtimeConfigToModelParameters(runtimeConfig *apiV1beta1.PipelineSpec_Runti
}
func (r *ResourceManager) toModelResourceReferences(
resourceId string, resourceType model.ResourceType, apiRefs []*apiV1beta1.ResourceReference) ([]*model.ResourceReference, error) {
resourceId string, resourceType model.ResourceType, apiRefs []*apiv1beta1.ResourceReference) ([]*model.ResourceReference, error) {
var modelRefs []*model.ResourceReference
for _, apiRef := range apiRefs {
modelReferenceType, err := common.ToModelResourceType(apiRef.Key.Type)
@ -326,7 +442,7 @@ func (r *ResourceManager) getResourceName(resourceType model.ResourceType, resou
case common.Job:
job, err := r.GetJob(resourceId)
if err != nil {
return "", util.Wrap(err, "Referred job not found.")
return "", util.NewInvalidInputError("Referred job not found.")
}
return job.DisplayName, nil
case common.Run:
@ -348,10 +464,10 @@ func (r *ResourceManager) getResourceName(resourceType model.ResourceType, resou
}
}
func (r *ResourceManager) getOwningExperimentUUID(references []*apiV1beta1.ResourceReference) (string, error) {
func (r *ResourceManager) getOwningExperimentUUID(references []*apiv1beta1.ResourceReference) (string, error) {
var experimentUUID string
for _, ref := range references {
if ref.Key.Type == apiV1beta1.ResourceType_EXPERIMENT && ref.Relationship == apiV1beta1.Relationship_OWNER {
if ref.Key.Type == apiv1beta1.ResourceType_EXPERIMENT && ref.Relationship == apiv1beta1.Relationship_OWNER {
experimentUUID = ref.Key.Id
break
}

View File

@ -25,8 +25,8 @@ import (
"google.golang.org/protobuf/types/known/structpb"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
apiV1beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
apiV2beta1 "github.com/kubeflow/pipelines/backend/api/v2beta1/go_client"
apiv1beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
apiv2beta1 "github.com/kubeflow/pipelines/backend/api/v2beta1/go_client"
"github.com/kubeflow/pipelines/backend/src/apiserver/common"
"github.com/kubeflow/pipelines/backend/src/apiserver/model"
"github.com/kubeflow/pipelines/backend/src/apiserver/template"
@ -52,7 +52,7 @@ func TestToModelExperiment(t *testing.T) {
}{
{
"API V1beta1: No resource references",
&apiV1beta1.Experiment{
&apiv1beta1.Experiment{
Name: "exp1",
Description: "This is an experiment",
},
@ -66,16 +66,16 @@ func TestToModelExperiment(t *testing.T) {
},
{
"API V1beta1: Valid resource references",
&apiV1beta1.Experiment{
&apiv1beta1.Experiment{
Name: "exp1",
Description: "This is an experiment",
ResourceReferences: []*apiV1beta1.ResourceReference{
&apiV1beta1.ResourceReference{
Key: &apiV1beta1.ResourceKey{
Type: apiV1beta1.ResourceType_NAMESPACE,
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Type: apiv1beta1.ResourceType_NAMESPACE,
Id: "ns1",
},
Relationship: apiV1beta1.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
},
@ -89,16 +89,16 @@ func TestToModelExperiment(t *testing.T) {
},
{
"API V1beta1: Invalid resource references",
&apiV1beta1.Experiment{
&apiv1beta1.Experiment{
Name: "exp1",
Description: "This is an experiment",
ResourceReferences: []*apiV1beta1.ResourceReference{
&apiV1beta1.ResourceReference{
Key: &apiV1beta1.ResourceKey{
Type: apiV1beta1.ResourceType_EXPERIMENT,
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Type: apiv1beta1.ResourceType_EXPERIMENT,
Id: "invalid",
},
Relationship: apiV1beta1.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
},
@ -108,7 +108,7 @@ func TestToModelExperiment(t *testing.T) {
},
{
"API V2beta1: Happy pass",
&apiV2beta1.Experiment{
&apiv2beta1.Experiment{
DisplayName: "exp2",
Description: "API V2beta1 test experiment",
Namespace: "ns2",
@ -155,13 +155,13 @@ func TestToModelExperiment(t *testing.T) {
func TestToModelRunMetric(t *testing.T) {
store, manager := initResourceManager()
defer store.Close()
apiRunMetric := &apiV1beta1.RunMetric{
apiRunMetric := &apiv1beta1.RunMetric{
Name: "metric-1",
NodeId: "node-1",
Value: &apiV1beta1.RunMetric_NumberValue{
Value: &apiv1beta1.RunMetric_NumberValue{
NumberValue: 0.88,
},
Format: apiV1beta1.RunMetric_RAW,
Format: apiv1beta1.RunMetric_RAW,
}
actualModelRunMetric := manager.ToModelRunMetric(apiRunMetric, "run-1")
@ -197,7 +197,7 @@ func TestToModelRunDetail(t *testing.T) {
tests := []struct {
name string
apiRun *apiV1beta1.Run
apiRun *apiv1beta1.Run
workflow *util.Workflow
manifest string
templateType template.TemplateType
@ -205,17 +205,17 @@ func TestToModelRunDetail(t *testing.T) {
}{
{
name: "v1",
apiRun: &apiV1beta1.Run{
apiRun: &apiv1beta1.Run{
Id: "run1",
Name: "name1",
Description: "this is a run",
PipelineSpec: &apiV1beta1.PipelineSpec{
Parameters: []*apiV1beta1.Parameter{{Name: "param2", Value: "world"}},
PipelineSpec: &apiv1beta1.PipelineSpec{
Parameters: []*apiv1beta1.Parameter{{Name: "param2", Value: "world"}},
},
ResourceReferences: []*apiV1beta1.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiV1beta1.Relationship_OWNER}},
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiv1beta1.Relationship_OWNER}},
},
workflow: util.NewWorkflow(&v1alpha1.Workflow{
ObjectMeta: v1.ObjectMeta{Name: "workflow-name", UID: "123"},
@ -255,18 +255,18 @@ func TestToModelRunDetail(t *testing.T) {
},
{
name: "v2",
apiRun: &apiV1beta1.Run{
apiRun: &apiv1beta1.Run{
Id: "run1",
Name: "name1",
Description: "this is a run",
PipelineSpec: &apiV1beta1.PipelineSpec{
RuntimeConfig: &apiV1beta1.PipelineSpec_RuntimeConfig{
PipelineSpec: &apiv1beta1.PipelineSpec{
RuntimeConfig: &apiv1beta1.PipelineSpec_RuntimeConfig{
Parameters: v2RuntimeParams,
}},
ResourceReferences: []*apiV1beta1.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiV1beta1.Relationship_OWNER}},
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiv1beta1.Relationship_OWNER}},
},
workflow: util.NewWorkflow(&v1alpha1.Workflow{
ObjectMeta: v1.ObjectMeta{Name: "workflow-name", UID: "123"},
@ -318,45 +318,34 @@ func TestToModelJob(t *testing.T) {
tests := []struct {
name string
apiJob *apiV1beta1.Job
swf *util.ScheduledWorkflow
jobInterface interface{}
manifest string
templateType template.TemplateType
expectedModelJob *model.Job
}{
{name: "v1",
apiJob: &apiV1beta1.Job{
{
name: "v1api v1template",
jobInterface: &apiv1beta1.Job{
Name: "name1",
Enabled: true,
MaxConcurrency: 1,
NoCatchup: true,
Trigger: &apiV1beta1.Trigger{
Trigger: &apiV1beta1.Trigger_CronSchedule{CronSchedule: &apiV1beta1.CronSchedule{
Trigger: &apiv1beta1.Trigger{
Trigger: &apiv1beta1.Trigger_CronSchedule{CronSchedule: &apiv1beta1.CronSchedule{
StartTime: &timestamp.Timestamp{Seconds: 1},
Cron: "1 * * * *",
}}},
ResourceReferences: []*apiV1beta1.ResourceReference{
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID}, Relationship: apiV1beta1.Relationship_OWNER},
ResourceReferences: []*apiv1beta1.ResourceReference{
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID}, Relationship: apiv1beta1.Relationship_OWNER},
},
PipelineSpec: &apiV1beta1.PipelineSpec{PipelineId: pipeline.UUID, Parameters: []*apiV1beta1.Parameter{{Name: "param2", Value: "world"}}},
PipelineSpec: &apiv1beta1.PipelineSpec{PipelineId: pipeline.UUID, Parameters: []*apiv1beta1.Parameter{{Name: "param2", Value: "world"}}},
},
swf: util.NewScheduledWorkflow(&swfapi.ScheduledWorkflow{
ObjectMeta: v1.ObjectMeta{
Name: "swf_name",
Namespace: "swf_namespace",
UID: "swf_123",
},
Status: swfapi.ScheduledWorkflowStatus{
Conditions: []swfapi.ScheduledWorkflowCondition{{Type: swfapi.ScheduledWorkflowEnabled}}},
}),
manifest: "workflow spec",
templateType: template.V1,
expectedModelJob: &model.Job{
UUID: "swf_123",
Name: "swf_name",
Namespace: "swf_namespace",
Conditions: "Enabled",
DisplayName: "name1",
Name: "name1",
Namespace: "ns1",
Enabled: true,
Trigger: model.Trigger{
CronSchedule: model.CronSchedule{
@ -374,7 +363,6 @@ func TestToModelJob(t *testing.T) {
},
ResourceReferences: []*model.ResourceReference{
{
ResourceUUID: "swf_123",
ResourceType: common.Job,
ReferenceUUID: experiment.UUID,
ReferenceName: experiment.Name,
@ -382,41 +370,31 @@ func TestToModelJob(t *testing.T) {
Relationship: common.Owner},
},
},
},
{name: "v2",
apiJob: &apiV1beta1.Job{
}, {
name: "v1api v2template",
jobInterface: &apiv1beta1.Job{
Name: "name1",
Enabled: true,
MaxConcurrency: 1,
NoCatchup: true,
Trigger: &apiV1beta1.Trigger{
Trigger: &apiV1beta1.Trigger_CronSchedule{CronSchedule: &apiV1beta1.CronSchedule{
Trigger: &apiv1beta1.Trigger{
Trigger: &apiv1beta1.Trigger_CronSchedule{CronSchedule: &apiv1beta1.CronSchedule{
StartTime: &timestamp.Timestamp{Seconds: 1},
Cron: "1 * * * *",
}}},
ResourceReferences: []*apiV1beta1.ResourceReference{
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID}, Relationship: apiV1beta1.Relationship_OWNER},
ResourceReferences: []*apiv1beta1.ResourceReference{
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID}, Relationship: apiv1beta1.Relationship_OWNER},
},
PipelineSpec: &apiV1beta1.PipelineSpec{PipelineId: pipeline.UUID, RuntimeConfig: &apiV1beta1.PipelineSpec_RuntimeConfig{Parameters: map[string]*structpb.Value{
"param2": &structpb.Value{Kind: &structpb.Value_StringValue{StringValue: "world"}},
}}},
PipelineSpec: &apiv1beta1.PipelineSpec{PipelineId: pipeline.UUID,
RuntimeConfig: &apiv1beta1.PipelineSpec_RuntimeConfig{Parameters: map[string]*structpb.Value{
"param2": &structpb.Value{Kind: &structpb.Value_StringValue{StringValue: "world"}},
}}},
},
swf: util.NewScheduledWorkflow(&swfapi.ScheduledWorkflow{
ObjectMeta: v1.ObjectMeta{
Name: "swf_name",
Namespace: "swf_namespace",
UID: "swf_123",
},
Status: swfapi.ScheduledWorkflowStatus{
Conditions: []swfapi.ScheduledWorkflowCondition{{Type: swfapi.ScheduledWorkflowEnabled}}},
}),
manifest: "pipeline spec",
templateType: template.V2,
expectedModelJob: &model.Job{
UUID: "swf_123",
Name: "swf_name",
Namespace: "swf_namespace",
Conditions: "Enabled",
Name: "name1",
Namespace: "ns1",
DisplayName: "name1",
Enabled: true,
Trigger: model.Trigger{
@ -437,7 +415,6 @@ func TestToModelJob(t *testing.T) {
},
ResourceReferences: []*model.ResourceReference{
{
ResourceUUID: "swf_123",
ResourceType: common.Job,
ReferenceUUID: experiment.UUID,
ReferenceName: experiment.Name,
@ -449,26 +426,110 @@ func TestToModelJob(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
modelJob, err := manager.ToModelJob(tt.apiJob, tt.swf, tt.manifest, tt.templateType)
modelJob, err := manager.ToModelJob(tt.jobInterface, tt.manifest, tt.templateType)
assert.Nil(t, err)
assert.Equal(t, tt.expectedModelJob, modelJob)
})
}
}
func TestToModelResourceReferences(t *testing.T) {
store, manager, job := initWithJob(t)
func TestUpdateModelJobWithNewScheduledWorkflow(t *testing.T) {
store, manager, experiment, pipeline := initWithExperimentAndPipeline(t)
defer store.Close()
refs, err := manager.toModelResourceReferences("r1", common.Run, []*apiV1beta1.ResourceReference{
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_EXPERIMENT, Id: DefaultFakeUUID}, Relationship: apiV1beta1.Relationship_OWNER},
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_JOB, Id: job.UUID}, Relationship: apiV1beta1.Relationship_CREATOR},
modelJob := &model.Job{
Name: "name1",
Namespace: "ns1",
DisplayName: "name1",
Enabled: true,
Trigger: model.Trigger{
CronSchedule: model.CronSchedule{
CronScheduleStartTimeInSec: util.Int64Pointer(1),
Cron: util.StringPointer("1 * * * *"),
},
},
MaxConcurrency: 1,
NoCatchup: true,
PipelineSpec: model.PipelineSpec{
PipelineId: pipeline.UUID,
PipelineName: pipeline.Name,
PipelineSpecManifest: "pipeline spec",
RuntimeConfig: model.RuntimeConfig{
Parameters: "{\"param2\":\"world\"}",
},
},
ResourceReferences: []*model.ResourceReference{
{
ResourceType: common.Job,
ReferenceUUID: experiment.UUID,
ReferenceName: experiment.Name,
ReferenceType: common.Experiment,
Relationship: common.Owner},
},
}
swf := util.NewScheduledWorkflow(&swfapi.ScheduledWorkflow{
ObjectMeta: v1.ObjectMeta{
Name: "swf_name",
Namespace: "swf_namespace",
UID: "swf_123",
},
Status: swfapi.ScheduledWorkflowStatus{
Conditions: []swfapi.ScheduledWorkflowCondition{{Type: swfapi.ScheduledWorkflowEnabled}}},
})
expectedModelJob := &model.Job{
UUID: "swf_123",
Name: "swf_name",
Namespace: "swf_namespace",
DisplayName: "name1",
Enabled: true,
Conditions: "Enabled",
Trigger: model.Trigger{
CronSchedule: model.CronSchedule{
CronScheduleStartTimeInSec: util.Int64Pointer(1),
Cron: util.StringPointer("1 * * * *"),
},
},
MaxConcurrency: 1,
NoCatchup: true,
PipelineSpec: model.PipelineSpec{
PipelineId: pipeline.UUID,
PipelineName: pipeline.Name,
PipelineSpecManifest: "pipeline spec",
RuntimeConfig: model.RuntimeConfig{
Parameters: "{\"param2\":\"world\"}",
},
},
ResourceReferences: []*model.ResourceReference{
{
ResourceUUID: "swf_123",
ResourceType: common.Job,
ReferenceUUID: experiment.UUID,
ReferenceName: experiment.Name,
ReferenceType: common.Experiment,
Relationship: common.Owner},
},
}
err := manager.updateModelJobWithNewScheduledWorkflow(modelJob, swf)
assert.Nil(t, err)
assert.Equal(t, expectedModelJob, modelJob)
}
func TestToModelResourceReferences(t *testing.T) {
store, manager, _ := initWithJob(t)
defer store.Close()
refs, err := manager.toModelResourceReferences("r1", common.Run, []*apiv1beta1.ResourceReference{
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: DefaultFakeUUID}, Relationship: apiv1beta1.Relationship_OWNER},
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_JOB, Id: DefaultFakeUUID}, Relationship: apiv1beta1.Relationship_CREATOR},
})
assert.Nil(t, err)
expectedRefs := []*model.ResourceReference{
{ResourceUUID: "r1", ResourceType: common.Run,
ReferenceUUID: DefaultFakeUUID, ReferenceName: "e1", ReferenceType: common.Experiment, Relationship: common.Owner},
{ResourceUUID: "r1", ResourceType: common.Run,
ReferenceUUID: job.UUID, ReferenceName: "j1", ReferenceType: common.Job, Relationship: common.Creator},
ReferenceUUID: DefaultFakeUUID, ReferenceName: "j1", ReferenceType: common.Job, Relationship: common.Creator},
}
assert.Equal(t, expectedRefs, refs)
}
@ -477,9 +538,9 @@ func TestToModelResourceReferences_UnknownRefType(t *testing.T) {
store, manager, _ := initWithJob(t)
defer store.Close()
_, err := manager.toModelResourceReferences("r1", common.Run, []*apiV1beta1.ResourceReference{
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_UNKNOWN_RESOURCE_TYPE, Id: "e1"}, Relationship: apiV1beta1.Relationship_OWNER},
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_JOB, Id: "j1"}, Relationship: apiV1beta1.Relationship_CREATOR},
_, err := manager.toModelResourceReferences("r1", common.Run, []*apiv1beta1.ResourceReference{
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_UNKNOWN_RESOURCE_TYPE, Id: "e1"}, Relationship: apiv1beta1.Relationship_OWNER},
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_JOB, Id: "j1"}, Relationship: apiv1beta1.Relationship_CREATOR},
})
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Failed to convert reference type")
@ -489,8 +550,8 @@ func TestToModelResourceReferences_NamespaceRef(t *testing.T) {
store, manager, _ := initWithJob(t)
defer store.Close()
modelRefs, err := manager.toModelResourceReferences("r1", common.Run, []*apiV1beta1.ResourceReference{
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_NAMESPACE, Id: "e1"}, Relationship: apiV1beta1.Relationship_OWNER},
modelRefs, err := manager.toModelResourceReferences("r1", common.Run, []*apiv1beta1.ResourceReference{
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_NAMESPACE, Id: "e1"}, Relationship: apiv1beta1.Relationship_OWNER},
})
assert.Nil(t, err)
assert.Equal(t, 1, len(modelRefs))
@ -499,9 +560,9 @@ func TestToModelResourceReferences_NamespaceRef(t *testing.T) {
func TestToModelResourceReferences_UnknownRelationship(t *testing.T) {
store, manager, _ := initWithJob(t)
defer store.Close()
_, err := manager.toModelResourceReferences("r1", common.Run, []*apiV1beta1.ResourceReference{
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_EXPERIMENT, Id: "e1"}, Relationship: apiV1beta1.Relationship_UNKNOWN_RELATIONSHIP},
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_JOB, Id: "j1"}, Relationship: apiV1beta1.Relationship_CREATOR},
_, err := manager.toModelResourceReferences("r1", common.Run, []*apiv1beta1.ResourceReference{
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: "e1"}, Relationship: apiv1beta1.Relationship_UNKNOWN_RELATIONSHIP},
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_JOB, Id: "j1"}, Relationship: apiv1beta1.Relationship_CREATOR},
})
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Failed to convert relationship")
@ -510,9 +571,9 @@ func TestToModelResourceReferences_UnknownRelationship(t *testing.T) {
func TestToModelResourceReferences_ReferredJobNotFound(t *testing.T) {
store, manager, _ := initWithJob(t)
defer store.Close()
_, err := manager.toModelResourceReferences("r1", common.Run, []*apiV1beta1.ResourceReference{
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_EXPERIMENT, Id: "e1"}, Relationship: apiV1beta1.Relationship_OWNER},
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_JOB, Id: "j2"}, Relationship: apiV1beta1.Relationship_CREATOR},
_, err := manager.toModelResourceReferences("r1", common.Run, []*apiv1beta1.ResourceReference{
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: "e1"}, Relationship: apiv1beta1.Relationship_OWNER},
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_JOB, Id: "j2"}, Relationship: apiv1beta1.Relationship_CREATOR},
})
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Failed to find the referred resource")
@ -521,9 +582,9 @@ func TestToModelResourceReferences_ReferredJobNotFound(t *testing.T) {
func TestToModelResourceReferences_ReferredExperimentNotFound(t *testing.T) {
store, manager, _ := initWithJob(t)
defer store.Close()
_, err := manager.toModelResourceReferences("r1", common.Run, []*apiV1beta1.ResourceReference{
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_EXPERIMENT, Id: "e2"}, Relationship: apiV1beta1.Relationship_OWNER},
{Key: &apiV1beta1.ResourceKey{Type: apiV1beta1.ResourceType_JOB, Id: "j1"}, Relationship: apiV1beta1.Relationship_CREATOR},
_, err := manager.toModelResourceReferences("r1", common.Run, []*apiv1beta1.ResourceReference{
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: "e2"}, Relationship: apiv1beta1.Relationship_OWNER},
{Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_JOB, Id: "j1"}, Relationship: apiv1beta1.Relationship_CREATOR},
})
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Failed to find the referred resource")
@ -532,18 +593,18 @@ func TestToModelResourceReferences_ReferredExperimentNotFound(t *testing.T) {
func TestToModelPipelineVersion(t *testing.T) {
store, manager := initResourceManager()
defer store.Close()
apiPipelineVersion := &apiV1beta1.PipelineVersion{
apiPipelineVersion := &apiv1beta1.PipelineVersion{
Id: "pipelineversion1",
CreatedAt: &timestamp.Timestamp{Seconds: 1},
Parameters: []*apiV1beta1.Parameter{},
Parameters: []*apiv1beta1.Parameter{},
CodeSourceUrl: "http://repo/11111",
ResourceReferences: []*apiV1beta1.ResourceReference{
&apiV1beta1.ResourceReference{
Key: &apiV1beta1.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: "pipeline1",
Type: apiV1beta1.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: apiV1beta1.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}

View File

@ -23,8 +23,8 @@ import (
"github.com/cenkalti/backoff"
"github.com/golang/glog"
apiV1beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
// apiV2beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
apiv1beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
apiv2beta1 "github.com/kubeflow/pipelines/backend/api/v2beta1/go_client"
"github.com/kubeflow/pipelines/backend/src/apiserver/archive"
kfpauth "github.com/kubeflow/pipelines/backend/src/apiserver/auth"
"github.com/kubeflow/pipelines/backend/src/apiserver/client"
@ -334,13 +334,13 @@ func (r *ResourceManager) GetPipelineTemplate(pipelineId string) ([]byte, error)
return template, nil
}
func (r *ResourceManager) CreateRun(ctx context.Context, apiRun *apiV1beta1.Run) (*model.RunDetail, error) {
func (r *ResourceManager) CreateRun(ctx context.Context, apiRun *apiv1beta1.Run) (*model.RunDetail, error) {
// Get manifest from either of the two places:
// (1) raw manifest in pipeline_spec
// (2) pipeline version in resource_references
// And the latter takes priority over the former when the manifest is from pipeline_spec.pipeline_id
// workflow/pipeline manifest and pipeline id/version will not exist at the same time, guaranteed by the validation phase
manifestBytes, err := getManifestBytes(apiRun.PipelineSpec, &apiRun.ResourceReferences, r)
manifestBytes, err := getManifestBytesV1(apiRun.PipelineSpec, &apiRun.ResourceReferences, r)
if err != nil {
return nil, err
}
@ -472,7 +472,7 @@ func (r *ResourceManager) DeleteRun(ctx context.Context, runID string) error {
return nil
}
func (r *ResourceManager) CreateTask(ctx context.Context, apiTask *apiV1beta1.Task) (*model.Task, error) {
func (r *ResourceManager) CreateTask(ctx context.Context, apiTask *apiv1beta1.Task) (*model.Task, error) {
uuid, err := r.uuid.NewRandom()
if err != nil {
return nil, util.NewInternalServerError(err, "Failed to generate task ID.")
@ -688,54 +688,60 @@ func (r *ResourceManager) GetJob(id string) (*model.Job, error) {
return r.jobStore.GetJob(id)
}
func (r *ResourceManager) CreateJob(ctx context.Context, apiJob *apiV1beta1.Job) (*model.Job, error) {
// Get workflow from either of the two places:
func (r *ResourceManager) CreateJob(ctx context.Context, apiJobInterface interface{}) (*model.Job, error) {
// Get pipeline manifest from either of the two places:
// (1) raw pipeline manifest in pipeline_spec
// (2) pipeline version in resource_references
// (2) pipeline id
// And the latter takes priority over the former when the pipeline manifest is from pipeline_spec.pipeline_id
// workflow manifest and pipeline id/version will not exist at the same time, guaranteed by the validation phase
manifestBytes, err := getManifestBytes(apiJob.PipelineSpec, &apiJob.ResourceReferences, r)
// TODO(lingqinggan): Add get pipeline from pipeline version.
manifestBytes, err := getManifestBytesfromAPIJobInterface(apiJobInterface, r)
if err != nil {
return nil, err
return nil, util.Wrap(err, "Error getting manifest Bytes from api job")
}
tmpl, err := template.New(manifestBytes)
if err != nil {
return nil, err
return nil, util.Wrap(err, "Error creating new template")
}
scheduledWorkflow, err := tmpl.ScheduledWorkflow(apiJob)
// Convert apiJob, either v1 or v2, to model Job.
modelJob, err := r.ToModelJob(apiJobInterface, string(manifestBytes), tmpl.GetTemplateType())
if err != nil {
return nil, util.Wrap(err, "failed to generate the scheduledWorkflow.")
}
// Add a reference to the default experiment if run does not already have a containing experiment
ref, err := r.getDefaultExperimentIfNoExperiment(apiJob.GetResourceReferences())
if err != nil {
return nil, err
}
if ref != nil {
apiJob.ResourceReferences = append(apiJob.GetResourceReferences(), ref)
return nil, util.Wrap(err, "Error creating model job")
}
namespace, err := r.getNamespaceFromExperiment(apiJob.GetResourceReferences())
// Convert modelJob into scheduledWorkflow.
scheduledWorkflow, err := tmpl.ScheduledWorkflow(modelJob)
if err != nil {
return nil, err
return nil, util.Wrap(err, "Failed to generate the scheduledWorkflow")
}
newScheduledWorkflow, err := r.getScheduledWorkflowClient(namespace).Create(ctx, scheduledWorkflow)
// Create a new ScheduledWorkflow at the ScheduledWorkflow client.
newScheduledWorkflow, err := r.getScheduledWorkflowClient(modelJob.Namespace).Create(ctx, scheduledWorkflow)
if err != nil {
return nil, util.NewInternalServerError(err, "Failed to create a scheduled workflow for (%s)", scheduledWorkflow.Name)
return nil, util.Wrap(err, "Failed to create a scheduled workflow")
}
job, err := r.ToModelJob(apiJob, util.NewScheduledWorkflow(newScheduledWorkflow), string(manifestBytes), tmpl.GetTemplateType())
// Complete modelJob with info coming back from ScheduledWorkflow client.
err = r.updateModelJobWithNewScheduledWorkflow(modelJob, util.NewScheduledWorkflow(newScheduledWorkflow))
if err != nil {
return nil, util.Wrap(err, "Create job failed")
return nil, util.Wrap(err, "Failed to add scheduled workflow info to model job")
}
// Add creation/update time.
now := r.time.Now().Unix()
job.CreatedAtInSec = now
job.UpdatedAtInSec = now
return r.jobStore.CreateJob(job)
modelJob.CreatedAtInSec = now
modelJob.UpdatedAtInSec = now
// Store modelJob to database and return.
return r.jobStore.CreateJob(modelJob)
}
func (r *ResourceManager) updateJobResourceReferences(resourceId string, modelJob *model.Job) error {
for _, modelRef := range modelJob.ResourceReferences {
modelRef.ResourceUUID = resourceId
}
return nil
}
func (r *ResourceManager) EnableJob(ctx context.Context, jobID string, enabled bool) error {
@ -881,7 +887,7 @@ func (r *ResourceManager) ReportWorkflowResource(ctx context.Context, execSpec u
ExperimentUUID: experimentRef.ReferenceUUID,
DisplayName: execSpec.ExecutionName(),
Name: execSpec.ExecutionName(),
StorageState: apiV1beta1.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
Namespace: execSpec.ExecutionNamespace(),
CreatedAtInSec: objMeta.CreationTimestamp.Unix(),
ScheduledAtInSec: scheduledTimeInSec,
@ -995,17 +1001,17 @@ func (r *ResourceManager) checkRunExist(runID string) (*model.RunDetail, error)
return runDetail, nil
}
func (r *ResourceManager) getWorkflowSpecBytesFromPipelineSpec(spec *apiV1beta1.PipelineSpec) ([]byte, error) {
func (r *ResourceManager) getWorkflowSpecBytesFromPipelineSpec(spec *apiv1beta1.PipelineSpec) ([]byte, error) {
if spec.GetWorkflowManifest() != "" {
return []byte(spec.GetWorkflowManifest()), nil
}
return nil, util.NewInvalidInputError("Please provide a valid pipeline spec")
}
func (r *ResourceManager) getManifestBytesFromPipelineVersion(references []*apiV1beta1.ResourceReference) ([]byte, error) {
func (r *ResourceManager) getManifestBytesFromPipelineVersion(references []*apiv1beta1.ResourceReference) ([]byte, error) {
var pipelineVersionId = ""
for _, reference := range references {
if reference.Key.Type == apiV1beta1.ResourceType_PIPELINE_VERSION && reference.Relationship == apiV1beta1.Relationship_CREATOR {
if reference.Key.Type == apiv1beta1.ResourceType_PIPELINE_VERSION && reference.Relationship == apiv1beta1.Relationship_CREATOR {
pipelineVersionId = reference.Key.Id
}
}
@ -1020,7 +1026,7 @@ func (r *ResourceManager) getManifestBytesFromPipelineVersion(references []*apiV
return manifestBytes, nil
}
func getManifestBytes(pipelineSpec *apiV1beta1.PipelineSpec, resourceReferences *[]*apiV1beta1.ResourceReference, r *ResourceManager) ([]byte, error) {
func getManifestBytesV1(pipelineSpec *apiv1beta1.PipelineSpec, resourceReferences *[]*apiv1beta1.ResourceReference, r *ResourceManager) ([]byte, error) {
var manifestBytes []byte
if pipelineSpec.GetWorkflowManifest() != "" {
manifestBytes = []byte(pipelineSpec.GetWorkflowManifest())
@ -1039,6 +1045,35 @@ func getManifestBytes(pipelineSpec *apiV1beta1.PipelineSpec, resourceReferences
return manifestBytes, nil
}
func getManifestBytesfromAPIJobInterface(apiJobInterface interface{}, r *ResourceManager) ([]byte, error) {
var manifestBytes []byte
var err error
switch apiJobInterface.(type) {
case *apiv1beta1.Job:
apiJob := apiJobInterface.(*apiv1beta1.Job)
manifestBytes, err = getManifestBytesV1(apiJob.PipelineSpec, &apiJob.ResourceReferences, r)
if err != nil {
return nil, util.Wrap(err, "Cannot get manifest bytes.")
}
case *apiv2beta1.RecurringRun:
apiRecurringRun := apiJobInterface.(*apiv2beta1.RecurringRun)
if apiRecurringRun.GetPipelineId() != "" {
manifestBytes, err = r.GetPipelineTemplate(apiRecurringRun.GetPipelineId())
if err != nil {
return nil, util.Wrap(err, "Cannot retrieve manifestBytes using pipelineId.")
}
} else if apiRecurringRun.GetPipelineSpec() != nil {
manifestBytes, err = json.Marshal(apiRecurringRun.GetPipelineSpec())
if err != nil {
return nil, util.Wrap(err, "Cannot marshal PipelineSpec.")
}
}
default:
return nil, util.Wrap(err, "Wrong api job interface type.")
}
return manifestBytes, nil
}
// Used to initialize the Experiment database with a default to be used for runs
func (r *ResourceManager) CreateDefaultExperiment() (string, error) {
// First check that we don't already have a default experiment ID in the DB.
@ -1053,7 +1088,7 @@ func (r *ResourceManager) CreateDefaultExperiment() (string, error) {
}
// Create default experiment
defaultExperiment := &apiV1beta1.Experiment{
defaultExperiment := &apiv1beta1.Experiment{
Name: "Default",
Description: "All runs created without specifying an experiment will be grouped here.",
}
@ -1074,10 +1109,10 @@ func (r *ResourceManager) CreateDefaultExperiment() (string, error) {
// getDefaultExperimentIfNoExperiment If the provided run does not include a reference to a containing
// experiment, then we fetch the default experiment's ID and create a reference to that.
func (r *ResourceManager) getDefaultExperimentIfNoExperiment(references []*apiV1beta1.ResourceReference) (*apiV1beta1.ResourceReference, error) {
func (r *ResourceManager) getDefaultExperimentIfNoExperiment(references []*apiv1beta1.ResourceReference) (*apiv1beta1.ResourceReference, error) {
// First check if there is already a referenced experiment
for _, ref := range references {
if ref.Key.Type == apiV1beta1.ResourceType_EXPERIMENT && ref.Relationship == apiV1beta1.Relationship_OWNER {
if ref.Key.Type == apiv1beta1.ResourceType_EXPERIMENT && ref.Relationship == apiv1beta1.Relationship_OWNER {
return nil, nil
}
}
@ -1087,7 +1122,7 @@ func (r *ResourceManager) getDefaultExperimentIfNoExperiment(references []*apiV1
return r.getDefaultExperimentResourceReference(references)
}
func (r *ResourceManager) getDefaultExperimentResourceReference(references []*apiV1beta1.ResourceReference) (*apiV1beta1.ResourceReference, error) {
func (r *ResourceManager) getDefaultExperimentResourceReference(references []*apiv1beta1.ResourceReference) (*apiv1beta1.ResourceReference, error) {
// Create reference to the default experiment
defaultExperimentId, err := r.GetDefaultExperimentId()
if err != nil {
@ -1100,18 +1135,18 @@ func (r *ResourceManager) getDefaultExperimentResourceReference(references []*ap
return nil, util.NewInternalServerError(err, "Failed to create new default experiment")
}
}
defaultExperimentRef := &apiV1beta1.ResourceReference{
Key: &apiV1beta1.ResourceKey{
defaultExperimentRef := &apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: defaultExperimentId,
Type: apiV1beta1.ResourceType_EXPERIMENT,
Type: apiv1beta1.ResourceType_EXPERIMENT,
},
Relationship: apiV1beta1.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
}
return defaultExperimentRef, nil
}
func (r *ResourceManager) ReportMetric(metric *apiV1beta1.RunMetric, runUUID string) error {
func (r *ResourceManager) ReportMetric(metric *apiv1beta1.RunMetric, runUUID string) error {
return r.runStore.ReportMetric(r.ToModelRunMetric(metric, runUUID))
}
@ -1155,11 +1190,11 @@ func (r *ResourceManager) MarkSampleLoaded() error {
return r.dBStatusStore.MarkSampleLoaded()
}
func (r *ResourceManager) CreatePipelineVersion(apiVersion *apiV1beta1.PipelineVersion, pipelineFile []byte, updateDefaultVersion bool) (*model.PipelineVersion, error) {
func (r *ResourceManager) CreatePipelineVersion(apiVersion *apiv1beta1.PipelineVersion, pipelineFile []byte, updateDefaultVersion bool) (*model.PipelineVersion, error) {
// Extract pipeline id
var pipelineId = ""
for _, resourceReference := range apiVersion.ResourceReferences {
if resourceReference.Key.Type == apiV1beta1.ResourceType_PIPELINE && resourceReference.Relationship == apiV1beta1.Relationship_OWNER {
if resourceReference.Key.Type == apiv1beta1.ResourceType_PIPELINE && resourceReference.Relationship == apiv1beta1.Relationship_OWNER {
pipelineId = resourceReference.Key.Id
}
}
@ -1350,7 +1385,7 @@ func (r *ResourceManager) GetNamespaceFromPipelineVersion(versionId string) (str
return r.GetNamespaceFromPipelineID(pipelineVersion.PipelineId)
}
func (r *ResourceManager) getNamespaceFromExperiment(references []*apiV1beta1.ResourceReference) (string, error) {
func (r *ResourceManager) getNamespaceFromExperiment(references []*apiv1beta1.ResourceReference) (string, error) {
experimentID := common.GetExperimentIDFromAPIResourceReferences(references)
experiment, err := r.GetExperiment(experimentID)
if err != nil {

View File

@ -27,7 +27,7 @@ import (
"github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/util/file"
"github.com/golang/protobuf/ptypes/timestamp"
api "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
apiv1beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
"github.com/kubeflow/pipelines/backend/src/apiserver/client"
"github.com/kubeflow/pipelines/backend/src/apiserver/common"
"github.com/kubeflow/pipelines/backend/src/apiserver/model"
@ -106,7 +106,7 @@ func initWithExperiment(t *testing.T) (*FakeClientManager, *ResourceManager, *mo
initEnvVars()
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
manager := NewResourceManager(store)
apiExperiment := &api.Experiment{Name: "e1"}
apiExperiment := &apiv1beta1.Experiment{Name: "e1"}
experiment, err := manager.CreateExperiment(apiExperiment)
assert.Nil(t, err)
return store, manager, experiment
@ -116,7 +116,7 @@ func initWithExperimentAndPipeline(t *testing.T) (*FakeClientManager, *ResourceM
initEnvVars()
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
manager := NewResourceManager(store)
apiExperiment := &api.Experiment{Name: "e1"}
apiExperiment := &apiv1beta1.Experiment{Name: "e1"}
experiment, err := manager.CreateExperiment(apiExperiment)
assert.Nil(t, err)
pipeline, err := manager.CreatePipeline("p1", "", "", []byte(testWorkflow.ToStringForStore()))
@ -130,15 +130,15 @@ func initWithExperimentAndPipelineAndRun(t *testing.T) (*FakeClientManager, *Res
pipelineStore, ok := store.pipelineStore.(*storage.PipelineStore)
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
_, err := manager.CreatePipelineVersion(&api.PipelineVersion{
_, err := manager.CreatePipelineVersion(&apiv1beta1.PipelineVersion{
Name: "version_for_run",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: pipeline.UUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}, []byte(testWorkflow.ToStringForStore()), true)
@ -146,18 +146,18 @@ func initWithExperimentAndPipelineAndRun(t *testing.T) (*FakeClientManager, *Res
// The pipeline specified via pipeline id will be converted to this
// pipeline's default version, which will be used to create run.
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
PipelineId: pipeline.UUID,
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -169,14 +169,14 @@ func initWithExperimentAndPipelineAndRun(t *testing.T) (*FakeClientManager, *Res
// Util function to create an initial state with pipeline uploaded
func initWithJob(t *testing.T) (*FakeClientManager, *ResourceManager, *model.Job) {
store, manager, exp := initWithExperiment(t)
job := &api.Job{
job := &apiv1beta1.Job{
Name: "j1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{WorkflowManifest: testWorkflow.ToStringForStore()},
ResourceReferences: []*api.ResourceReference{
PipelineSpec: &apiv1beta1.PipelineSpec{WorkflowManifest: testWorkflow.ToStringForStore()},
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -189,22 +189,22 @@ func initWithJob(t *testing.T) (*FakeClientManager, *ResourceManager, *model.Job
// Util function to create an initial state with pipeline uploaded
func initWithJobV2(t *testing.T) (*FakeClientManager, *ResourceManager, *model.Job) {
store, manager, exp := initWithExperiment(t)
job := &api.Job{
job := &apiv1beta1.Job{
Name: "j1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
PipelineManifest: v2SpecHelloWorld,
RuntimeConfig: &api.PipelineSpec_RuntimeConfig{
RuntimeConfig: &apiv1beta1.PipelineSpec_RuntimeConfig{
Parameters: map[string]*structpb.Value{
"param1": &structpb.Value{Kind: &structpb.Value_StringValue{StringValue: "world"}},
},
PipelineRoot: "job-1-root",
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -216,18 +216,18 @@ func initWithJobV2(t *testing.T) (*FakeClientManager, *ResourceManager, *model.J
func initWithOneTimeRun(t *testing.T) (*FakeClientManager, *ResourceManager, *model.RunDetail) {
store, manager, exp := initWithExperiment(t)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: testWorkflow.ToStringForStore(),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -238,15 +238,15 @@ func initWithOneTimeRun(t *testing.T) (*FakeClientManager, *ResourceManager, *mo
func initWithOneTimeRunV2(t *testing.T) (*FakeClientManager, *ResourceManager, *model.RunDetail) {
store, manager, exp := initWithExperiment(t)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
PipelineManifest: v2SpecHelloWorld,
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -257,18 +257,18 @@ func initWithOneTimeRunV2(t *testing.T) (*FakeClientManager, *ResourceManager, *
func initWithPatchedRun(t *testing.T) (*FakeClientManager, *ResourceManager, *model.RunDetail) {
store, manager, exp := initWithExperiment(t)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: testWorkflow.ToStringForStore(),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "{{kfp-default-bucket}}"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -279,18 +279,18 @@ func initWithPatchedRun(t *testing.T) (*FakeClientManager, *ResourceManager, *mo
func initWithOneTimeFailedRun(t *testing.T) (*FakeClientManager, *ResourceManager, *model.RunDetail) {
store, manager, exp := initWithExperiment(t)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: testWorkflow.ToStringForStore(),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -308,18 +308,18 @@ func initWithOneTimeFailedRun(t *testing.T) (*FakeClientManager, *ResourceManage
func initWithOneTimeFailedRunCompressed(t *testing.T) (*FakeClientManager, *ResourceManager, *model.RunDetail) {
store, manager, exp := initWithExperiment(t)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: testWorkflow.ToStringForStore(),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -340,18 +340,18 @@ func initWithOneTimeFailedRunCompressed(t *testing.T) (*FakeClientManager, *Reso
func initWithOneTimeFailedRunOffloaded(t *testing.T) (*FakeClientManager, *ResourceManager, *model.RunDetail) {
store, manager, exp := initWithExperiment(t)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: testWorkflow.ToStringForStore(),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: exp.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -605,7 +605,7 @@ func TestGetPipelineTemplate_PipelineFileNotFound(t *testing.T) {
func TestCreateRun_ThroughPipelineID(t *testing.T) {
store, manager, p := initWithPipeline(t)
defer store.Close()
apiExperiment := &api.Experiment{Name: "e1"}
apiExperiment := &apiv1beta1.Experiment{Name: "e1"}
experiment, err := manager.CreateExperiment(apiExperiment)
assert.Nil(t, err)
@ -613,15 +613,15 @@ func TestCreateRun_ThroughPipelineID(t *testing.T) {
pipelineStore, ok := store.pipelineStore.(*storage.PipelineStore)
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
version, err := manager.CreatePipelineVersion(&api.PipelineVersion{
version, err := manager.CreatePipelineVersion(&apiv1beta1.PipelineVersion{
Name: "version_for_run",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: p.UUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}, []byte(testWorkflow.ToStringForStore()), true)
@ -629,18 +629,18 @@ func TestCreateRun_ThroughPipelineID(t *testing.T) {
// The pipeline specified via pipeline id will be converted to this
// pipeline's default version, which will be used to create run.
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
PipelineId: p.UUID,
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -666,7 +666,7 @@ func TestCreateRun_ThroughPipelineID(t *testing.T) {
Name: "workflow-name",
Namespace: "ns1",
ServiceAccount: "pipeline-runner",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
CreatedAtInSec: 4,
ScheduledAtInSec: 4,
Conditions: "Running",
@ -717,7 +717,7 @@ func TestCreateRun_ThroughWorkflowSpecV2(t *testing.T) {
DisplayName: "run1",
Name: "hello-world-0",
ServiceAccount: "pipeline-runner",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
CreatedAtInSec: 2,
ScheduledAtInSec: 2,
PipelineSpec: model.PipelineSpec{
@ -765,7 +765,7 @@ func TestCreateRun_ThroughWorkflowSpec(t *testing.T) {
Name: "workflow-name",
Namespace: "ns1",
ServiceAccount: "pipeline-runner",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
CreatedAtInSec: 2,
ScheduledAtInSec: 2,
Conditions: "Running",
@ -821,7 +821,7 @@ func TestCreateRun_ThroughWorkflowSpecWithPatch(t *testing.T) {
Name: "workflow-name",
Namespace: "ns1",
ServiceAccount: "pipeline-runner",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
CreatedAtInSec: 2,
ScheduledAtInSec: 2,
Conditions: "Running",
@ -858,35 +858,35 @@ func TestCreateRun_ThroughPipelineVersion(t *testing.T) {
pipelineStore, ok := store.pipelineStore.(*storage.PipelineStore)
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
version, err := manager.CreatePipelineVersion(&api.PipelineVersion{
version, err := manager.CreatePipelineVersion(&apiv1beta1.PipelineVersion{
Name: "version_for_run",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: pipeline.UUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}, []byte(testWorkflow.ToStringForStore()), true)
assert.Nil(t, err)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
Parameters: []*api.Parameter{
PipelineSpec: &apiv1beta1.PipelineSpec{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
{
Key: &api.ResourceKey{Type: api.ResourceType_PIPELINE_VERSION, Id: version.UUID},
Relationship: api.Relationship_CREATOR,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_PIPELINE_VERSION, Id: version.UUID},
Relationship: apiv1beta1.Relationship_CREATOR,
},
},
ServiceAccount: "sa1",
@ -914,7 +914,7 @@ func TestCreateRun_ThroughPipelineVersion(t *testing.T) {
Name: "workflow-name",
Namespace: "ns1",
ServiceAccount: "sa1",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
CreatedAtInSec: 4,
ScheduledAtInSec: 4,
Conditions: "Running",
@ -959,36 +959,36 @@ func TestCreateRun_ThroughPipelineIdAndPipelineVersion(t *testing.T) {
pipelineStore, ok := store.pipelineStore.(*storage.PipelineStore)
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
version, err := manager.CreatePipelineVersion(&api.PipelineVersion{
version, err := manager.CreatePipelineVersion(&apiv1beta1.PipelineVersion{
Name: "version_for_run",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: pipeline.UUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}, []byte(testWorkflow.ToStringForStore()), true)
assert.Nil(t, err)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
PipelineId: pipeline.UUID,
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
{
Key: &api.ResourceKey{Type: api.ResourceType_PIPELINE_VERSION, Id: version.UUID},
Relationship: api.Relationship_CREATOR,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_PIPELINE_VERSION, Id: version.UUID},
Relationship: apiv1beta1.Relationship_CREATOR,
},
},
ServiceAccount: "sa1",
@ -1016,7 +1016,7 @@ func TestCreateRun_ThroughPipelineIdAndPipelineVersion(t *testing.T) {
Name: "workflow-name",
Namespace: "ns1",
ServiceAccount: "sa1",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
CreatedAtInSec: 4,
ScheduledAtInSec: 4,
Conditions: "Running",
@ -1064,16 +1064,16 @@ func TestCreateRun_NoExperiment(t *testing.T) {
experiment, err := manager.GetExperiment(experimentID)
assert.Equal(t, experiment.Name, "Default")
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "No experiment",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: testWorkflow.ToStringForStore(),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
// No experiment
ResourceReferences: []*api.ResourceReference{},
ResourceReferences: []*apiv1beta1.ResourceReference{},
}
runDetail, err := manager.CreateRun(context.Background(), apiRun)
assert.Nil(t, err)
@ -1096,10 +1096,10 @@ func TestCreateRun_EmptyPipelineSpec(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
Parameters: []*api.Parameter{
PipelineSpec: &apiv1beta1.PipelineSpec{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
@ -1113,11 +1113,11 @@ func TestCreateRun_InvalidWorkflowSpec(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: string("I am invalid"),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
@ -1131,11 +1131,11 @@ func TestCreateRun_NullWorkflowSpec(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: "null", // this situation occurs for real when the manifest file disappears from object store in some way due to retention policy or manual deletion.
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
@ -1149,11 +1149,11 @@ func TestCreateRun_OverrideParametersError(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: testWorkflow.ToStringForStore(),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param2", Value: "world"},
},
},
@ -1168,11 +1168,11 @@ func TestCreateRun_CreateWorkflowError(t *testing.T) {
defer store.Close()
manager := NewResourceManager(store)
manager.execClient = client.NewFakeExecClientWithBadWorkflow()
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: testWorkflow.ToStringForStore(),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
@ -1187,11 +1187,11 @@ func TestCreateRun_StoreRunMetadataError(t *testing.T) {
defer store.Close()
manager := NewResourceManager(store)
store.DB().Close()
apiRun := &api.Run{
apiRun := &apiv1beta1.Run{
Name: "run1",
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: testWorkflow.ToStringForStore(),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
@ -1504,21 +1504,21 @@ func TestCreateJob_ThroughWorkflowSpecV2(t *testing.T) {
func TestCreateJob_ThroughPipelineID(t *testing.T) {
store, manager, pipeline := initWithPipeline(t)
defer store.Close()
apiExperiment := &api.Experiment{Name: "e1"}
apiExperiment := &apiv1beta1.Experiment{Name: "e1"}
experiment, err := manager.CreateExperiment(apiExperiment)
job := &api.Job{
job := &apiv1beta1.Job{
Name: "j1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
PipelineId: pipeline.UUID,
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}
@ -1527,15 +1527,15 @@ func TestCreateJob_ThroughPipelineID(t *testing.T) {
pipelineStore, ok := store.pipelineStore.(*storage.PipelineStore)
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
version, err := manager.CreatePipelineVersion(&api.PipelineVersion{
version, err := manager.CreatePipelineVersion(&apiv1beta1.PipelineVersion{
Name: "version_for_run",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: pipeline.UUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}, []byte(testWorkflow.ToStringForStore()), true)
@ -1590,36 +1590,36 @@ func TestCreateJob_ThroughPipelineVersion(t *testing.T) {
pipelineStore, ok := store.pipelineStore.(*storage.PipelineStore)
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
version, err := manager.CreatePipelineVersion(&api.PipelineVersion{
version, err := manager.CreatePipelineVersion(&apiv1beta1.PipelineVersion{
Name: "version_for_job",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: pipeline.UUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}, []byte(testWorkflow.ToStringForStore()), true)
assert.Nil(t, err)
job := &api.Job{
job := &apiv1beta1.Job{
Name: "j1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{
Parameters: []*api.Parameter{
PipelineSpec: &apiv1beta1.PipelineSpec{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
{
Key: &api.ResourceKey{Type: api.ResourceType_PIPELINE_VERSION, Id: version.UUID},
Relationship: api.Relationship_CREATOR,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_PIPELINE_VERSION, Id: version.UUID},
Relationship: apiv1beta1.Relationship_CREATOR,
},
},
}
@ -1668,37 +1668,37 @@ func TestCreateJob_ThroughPipelineIdAndPipelineVersion(t *testing.T) {
pipelineStore, ok := store.pipelineStore.(*storage.PipelineStore)
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
version, err := manager.CreatePipelineVersion(&api.PipelineVersion{
version, err := manager.CreatePipelineVersion(&apiv1beta1.PipelineVersion{
Name: "version_for_job",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: pipeline.UUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
}, []byte(testWorkflow.ToStringForStore()), true)
assert.Nil(t, err)
job := &api.Job{
job := &apiv1beta1.Job{
Name: "j1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
PipelineId: pipeline.UUID,
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
ResourceReferences: []*api.ResourceReference{
ResourceReferences: []*apiv1beta1.ResourceReference{
{
Key: &api.ResourceKey{Type: api.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: api.Relationship_OWNER,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_EXPERIMENT, Id: experiment.UUID},
Relationship: apiv1beta1.Relationship_OWNER,
},
{
Key: &api.ResourceKey{Type: api.ResourceType_PIPELINE_VERSION, Id: version.UUID},
Relationship: api.Relationship_CREATOR,
Key: &apiv1beta1.ResourceKey{Type: apiv1beta1.ResourceType_PIPELINE_VERSION, Id: version.UUID},
Relationship: apiv1beta1.Relationship_CREATOR,
},
},
}
@ -1746,11 +1746,11 @@ func TestCreateJob_EmptyPipelineSpec(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
job := &api.Job{
job := &apiv1beta1.Job{
Name: "pp 1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{
Parameters: []*api.Parameter{
PipelineSpec: &apiv1beta1.PipelineSpec{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
@ -1764,12 +1764,12 @@ func TestCreateJob_InvalidWorkflowSpec(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
job := &api.Job{
job := &apiv1beta1.Job{
Name: "pp 1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: string("I am invalid"),
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
@ -1783,12 +1783,12 @@ func TestCreateJob_NullWorkflowSpec(t *testing.T) {
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
job := &api.Job{
job := &apiv1beta1.Job{
Name: "pp 1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
WorkflowManifest: string("null"), // this situation occurs for real when the manifest file disappears from object store in some way due to retention policy or manual deletion.
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
},
@ -1801,17 +1801,19 @@ func TestCreateJob_NullWorkflowSpec(t *testing.T) {
func TestCreateJob_ExtraInputParameterError(t *testing.T) {
store, manager, p := initWithPipeline(t)
defer store.Close()
job := &api.Job{
job := &apiv1beta1.Job{
Name: "pp 1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{
PipelineSpec: &apiv1beta1.PipelineSpec{
PipelineId: p.UUID,
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param2", Value: "world"},
},
},
}
_, err := manager.CreateJob(context.Background(), job)
jobjob, err := manager.CreateJob(context.Background(), job)
fmt.Print("job value: ", jobjob)
assert.NotNil(t, err)
assert.Equal(t, codes.InvalidArgument, err.(*util.UserError).ExternalStatusCode())
assert.Contains(t, err.Error(), "Unrecognized input parameter: param2")
}
@ -1820,13 +1822,13 @@ func TestCreateJob_FailedToCreateScheduleWorkflow(t *testing.T) {
store, manager, p := initWithPipeline(t)
defer store.Close()
manager.swfClient = client.NewFakeSwfClientWithBadWorkflow()
job := &api.Job{
job := &apiv1beta1.Job{
Name: "pp1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{PipelineId: p.UUID},
PipelineSpec: &apiv1beta1.PipelineSpec{PipelineId: p.UUID},
}
_, err := manager.CreateJob(context.Background(), job)
assert.Equal(t, codes.Internal, err.(*util.UserError).ExternalStatusCode())
assert.NotNil(t, err)
assert.Contains(t, err.Error(), "Failed to create a scheduled workflow")
}
@ -2000,7 +2002,7 @@ func TestReportWorkflowResource_ScheduledWorkflowIDEmpty_Success(t *testing.T) {
Name: "workflow-name",
Namespace: "ns1",
ServiceAccount: "pipeline-runner",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
CreatedAtInSec: 2,
ScheduledAtInSec: 2,
Conditions: "Running",
@ -2053,7 +2055,7 @@ func TestReportWorkflowResource_ScheduledWorkflowIDNotEmpty_Success(t *testing.T
UUID: "WORKFLOW_1",
ExperimentUUID: DefaultFakeUUID,
DisplayName: "MY_NAME",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
Name: "MY_NAME",
Namespace: "MY_NAMESPACE",
CreatedAtInSec: 11,
@ -2091,10 +2093,10 @@ func TestReportWorkflowResource_ScheduledWorkflowIDNotEmpty_NoExperiment_Success
store := NewFakeClientManagerOrFatal(util.NewFakeTimeForEpoch())
defer store.Close()
manager := NewResourceManager(store)
job := &api.Job{
job := &apiv1beta1.Job{
Name: "j1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{WorkflowManifest: testWorkflow.ToStringForStore()},
PipelineSpec: &apiv1beta1.PipelineSpec{WorkflowManifest: testWorkflow.ToStringForStore()},
// no experiment reference
}
newJob, err := manager.CreateJob(context.Background(), job)
@ -2127,7 +2129,7 @@ func TestReportWorkflowResource_ScheduledWorkflowIDNotEmpty_NoExperiment_Success
UUID: "WORKFLOW_1",
ExperimentUUID: DefaultFakeUUID,
DisplayName: "MY_NAME",
StorageState: api.Run_STORAGESTATE_AVAILABLE.String(),
StorageState: apiv1beta1.Run_STORAGESTATE_AVAILABLE.String(),
Name: "MY_NAME",
Namespace: "MY_NAMESPACE",
CreatedAtInSec: 11,
@ -2353,10 +2355,10 @@ func TestReportScheduledWorkflowResource_Error(t *testing.T) {
assert.Nil(t, err)
// Create job
job := &api.Job{
job := &apiv1beta1.Job{
Name: "pp1",
Enabled: true,
PipelineSpec: &api.PipelineSpec{PipelineId: p.UUID},
PipelineSpec: &apiv1beta1.PipelineSpec{PipelineId: p.UUID},
}
newJob, err := manager.CreateJob(context.Background(), job)
assert.Nil(t, err)
@ -2382,9 +2384,9 @@ func TestGetWorkflowSpecBytes_ByWorkflowManifest(t *testing.T) {
defer store.Close()
manager := NewResourceManager(store)
spec := &api.PipelineSpec{
spec := &apiv1beta1.PipelineSpec{
WorkflowManifest: "some manifest",
Parameters: []*api.Parameter{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
}
@ -2398,8 +2400,8 @@ func TestGetWorkflowSpecBytes_MissingSpec(t *testing.T) {
defer store.Close()
manager := NewResourceManager(store)
spec := &api.PipelineSpec{
Parameters: []*api.Parameter{
spec := &apiv1beta1.PipelineSpec{
Parameters: []*apiv1beta1.Parameter{
{Name: "param1", Value: "world"},
},
}
@ -2417,7 +2419,7 @@ func TestReadArtifact_Succeed(t *testing.T) {
store.ObjectStore().AddFile([]byte(expectedContent), filePath)
// Create a scheduled run
// job, _ := manager.CreateJob(&api.Job{
// job, _ := manager.CreateJob(&apiv1beta1.Job{
// Name: "pp1",
// PipelineId: p.UUID,
// Enabled: true,
@ -3113,10 +3115,10 @@ spec:
func TestCreatePipelineVersion(t *testing.T) {
tt := []struct {
msg string
template string // pipeline template
version *api.PipelineVersion // optional
badObjectStore bool // optional, object requests always fail
badDB bool // optional, DB request always fail
template string // pipeline template
version *apiv1beta1.PipelineVersion // optional
badObjectStore bool // optional, object requests always fail
badDB bool // optional, DB request always fail
// The following are expected results.
model *model.PipelineVersion // optional, expected version model when success
// To verify an error, set the errorCode and
@ -3128,7 +3130,7 @@ func TestCreatePipelineVersion(t *testing.T) {
{
msg: "HappyCase",
template: testWorkflow.ToStringForStore(),
version: &api.PipelineVersion{
version: &apiv1beta1.PipelineVersion{
Name: "p_v",
Description: "test",
},
@ -3141,7 +3143,7 @@ func TestCreatePipelineVersion(t *testing.T) {
{
msg: "ComplexPipeline",
template: complexPipeline,
version: &api.PipelineVersion{
version: &apiv1beta1.PipelineVersion{
Name: "complex",
},
model: &model.PipelineVersion{
@ -3182,7 +3184,7 @@ func TestCreatePipelineVersion(t *testing.T) {
{
msg: "V2PipelineSpec",
template: v2SpecHelloWorld,
version: &api.PipelineVersion{
version: &apiv1beta1.PipelineVersion{
Name: "v2spec",
},
model: &model.PipelineVersion{
@ -3217,14 +3219,14 @@ func TestCreatePipelineVersion(t *testing.T) {
}
// Create a version under the above pipeline.
if test.version == nil {
test.version = &api.PipelineVersion{Name: "my_pipeline_version_name"}
test.version = &apiv1beta1.PipelineVersion{Name: "my_pipeline_version_name"}
}
test.version.ResourceReferences = []*api.ResourceReference{{
Key: &api.ResourceKey{
test.version.ResourceReferences = []*apiv1beta1.ResourceReference{{
Key: &apiv1beta1.ResourceKey{
Id: pipeline.UUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
}}
version, err := manager.CreatePipelineVersion(test.version,
[]byte(test.template), true)
@ -3289,14 +3291,14 @@ func TestCreatePipelineOrVersion_V2PipelineName(t *testing.T) {
// Verify v2 pipeline name of CreatePipelineVersion template.
version, err := manager.CreatePipelineVersion(
&api.PipelineVersion{
&apiv1beta1.PipelineVersion{
Name: "pipeline_version",
ResourceReferences: []*api.ResourceReference{{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{{
Key: &apiv1beta1.ResourceKey{
Id: createdPipeline.UUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
}},
},
[]byte(test.template), true)
@ -3324,15 +3326,15 @@ func TestDeletePipelineVersion(t *testing.T) {
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
_, err = manager.CreatePipelineVersion(
&api.PipelineVersion{
&apiv1beta1.PipelineVersion{
Name: "pipeline_version",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: DefaultFakeUUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
},
@ -3361,15 +3363,15 @@ func TestDeletePipelineVersion_FileError(t *testing.T) {
assert.True(t, ok)
pipelineStore.SetUUIDGenerator(util.NewFakeUUIDGeneratorOrFatal(FakeUUIDOne, nil))
_, err = manager.CreatePipelineVersion(
&api.PipelineVersion{
&apiv1beta1.PipelineVersion{
Name: "pipeline_version",
ResourceReferences: []*api.ResourceReference{
&api.ResourceReference{
Key: &api.ResourceKey{
ResourceReferences: []*apiv1beta1.ResourceReference{
&apiv1beta1.ResourceReference{
Key: &apiv1beta1.ResourceKey{
Id: DefaultFakeUUID,
Type: api.ResourceType_PIPELINE,
Type: apiv1beta1.ResourceType_PIPELINE,
},
Relationship: api.Relationship_OWNER,
Relationship: apiv1beta1.Relationship_OWNER,
},
},
},
@ -3435,7 +3437,7 @@ func TestCreateDefaultExperiment_MultiUser(t *testing.T) {
func TestCreateTask(t *testing.T) {
_, manager, _, _, runDetail := initWithExperimentAndPipelineAndRun(t)
task := &api.Task{
task := &apiv1beta1.Task{
Namespace: "",
PipelineName: "pipeline/my-pipeline",
RunId: runDetail.UUID,

View File

@ -1,3 +1,17 @@
// Copyright 2018-2022 The Kubeflow Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package template
import (
@ -6,9 +20,9 @@ import (
workflowapi "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/workflow/validate"
"github.com/ghodss/yaml"
api "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
"github.com/kubeflow/pipelines/backend/src/apiserver/common"
"github.com/kubeflow/pipelines/backend/src/apiserver/model"
"github.com/kubeflow/pipelines/backend/src/common/util"
scheduledworkflow "github.com/kubeflow/pipelines/backend/src/crd/pkg/apis/scheduledworkflow/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -73,42 +87,52 @@ type Argo struct {
wf *util.Workflow
}
func (t *Argo) ScheduledWorkflow(apiJob *api.Job) (*scheduledworkflow.ScheduledWorkflow, error) {
func (t *Argo) ScheduledWorkflow(modelJob *model.Job) (*scheduledworkflow.ScheduledWorkflow, error) {
workflow := util.NewWorkflow(t.wf.Workflow.DeepCopy())
parameters := toParametersMap(apiJob.GetPipelineSpec().GetParameters())
parameters, err := modelToParametersMap(modelJob.PipelineSpec.Parameters)
if err != nil {
return nil, util.Wrap(err, "Failed to convert parameters.")
}
// Verify no additional parameter provided
if err := workflow.VerifyParameters(parameters); err != nil {
return nil, util.Wrap(err, "Failed to verify parameters.")
}
// Append provided parameter
workflow.OverrideParameters(parameters)
setDefaultServiceAccount(workflow, apiJob.GetServiceAccount())
setDefaultServiceAccount(workflow, modelJob.ServiceAccount)
// Disable istio sidecar injection if not specified
workflow.SetAnnotationsToAllTemplatesIfKeyNotExist(util.AnnotationKeyIstioSidecarInject, util.AnnotationValueIstioSidecarInjectDisabled)
swfGeneratedName, err := toSWFCRDResourceGeneratedName(apiJob.Name)
swfGeneratedName, err := toSWFCRDResourceGeneratedName(modelJob.Name)
if err != nil {
return nil, util.Wrap(err, "Create job failed")
return nil, util.Wrap(err, "Create job failed.")
}
// Marking auto-added artifacts as optional. Otherwise most older workflows will start failing after upgrade to Argo 2.3.
// TODO: Fix the components to explicitly declare the artifacts they really output.
workflow.PatchTemplateOutputArtifacts()
swfParameters, err := modelToCRDParameters(modelJob.RuntimeConfig.Parameters)
if err != nil {
return nil, util.Wrap(err, "Failed to convert model parameters to CRD parameters")
}
crdTrigger, err := modelToCRDTrigger(modelJob.Trigger)
if err != nil {
return nil, err
}
scheduledWorkflow := &scheduledworkflow.ScheduledWorkflow{
ObjectMeta: metav1.ObjectMeta{GenerateName: swfGeneratedName},
Spec: scheduledworkflow.ScheduledWorkflowSpec{
Enabled: apiJob.Enabled,
MaxConcurrency: &apiJob.MaxConcurrency,
Trigger: *toCRDTrigger(apiJob.Trigger),
Enabled: modelJob.Enabled,
MaxConcurrency: &modelJob.MaxConcurrency,
Trigger: crdTrigger,
Workflow: &scheduledworkflow.WorkflowResource{
Parameters: toCRDParameter(apiJob.GetPipelineSpec().GetParameters()),
Parameters: swfParameters,
Spec: workflow.ToStringForSchedule(),
},
NoCatchup: util.BoolPointer(apiJob.NoCatchup),
NoCatchup: util.BoolPointer(modelJob.NoCatchup),
},
}
return scheduledWorkflow, nil
}

View File

@ -1,4 +1,4 @@
// Copyright 2018 The Kubeflow Authors
// Copyright 2018-2022 The Kubeflow Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@ -21,15 +21,16 @@ import (
"strings"
"time"
"github.com/kubeflow/pipelines/api/v2alpha1/go/pipelinespec"
api "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
"github.com/ghodss/yaml"
"github.com/kubeflow/pipelines/api/v2alpha1/go/pipelinespec"
apiv1beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
apiv2beta1 "github.com/kubeflow/pipelines/backend/api/v2beta1/go_client"
"github.com/kubeflow/pipelines/backend/src/apiserver/common"
"github.com/kubeflow/pipelines/backend/src/apiserver/model"
"github.com/kubeflow/pipelines/backend/src/common/util"
scheduledworkflow "github.com/kubeflow/pipelines/backend/src/crd/pkg/apis/scheduledworkflow/v1beta1"
"google.golang.org/protobuf/encoding/protojson"
structpb "google.golang.org/protobuf/types/known/structpb"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@ -104,9 +105,9 @@ type Template interface {
GetTemplateType() TemplateType
//Get workflow
RunWorkflow(apiRun *api.Run, options RunWorkflowOptions) (util.ExecutionSpec, error)
RunWorkflow(apiRun *apiv1beta1.Run, options RunWorkflowOptions) (util.ExecutionSpec, error)
ScheduledWorkflow(apiJob *api.Job) (*scheduledworkflow.ScheduledWorkflow, error)
ScheduledWorkflow(modelJob *model.Job) (*scheduledworkflow.ScheduledWorkflow, error)
}
type RunWorkflowOptions struct {
@ -126,7 +127,7 @@ func New(bytes []byte) (Template, error) {
}
}
func toParametersMap(apiParams []*api.Parameter) map[string]string {
func toParametersMap(apiParams []*apiv1beta1.Parameter) map[string]string {
// Preprocess workflow by appending parameter and add pipeline specific labels
desiredParamsMap := make(map[string]string)
for _, param := range apiParams {
@ -135,6 +136,22 @@ func toParametersMap(apiParams []*api.Parameter) map[string]string {
return desiredParamsMap
}
func modelToParametersMap(modelParameters string) (map[string]string, error) {
var paramsMapList []*map[string]string
desiredParamsMap := make(map[string]string)
if modelParameters == "" {
return desiredParamsMap, nil
}
err := json.Unmarshal([]byte(modelParameters), &paramsMapList)
if err != nil {
return nil, err
}
for _, param := range paramsMapList {
desiredParamsMap[(*param)["name"]] = (*param)["value"]
}
return desiredParamsMap, nil
}
// Patch the system-specified default parameters if available.
func OverrideParameterWithSystemDefault(execSpec util.ExecutionSpec) error {
// Patch the default value to workflow spec.
@ -192,53 +209,7 @@ func toSWFCRDResourceGeneratedName(displayName string) (string, error) {
return util.Truncate(processedName, 25), nil
}
func toCRDTrigger(apiTrigger *api.Trigger) *scheduledworkflow.Trigger {
var crdTrigger scheduledworkflow.Trigger
if apiTrigger.GetCronSchedule() != nil {
crdTrigger.CronSchedule = toCRDCronSchedule(apiTrigger.GetCronSchedule())
}
if apiTrigger.GetPeriodicSchedule() != nil {
crdTrigger.PeriodicSchedule = toCRDPeriodicSchedule(apiTrigger.GetPeriodicSchedule())
}
return &crdTrigger
}
func toCRDCronSchedule(cronSchedule *api.CronSchedule) *scheduledworkflow.CronSchedule {
if cronSchedule == nil || cronSchedule.Cron == "" {
return nil
}
crdCronSchedule := scheduledworkflow.CronSchedule{}
crdCronSchedule.Cron = cronSchedule.Cron
if cronSchedule.StartTime != nil {
startTime := metav1.NewTime(time.Unix(cronSchedule.StartTime.Seconds, 0))
crdCronSchedule.StartTime = &startTime
}
if cronSchedule.EndTime != nil {
endTime := metav1.NewTime(time.Unix(cronSchedule.EndTime.Seconds, 0))
crdCronSchedule.EndTime = &endTime
}
return &crdCronSchedule
}
func toCRDPeriodicSchedule(periodicSchedule *api.PeriodicSchedule) *scheduledworkflow.PeriodicSchedule {
if periodicSchedule == nil || periodicSchedule.IntervalSecond == 0 {
return nil
}
crdPeriodicSchedule := scheduledworkflow.PeriodicSchedule{}
crdPeriodicSchedule.IntervalSecond = periodicSchedule.IntervalSecond
if periodicSchedule.StartTime != nil {
startTime := metav1.NewTime(time.Unix(periodicSchedule.StartTime.Seconds, 0))
crdPeriodicSchedule.StartTime = &startTime
}
if periodicSchedule.EndTime != nil {
endTime := metav1.NewTime(time.Unix(periodicSchedule.EndTime.Seconds, 0))
crdPeriodicSchedule.EndTime = &endTime
}
return &crdPeriodicSchedule
}
func toCRDParameter(apiParams []*api.Parameter) []scheduledworkflow.Parameter {
func toCRDParametersV1(apiParams []*apiv1beta1.Parameter) []scheduledworkflow.Parameter {
var swParams []scheduledworkflow.Parameter
for _, apiParam := range apiParams {
swParam := scheduledworkflow.Parameter{
@ -250,7 +221,19 @@ func toCRDParameter(apiParams []*api.Parameter) []scheduledworkflow.Parameter {
return swParams
}
func toPipelineJobRuntimeConfig(apiRuntimeConfig *api.PipelineSpec_RuntimeConfig) (*pipelinespec.PipelineJob_RuntimeConfig, error) {
func toCRDParameters(apiParams map[string]*structpb.Value) []scheduledworkflow.Parameter {
var swParams []scheduledworkflow.Parameter
for name, value := range apiParams {
swParam := scheduledworkflow.Parameter{
Name: name,
Value: value.GetStringValue(),
}
swParams = append(swParams, swParam)
}
return swParams
}
func toPipelineJobRuntimeConfigV1(apiRuntimeConfig *apiv1beta1.PipelineSpec_RuntimeConfig) (*pipelinespec.PipelineJob_RuntimeConfig, error) {
if apiRuntimeConfig == nil {
return nil, nil
}
@ -259,3 +242,97 @@ func toPipelineJobRuntimeConfig(apiRuntimeConfig *api.PipelineSpec_RuntimeConfig
runtimeConfig.GcsOutputDirectory = apiRuntimeConfig.GetPipelineRoot()
return runtimeConfig, nil
}
func toPipelineJobRuntimeConfig(apiRuntimeConfig *apiv2beta1.RuntimeConfig) (*pipelinespec.PipelineJob_RuntimeConfig, error) {
if apiRuntimeConfig == nil {
return nil, nil
}
runtimeConfig := &pipelinespec.PipelineJob_RuntimeConfig{}
runtimeConfig.ParameterValues = apiRuntimeConfig.GetParameters()
runtimeConfig.GcsOutputDirectory = apiRuntimeConfig.GetPipelineRoot()
return runtimeConfig, nil
}
func modelToPipelineJobRuntimeConfig(modelRuntimeConfig *model.RuntimeConfig) (*pipelinespec.PipelineJob_RuntimeConfig, error) {
if modelRuntimeConfig == nil {
return nil, nil
}
parameters := new(map[string]*structpb.Value)
err := json.Unmarshal([]byte(modelRuntimeConfig.Parameters), parameters)
if err != nil {
return nil, err
}
runtimeConfig := &pipelinespec.PipelineJob_RuntimeConfig{}
runtimeConfig.ParameterValues = *parameters
runtimeConfig.GcsOutputDirectory = modelRuntimeConfig.PipelineRoot
return runtimeConfig, nil
}
func modelToCRDTrigger(modelTrigger model.Trigger) (scheduledworkflow.Trigger, error) {
crdTrigger := scheduledworkflow.Trigger{}
// CronSchedule and PeriodicSchedule can have at most one being non-empty
if modelTrigger.CronSchedule != (model.CronSchedule{}) {
// Check if CronSchedule is non-empty
crdCronSchedule := scheduledworkflow.CronSchedule{}
if modelTrigger.Cron != nil {
crdCronSchedule.Cron = *modelTrigger.Cron
}
if modelTrigger.CronScheduleStartTimeInSec != nil {
startTime := metav1.NewTime(time.Unix(*modelTrigger.CronScheduleStartTimeInSec, 0))
crdCronSchedule.StartTime = &startTime
}
if modelTrigger.CronScheduleEndTimeInSec != nil {
endTime := metav1.NewTime(time.Unix(*modelTrigger.CronScheduleEndTimeInSec, 0))
crdCronSchedule.EndTime = &endTime
}
crdTrigger.CronSchedule = &crdCronSchedule
} else if modelTrigger.PeriodicSchedule != (model.PeriodicSchedule{}) {
// Check if PeriodicSchedule is non-empty
crdPeriodicSchedule := scheduledworkflow.PeriodicSchedule{}
if modelTrigger.IntervalSecond != nil {
crdPeriodicSchedule.IntervalSecond = *modelTrigger.IntervalSecond
}
if modelTrigger.PeriodicScheduleStartTimeInSec != nil {
startTime := metav1.NewTime(time.Unix(*modelTrigger.PeriodicScheduleStartTimeInSec, 0))
crdPeriodicSchedule.StartTime = &startTime
}
if modelTrigger.PeriodicScheduleEndTimeInSec != nil {
endTime := metav1.NewTime(time.Unix(*modelTrigger.PeriodicScheduleEndTimeInSec, 0))
crdPeriodicSchedule.EndTime = &endTime
}
crdTrigger.PeriodicSchedule = &crdPeriodicSchedule
}
return crdTrigger, nil
}
func modelToCRDParameters(modelParams string) ([]scheduledworkflow.Parameter, error) {
var swParams []scheduledworkflow.Parameter
var parameters map[string]*structpb.Value
if modelParams == "" {
return swParams, nil
}
err := json.Unmarshal([]byte(modelParams), &parameters)
if err != nil {
return nil, err
}
for name, value := range parameters {
valueBytes, err := value.MarshalJSON()
if err != nil {
return nil, err
}
swParam := scheduledworkflow.Parameter{
Name: name,
Value: string(valueBytes),
}
swParams = append(swParams, swParam)
}
return swParams, nil
}
func modeToPipelineJobEnabled(recurringRunMode apiv2beta1.RecurringRun_Mode) bool {
if recurringRunMode == 1 {
return true
} else {
return false
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,17 @@
// Copyright 2021-2022 The Kubeflow Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package template
import (
@ -8,7 +22,8 @@ import (
"github.com/ghodss/yaml"
"github.com/kubeflow/pipelines/api/v2alpha1/go/pipelinespec"
api "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
apiv1beta1 "github.com/kubeflow/pipelines/backend/api/v1beta1/go_client"
"github.com/kubeflow/pipelines/backend/src/apiserver/model"
"github.com/kubeflow/pipelines/backend/src/common/util"
scheduledworkflow "github.com/kubeflow/pipelines/backend/src/crd/pkg/apis/scheduledworkflow/v1beta1"
"github.com/kubeflow/pipelines/backend/src/v2/compiler/argocompiler"
@ -20,7 +35,10 @@ type V2Spec struct {
spec *pipelinespec.PipelineSpec
}
func (t *V2Spec) ScheduledWorkflow(apiJob *api.Job) (*scheduledworkflow.ScheduledWorkflow, error) {
// Converts modelJob to ScheduledWorkflow
func (t *V2Spec) ScheduledWorkflow(modelJob *model.Job) (*scheduledworkflow.ScheduledWorkflow, error) {
job := &pipelinespec.PipelineJob{}
bytes, err := protojson.Marshal(t.spec)
if err != nil {
return nil, util.Wrap(err, "Failed marshal pipeline spec to json")
@ -29,15 +47,18 @@ func (t *V2Spec) ScheduledWorkflow(apiJob *api.Job) (*scheduledworkflow.Schedule
if err := protojson.Unmarshal(bytes, spec); err != nil {
return nil, util.Wrap(err, "Failed to parse pipeline spec")
}
job := &pipelinespec.PipelineJob{PipelineSpec: spec}
jobRuntimeConfig, err := toPipelineJobRuntimeConfig(apiJob.GetPipelineSpec().GetRuntimeConfig())
job.PipelineSpec = spec
jobRuntimeConfig, err := modelToPipelineJobRuntimeConfig(&modelJob.RuntimeConfig)
if err != nil {
return nil, util.Wrap(err, "Failed to convert to PipelineJob RuntimeConfig")
return nil, util.Wrap(err, "Failed to convert runtime config.")
}
job.RuntimeConfig = jobRuntimeConfig
obj, err := argocompiler.Compile(job, nil)
if err != nil {
return nil, util.Wrap(err, "Failed to compile job")
return nil, util.Wrap(err, "Failed to compile job.")
}
// currently, there is only Argo implementation, so it's using `ArgoWorkflow` for now
// later on, if a new runtime support will be added, we need a way to switch/specify
@ -46,25 +67,33 @@ func (t *V2Spec) ScheduledWorkflow(apiJob *api.Job) (*scheduledworkflow.Schedule
if err != nil {
return nil, util.NewInternalServerError(err, "not Workflow struct")
}
setDefaultServiceAccount(executionSpec, apiJob.GetServiceAccount())
setDefaultServiceAccount(executionSpec, modelJob.ServiceAccount)
// Disable istio sidecar injection if not specified
executionSpec.SetAnnotationsToAllTemplatesIfKeyNotExist(util.AnnotationKeyIstioSidecarInject, util.AnnotationValueIstioSidecarInjectDisabled)
swfGeneratedName, err := toSWFCRDResourceGeneratedName(apiJob.Name)
swfGeneratedName, err := toSWFCRDResourceGeneratedName(modelJob.Name)
if err != nil {
return nil, util.Wrap(err, "Create job failed")
return nil, util.Wrap(err, "Create job failed.")
}
parameters, err := modelToCRDParameters(modelJob.RuntimeConfig.Parameters)
if err != nil {
return nil, util.Wrap(err, "Converting model.Job parameters to CDR parameters failed.")
}
crdTrigger, err := modelToCRDTrigger(modelJob.Trigger)
if err != nil {
return nil, err
}
scheduledWorkflow := &scheduledworkflow.ScheduledWorkflow{
ObjectMeta: metav1.ObjectMeta{GenerateName: swfGeneratedName},
Spec: scheduledworkflow.ScheduledWorkflowSpec{
Enabled: apiJob.Enabled,
MaxConcurrency: &apiJob.MaxConcurrency,
Trigger: *toCRDTrigger(apiJob.Trigger),
Enabled: modelJob.Enabled,
MaxConcurrency: &modelJob.MaxConcurrency,
Trigger: crdTrigger,
Workflow: &scheduledworkflow.WorkflowResource{
Parameters: toCRDParameter(apiJob.GetPipelineSpec().GetParameters()),
Parameters: parameters,
Spec: executionSpec.ToStringForSchedule(),
},
NoCatchup: util.BoolPointer(apiJob.NoCatchup),
NoCatchup: util.BoolPointer(modelJob.NoCatchup),
},
}
return scheduledWorkflow, nil
@ -94,6 +123,7 @@ func NewV2SpecTemplate(template []byte) (*V2Spec, error) {
if spec.GetRoot() == nil {
return nil, util.NewInvalidInputErrorWithDetails(ErrorInvalidPipelineSpec, "invalid v2 pipeline spec: root component is empty")
}
return &V2Spec{spec: &spec}, nil
}
@ -143,7 +173,7 @@ func (t *V2Spec) ParametersJSON() (string, error) {
return "[]", nil
}
func (t *V2Spec) RunWorkflow(apiRun *api.Run, options RunWorkflowOptions) (util.ExecutionSpec, error) {
func (t *V2Spec) RunWorkflow(apiRun *apiv1beta1.Run, options RunWorkflowOptions) (util.ExecutionSpec, error) {
bytes, err := protojson.Marshal(t.spec)
if err != nil {
return nil, util.Wrap(err, "Failed marshal pipeline spec to json")
@ -153,7 +183,7 @@ func (t *V2Spec) RunWorkflow(apiRun *api.Run, options RunWorkflowOptions) (util.
return nil, util.Wrap(err, "Failed to parse pipeline spec")
}
job := &pipelinespec.PipelineJob{PipelineSpec: spec}
jobRuntimeConfig, err := toPipelineJobRuntimeConfig(apiRun.GetPipelineSpec().GetRuntimeConfig())
jobRuntimeConfig, err := toPipelineJobRuntimeConfigV1(apiRun.GetPipelineSpec().GetRuntimeConfig())
if err != nil {
return nil, util.Wrap(err, "Failed to convert to PipelineJob RuntimeConfig")
}

View File

@ -417,7 +417,7 @@ func (s *JobApiTestSuite) TestJobApis_noCatchupOption() {
_, err = s.jobClient.Create(createJobRequest)
assert.Nil(t, err)
// The scheduledWorkflow CRD would create the run and it synced to the DB by persistent agent.
// The scheduledWorkflow CRD would create the run and it is synced to the DB by persistent agent.
// This could take a few seconds to finish.
/* ---------- Assert number of runs when catchup = true ---------- */
@ -429,7 +429,7 @@ func (s *JobApiTestSuite) TestJobApis_noCatchupOption() {
return err
}
if runsWhenCatchupTrue != 2 {
return fmt.Errorf("expected runsWhenCatchupTrue to be 1, got: %v", runsWhenCatchupTrue)
return fmt.Errorf("expected runsWhenCatchupTrue with periodic schedule to be 2, got: %v", runsWhenCatchupTrue)
}
_, runsWhenCatchupTrue, _, err = s.runClient.List(&runParams.ListRunsV1Params{
@ -439,8 +439,9 @@ func (s *JobApiTestSuite) TestJobApis_noCatchupOption() {
return err
}
if runsWhenCatchupTrue != 2 {
return fmt.Errorf("expected runsWhenCatchupTrue to be 1, got: %v", runsWhenCatchupTrue)
return fmt.Errorf("expected runsWhenCatchupTrue with cron schedule to be 2, got: %v", runsWhenCatchupTrue)
}
return nil
}); err != nil {
assert.Nil(t, err)
@ -455,7 +456,7 @@ func (s *JobApiTestSuite) TestJobApis_noCatchupOption() {
return err
}
if runsWhenCatchupFalse != 1 {
return fmt.Errorf("expected runsWhenCatchupFalse to be 1, got: %v", runsWhenCatchupFalse)
return fmt.Errorf("expected runsWhenCatchupFalse with periodic schedule to be 1, got: %v", runsWhenCatchupFalse)
}
_, runsWhenCatchupFalse, _, err = s.runClient.List(&runParams.ListRunsV1Params{
@ -465,7 +466,7 @@ func (s *JobApiTestSuite) TestJobApis_noCatchupOption() {
return err
}
if runsWhenCatchupFalse != 1 {
return fmt.Errorf("expected runsWhenCatchupFalse to be 1, got: %v", runsWhenCatchupFalse)
return fmt.Errorf("expected runsWhenCatchupFalse with cron schedule to be 1, got: %v", runsWhenCatchupFalse)
}
return nil
}); err != nil {