diff --git a/api/api/models_api_test.go b/api/api/models_api_test.go index a4fefdc1a..6aa28cd08 100644 --- a/api/api/models_api_test.go +++ b/api/api/models_api_test.go @@ -410,7 +410,7 @@ func TestDeleteModel(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{}, nil) + }, false).Return([]*models.PredictionJob{}, nil, nil) return svc }, mlflowDeleteService: func() *mlflowDeleteServiceMocks.Service { @@ -780,7 +780,7 @@ func TestDeleteModel(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{ + }, false).Return([]*models.PredictionJob{ { ID: models.ID(1), Name: "prediction-job-1", @@ -790,7 +790,7 @@ func TestDeleteModel(t *testing.T) { EnvironmentName: "dev", Status: models.JobRunning, }, - }, nil) + }, nil, nil) return svc }, mlflowDeleteService: func() *mlflowDeleteServiceMocks.Service { @@ -877,7 +877,7 @@ func TestDeleteModel(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{ + }, false).Return([]*models.PredictionJob{ { ID: models.ID(1), Name: "prediction-job-1", @@ -887,7 +887,7 @@ func TestDeleteModel(t *testing.T) { EnvironmentName: "dev", Status: models.JobFailed, }, - }, nil) + }, nil, nil) svc.On("StopPredictionJob", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return( nil, errors.New("failed to stop prediction job")) return svc @@ -1076,7 +1076,7 @@ func TestDeleteModel(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{}, nil) + }, false).Return([]*models.PredictionJob{}, nil, nil) return svc }, mlflowDeleteService: func() *mlflowDeleteServiceMocks.Service { @@ -1164,7 +1164,7 @@ func TestDeleteModel(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{}, nil) + }, false).Return([]*models.PredictionJob{}, nil, nil) return svc }, mlflowDeleteService: func() *mlflowDeleteServiceMocks.Service { @@ -1253,7 +1253,7 @@ func TestDeleteModel(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{}, nil) + }, false).Return([]*models.PredictionJob{}, nil, nil) return svc }, mlflowDeleteService: func() *mlflowDeleteServiceMocks.Service { diff --git a/api/api/prediction_job_api.go b/api/api/prediction_job_api.go index 23776a720..c19037ba1 100644 --- a/api/api/prediction_job_api.go +++ b/api/api/prediction_job_api.go @@ -21,6 +21,8 @@ import ( "gorm.io/gorm" + "github.com/caraml-dev/mlp/api/pkg/pagination" + "github.com/caraml-dev/merlin/models" "github.com/caraml-dev/merlin/service" ) @@ -30,6 +32,11 @@ type PredictionJobController struct { *AppContext } +type ListJobsPaginatedResponse struct { + Results []*models.PredictionJob `json:"results"` + Paging pagination.Paging `json:"paging"` +} + // Create method creates a prediction job. func (c *PredictionJobController) Create(r *http.Request, vars map[string]string, body interface{}) *Response { ctx := r.Context() @@ -67,8 +74,8 @@ func (c *PredictionJobController) Create(r *http.Request, vars map[string]string func (c *PredictionJobController) List(r *http.Request, vars map[string]string, _ interface{}) *Response { ctx := r.Context() - modelID, _ := models.ParseID(vars["model_id"]) versionID, _ := models.ParseID(vars["version_id"]) + modelID, _ := models.ParseID(vars["model_id"]) model, _, err := c.getModelAndVersion(ctx, modelID, versionID) if err != nil { @@ -82,8 +89,7 @@ func (c *PredictionJobController) List(r *http.Request, vars map[string]string, ModelID: modelID, VersionID: versionID, } - - jobs, err := c.PredictionJobService.ListPredictionJobs(ctx, model.Project, query) + jobs, _, err := c.PredictionJobService.ListPredictionJobs(ctx, model.Project, query, false) if err != nil { return InternalServerError(fmt.Sprintf("Error listing prediction jobs: %v", err)) } @@ -91,6 +97,40 @@ func (c *PredictionJobController) List(r *http.Request, vars map[string]string, return Ok(jobs) } +// ListInPage method lists all prediction jobs of a model and version ID, with pagination. +func (c *PredictionJobController) ListByPage(r *http.Request, vars map[string]string, _ interface{}) *Response { + ctx := r.Context() + + versionID, _ := models.ParseID(vars["version_id"]) + modelID, _ := models.ParseID(vars["model_id"]) + + model, _, err := c.getModelAndVersion(ctx, modelID, versionID) + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return NotFound(fmt.Sprintf("Model / version not found: %v", err)) + } + return InternalServerError(fmt.Sprintf("Error getting model / version: %v", err)) + } + + var query service.ListPredictionJobQuery + err = decoder.Decode(&query, r.URL.Query()) + if err != nil { + return BadRequest(fmt.Sprintf("Bad query %s", r.URL.Query())) + } + query.ModelID = modelID + query.VersionID = versionID + + jobs, paging, err := c.PredictionJobService.ListPredictionJobs(ctx, model.Project, &query, true) + if err != nil { + return InternalServerError(fmt.Sprintf("Error listing prediction jobs: %v", err)) + } + + return Ok(ListJobsPaginatedResponse{ + Results: jobs, + Paging: *paging, + }) +} + // Get method gets a prediction job. func (c *PredictionJobController) Get(r *http.Request, vars map[string]string, _ interface{}) *Response { ctx := r.Context() @@ -205,10 +245,38 @@ func (c *PredictionJobController) ListAllInProject(r *http.Request, vars map[str return NotFound(fmt.Sprintf("Project not found: %v", err)) } - jobs, err := c.PredictionJobService.ListPredictionJobs(ctx, project, &query) + jobs, _, err := c.PredictionJobService.ListPredictionJobs(ctx, project, &query, false) if err != nil { return InternalServerError(fmt.Sprintf("Error listing prediction jobs: %v", err)) } return Ok(jobs) } + +// ListAllInProject lists all prediction jobs of a project, with pagination +func (c *PredictionJobController) ListAllInProjectByPage(r *http.Request, vars map[string]string, body interface{}) *Response { + ctx := r.Context() + + var query service.ListPredictionJobQuery + err := decoder.Decode(&query, r.URL.Query()) + if err != nil { + return BadRequest(fmt.Sprintf("Bad query %s", r.URL.Query())) + } + + projectID, _ := models.ParseID(vars["project_id"]) + + project, err := c.ProjectsService.GetByID(ctx, int32(projectID)) + if err != nil { + return NotFound(fmt.Sprintf("Project not found: %v", err)) + } + + jobs, paging, err := c.PredictionJobService.ListPredictionJobs(ctx, project, &query, true) + if err != nil { + return InternalServerError(fmt.Sprintf("Error listing prediction jobs: %v", err)) + } + + return Ok(ListJobsPaginatedResponse{ + Results: jobs, + Paging: *paging, + }) +} diff --git a/api/api/prediction_job_api_test.go b/api/api/prediction_job_api_test.go index 139f7b46e..e8dfae825 100644 --- a/api/api/prediction_job_api_test.go +++ b/api/api/prediction_job_api_test.go @@ -30,6 +30,7 @@ import ( "github.com/caraml-dev/merlin/service" "github.com/caraml-dev/merlin/service/mocks" "github.com/caraml-dev/mlp/api/client" + "github.com/caraml-dev/mlp/api/pkg/pagination" ) func TestList(t *testing.T) { @@ -84,7 +85,7 @@ func TestList(t *testing.T) { svc.On("ListPredictionJobs", context.Background(), mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{ + }, false).Return([]*models.PredictionJob{ { ID: models.ID(1), Name: "prediction-job-1", @@ -93,7 +94,7 @@ func TestList(t *testing.T) { VersionModelID: models.ID(1), EnvironmentName: "dev", }, - }, nil) + }, nil, nil) return svc }, expected: &Response{ @@ -177,7 +178,7 @@ func TestList(t *testing.T) { svc.On("ListPredictionJobs", context.Background(), mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return(nil, fmt.Errorf("Connection refused")) + }, false).Return(nil, nil, fmt.Errorf("Connection refused")) return svc }, expected: &Response{ @@ -207,12 +208,207 @@ func TestList(t *testing.T) { }, }, } + resp := ctl.List(&http.Request{}, tC.vars, nil) assertEqualResponses(t, tC.expected, resp) }) } } +func TestListByPage(t *testing.T) { + testCases := []struct { + desc string + vars map[string]string + modelService func() *mocks.ModelsService + versionService func() *mocks.VersionsService + predictionJobService func() *mocks.PredictionJobService + expected *Response + }{ + { + desc: "Should succcess list prediction job", + vars: map[string]string{ + "model_id": "1", + "version_id": "1", + }, + modelService: func() *mocks.ModelsService { + svc := &mocks.ModelsService{} + svc.On("FindByID", mock.Anything, models.ID(1)).Return(&models.Model{ + ID: models.ID(1), + Name: "model-1", + ProjectID: models.ID(1), + Project: mlp.Project{}, + ExperimentID: 1, + Type: "pyfunc", + MlflowURL: "", + Endpoints: nil, + }, nil) + return svc + }, + versionService: func() *mocks.VersionsService { + svc := &mocks.VersionsService{} + svc.On("FindByID", mock.Anything, models.ID(1), models.ID(1), mock.Anything).Return(&models.Version{ + ID: models.ID(1), + ModelID: models.ID(1), + Model: &models.Model{ + ID: models.ID(1), + Name: "model-1", + ProjectID: models.ID(1), + Project: mlp.Project{}, + ExperimentID: 1, + Type: "pyfunc", + MlflowURL: "", + Endpoints: nil, + }, + }, nil) + return svc + }, + predictionJobService: func() *mocks.PredictionJobService { + svc := &mocks.PredictionJobService{} + svc.On("ListPredictionJobs", context.Background(), mock.Anything, &service.ListPredictionJobQuery{ + ModelID: models.ID(1), + VersionID: models.ID(1), + }, true).Return([]*models.PredictionJob{ + { + ID: models.ID(1), + Name: "prediction-job-1", + ProjectID: models.ID(1), + VersionID: models.ID(1), + VersionModelID: models.ID(1), + EnvironmentName: "dev", + }, + }, &pagination.Paging{ + Total: 1, + Page: 1, + Pages: 1, + }, nil) + return svc + }, + expected: &Response{ + code: http.StatusOK, + data: ListJobsPaginatedResponse{ + Results: []*models.PredictionJob{ + { + ID: models.ID(1), + Name: "prediction-job-1", + ProjectID: models.ID(1), + VersionID: models.ID(1), + VersionModelID: models.ID(1), + EnvironmentName: "dev", + }, + }, + Paging: pagination.Paging{ + Total: 1, + Page: 1, + Pages: 1, + }, + }, + }, + }, + { + desc: "Should return 500 if error fetching model", + vars: map[string]string{ + "model_id": "1", + "version_id": "1", + }, + modelService: func() *mocks.ModelsService { + svc := &mocks.ModelsService{} + svc.On("FindByID", mock.Anything, models.ID(1)).Return(nil, fmt.Errorf("Error creating secret: db is down")) + return svc + }, + versionService: func() *mocks.VersionsService { + svc := &mocks.VersionsService{} + return svc + }, + predictionJobService: func() *mocks.PredictionJobService { + svc := &mocks.PredictionJobService{} + return svc + }, + expected: &Response{ + code: http.StatusInternalServerError, + data: Error{Message: "Error getting model / version: error retrieving model with id: 1"}, + }, + }, + { + desc: "Should return 500 if list prediction job returning error", + vars: map[string]string{ + "model_id": "1", + "version_id": "1", + }, + modelService: func() *mocks.ModelsService { + svc := &mocks.ModelsService{} + svc.On("FindByID", mock.Anything, models.ID(1)).Return(&models.Model{ + ID: models.ID(1), + Name: "model-1", + ProjectID: models.ID(1), + Project: mlp.Project{}, + ExperimentID: 1, + Type: "pyfunc", + MlflowURL: "", + Endpoints: nil, + }, nil) + return svc + }, + versionService: func() *mocks.VersionsService { + svc := &mocks.VersionsService{} + svc.On("FindByID", mock.Anything, models.ID(1), models.ID(1), mock.Anything).Return(&models.Version{ + ID: models.ID(1), + ModelID: models.ID(1), + Model: &models.Model{ + ID: models.ID(1), + Name: "model-1", + ProjectID: models.ID(1), + Project: mlp.Project{}, + ExperimentID: 1, + Type: "pyfunc", + MlflowURL: "", + Endpoints: nil, + }, + }, nil) + return svc + }, + predictionJobService: func() *mocks.PredictionJobService { + svc := &mocks.PredictionJobService{} + svc.On("ListPredictionJobs", context.Background(), mock.Anything, &service.ListPredictionJobQuery{ + ModelID: models.ID(1), + VersionID: models.ID(1), + }, true).Return(nil, nil, fmt.Errorf("Connection refused")) + return svc + }, + expected: &Response{ + code: http.StatusInternalServerError, + data: Error{Message: "Error listing prediction jobs: Connection refused"}, + }, + }, + } + for _, tC := range testCases { + t.Run(tC.desc, func(t *testing.T) { + modelSvc := tC.modelService() + versionSvc := tC.versionService() + predictionJobSvc := tC.predictionJobService() + ctl := &PredictionJobController{ + AppContext: &AppContext{ + ModelsService: modelSvc, + VersionsService: versionSvc, + PredictionJobService: predictionJobSvc, + FeatureToggleConfig: config.FeatureToggleConfig{ + AlertConfig: config.AlertConfig{ + AlertEnabled: true, + }, + MonitoringConfig: config.MonitoringConfig{ + MonitoringEnabled: true, + MonitoringBaseURL: "http://grafana", + }, + }, + }, + } + + request, _ := http.NewRequest(http.MethodGet, "http://localhost:80", nil) + resp := ctl.ListByPage(request, tC.vars, nil) + assertEqualResponses(t, tC.expected, resp) + }) + } +} + func TestGet(t *testing.T) { trueBoolean := true testCases := []struct { @@ -1432,7 +1628,7 @@ func TestListAllInProject(t *testing.T) { svc.On("ListPredictionJobs", context.Background(), mock.Anything, &service.ListPredictionJobQuery{ Name: "prediction-job", ModelID: models.ID(1), - }).Return([]*models.PredictionJob{ + }, false).Return([]*models.PredictionJob{ { ID: models.ID(1), Name: "prediction-job-1", @@ -1441,7 +1637,7 @@ func TestListAllInProject(t *testing.T) { VersionModelID: models.ID(1), EnvironmentName: "dev", }, - }, nil) + }, nil, nil) return svc }, expected: &Response{ @@ -1504,7 +1700,7 @@ func TestListAllInProject(t *testing.T) { svc.On("ListPredictionJobs", context.Background(), mock.Anything, &service.ListPredictionJobQuery{ Name: "prediction-job", ModelID: models.ID(1), - }).Return(nil, fmt.Errorf("Error creating secret: db is down")) + }, false).Return(nil, nil, fmt.Errorf("Error creating secret: db is down")) return svc }, expected: &Response{ @@ -1537,3 +1733,153 @@ func TestListAllInProject(t *testing.T) { }) } } + +func TestListAllInProjectByPage(t *testing.T) { + testCases := []struct { + desc string + request *http.Request + vars map[string]string + projectService func() *mocks.ProjectsService + predictionJobService func() *mocks.PredictionJobService + expected *Response + }{ + { + desc: "Should success list of prediction job", + request: &http.Request{URL: &url.URL{ + RawQuery: "name=prediction-job&model_id=1", + }}, + vars: map[string]string{ + "project_id": "1", + }, + projectService: func() *mocks.ProjectsService { + svc := &mocks.ProjectsService{} + svc.On("GetByID", mock.Anything, int32(1)).Return(mlp.Project(client.Project{ + ID: 1, + Name: "project-1", + MLFlowTrackingURL: "http://mlflow.com", + Team: "dsp", + Stream: "dsp", + }), nil) + return svc + }, + predictionJobService: func() *mocks.PredictionJobService { + svc := &mocks.PredictionJobService{} + svc.On("ListPredictionJobs", context.Background(), mock.Anything, &service.ListPredictionJobQuery{ + Name: "prediction-job", + ModelID: models.ID(1), + }, true).Return([]*models.PredictionJob{ + { + ID: models.ID(1), + Name: "prediction-job-1", + ProjectID: models.ID(1), + VersionID: models.ID(1), + VersionModelID: models.ID(1), + EnvironmentName: "dev", + }, + }, &pagination.Paging{ + Total: 1, + Page: 1, + Pages: 1, + }, nil) + return svc + }, + expected: &Response{ + code: http.StatusOK, + data: ListJobsPaginatedResponse{ + Results: []*models.PredictionJob{ + { + ID: models.ID(1), + Name: "prediction-job-1", + ProjectID: models.ID(1), + VersionID: models.ID(1), + VersionModelID: models.ID(1), + EnvironmentName: "dev", + }, + }, + Paging: pagination.Paging{ + Total: 1, + Page: 1, + Pages: 1, + }, + }, + }, + }, + { + desc: "Should return 404 when error fetching project", + request: &http.Request{URL: &url.URL{ + RawQuery: "name=prediction-job&model_id=1", + }}, + vars: map[string]string{ + "project_id": "1", + }, + projectService: func() *mocks.ProjectsService { + svc := &mocks.ProjectsService{} + svc.On("GetByID", mock.Anything, int32(1)).Return(mlp.Project{}, fmt.Errorf("API is down")) + return svc + }, + predictionJobService: func() *mocks.PredictionJobService { + svc := &mocks.PredictionJobService{} + return svc + }, + expected: &Response{ + code: http.StatusNotFound, + data: Error{Message: "Project not found: API is down"}, + }, + }, + { + desc: "Should return 500 when error get list of prediction jobs", + request: &http.Request{URL: &url.URL{ + RawQuery: "name=prediction-job&model_id=1", + }}, + vars: map[string]string{ + "project_id": "1", + }, + projectService: func() *mocks.ProjectsService { + svc := &mocks.ProjectsService{} + svc.On("GetByID", mock.Anything, int32(1)).Return(mlp.Project(client.Project{ + ID: 1, + Name: "project-1", + MLFlowTrackingURL: "http://mlflow.com", + Team: "dsp", + Stream: "dsp", + }), nil) + return svc + }, + predictionJobService: func() *mocks.PredictionJobService { + svc := &mocks.PredictionJobService{} + svc.On("ListPredictionJobs", context.Background(), mock.Anything, &service.ListPredictionJobQuery{ + Name: "prediction-job", + ModelID: models.ID(1), + }, true).Return(nil, nil, fmt.Errorf("Error creating secret: db is down")) + return svc + }, + expected: &Response{ + code: http.StatusInternalServerError, + data: Error{Message: "Error listing prediction jobs: Error creating secret: db is down"}, + }, + }, + } + for _, tC := range testCases { + t.Run(tC.desc, func(t *testing.T) { + projectSvc := tC.projectService() + predictionJobSvc := tC.predictionJobService() + ctl := &PredictionJobController{ + AppContext: &AppContext{ + ProjectsService: projectSvc, + PredictionJobService: predictionJobSvc, + FeatureToggleConfig: config.FeatureToggleConfig{ + AlertConfig: config.AlertConfig{ + AlertEnabled: true, + }, + MonitoringConfig: config.MonitoringConfig{ + MonitoringEnabled: true, + MonitoringBaseURL: "http://grafana", + }, + }, + }, + } + resp := ctl.ListAllInProjectByPage(tC.request, tC.vars, nil) + assertEqualResponses(t, tC.expected, resp) + }) + } +} diff --git a/api/api/router.go b/api/api/router.go index c0a62436c..eca6695f6 100644 --- a/api/api/router.go +++ b/api/api/router.go @@ -226,7 +226,9 @@ func NewRouter(appCtx AppContext) (*mux.Router, error) { // Prediction Job API {http.MethodGet, "/projects/{project_id:[0-9]+}/jobs", nil, predictionJobController.ListAllInProject, "ListAllPredictionJobInProject"}, + {http.MethodGet, "/projects/{project_id:[0-9]+}/jobs-by-page", nil, predictionJobController.ListAllInProjectByPage, "ListAllPredictionJobInProjectByPage"}, {http.MethodGet, "/models/{model_id:[0-9]+}/versions/{version_id:[0-9]+}/jobs", nil, predictionJobController.List, "ListPredictionJob"}, + {http.MethodGet, "/models/{model_id:[0-9]+}/versions/{version_id:[0-9]+}/jobs-by-page", nil, predictionJobController.ListByPage, "ListPredictionJobByPage"}, {http.MethodGet, "/models/{model_id:[0-9]+}/versions/{version_id:[0-9]+}/jobs/{job_id:[0-9]+}", nil, predictionJobController.Get, "GetPredictionJob"}, {http.MethodPut, "/models/{model_id:[0-9]+}/versions/{version_id:[0-9]+}/jobs/{job_id:[0-9]+}/stop", nil, predictionJobController.Stop, "StopPredictionJob"}, {http.MethodPost, "/models/{model_id:[0-9]+}/versions/{version_id:[0-9]+}/jobs", models.PredictionJob{}, predictionJobController.Create, "CreatePredictionJob"}, diff --git a/api/api/versions_api.go b/api/api/versions_api.go index ebca9ef1d..aec0fc455 100644 --- a/api/api/versions_api.go +++ b/api/api/versions_api.go @@ -220,7 +220,7 @@ func (c *VersionsController) getInactivePredictionJobsForDeletion(ctx context.Co VersionID: version.ID, } - jobs, err := c.PredictionJobService.ListPredictionJobs(ctx, model.Project, jobQuery) + jobs, _, err := c.PredictionJobService.ListPredictionJobs(ctx, model.Project, jobQuery, false) if err != nil { return nil, InternalServerError("Failed listing prediction job") } diff --git a/api/api/versions_api_test.go b/api/api/versions_api_test.go index 97b39824b..d6edda955 100644 --- a/api/api/versions_api_test.go +++ b/api/api/versions_api_test.go @@ -1739,7 +1739,7 @@ func TestDeleteVersion(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{}, nil) + }, false).Return([]*models.PredictionJob{}, nil, nil) return svc }, mlflowDeleteService: func() *mlflowDeleteServiceMocks.Service { @@ -2015,7 +2015,7 @@ func TestDeleteVersion(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{ + }, false).Return([]*models.PredictionJob{ { ID: models.ID(1), Name: "prediction-job-1", @@ -2025,7 +2025,7 @@ func TestDeleteVersion(t *testing.T) { EnvironmentName: "dev", Status: models.JobRunning, }, - }, nil) + }, nil, nil) return svc }, mlflowDeleteService: func() *mlflowDeleteServiceMocks.Service { @@ -2089,7 +2089,7 @@ func TestDeleteVersion(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{ + }, false).Return([]*models.PredictionJob{ { ID: models.ID(1), Name: "prediction-job-1", @@ -2099,7 +2099,7 @@ func TestDeleteVersion(t *testing.T) { EnvironmentName: "dev", Status: models.JobFailed, }, - }, nil) + }, nil, nil) svc.On("StopPredictionJob", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return( nil, errors.New("failed to stop prediction job")) return svc @@ -2165,7 +2165,7 @@ func TestDeleteVersion(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{}, nil) + }, false).Return([]*models.PredictionJob{}, nil, nil) return svc }, mlflowDeleteService: func() *mlflowDeleteServiceMocks.Service { @@ -2230,7 +2230,7 @@ func TestDeleteVersion(t *testing.T) { svc.On("ListPredictionJobs", mock.Anything, mock.Anything, &service.ListPredictionJobQuery{ ModelID: models.ID(1), VersionID: models.ID(1), - }).Return([]*models.PredictionJob{}, nil) + }, false).Return([]*models.PredictionJob{}, nil, nil) return svc }, mlflowDeleteService: func() *mlflowDeleteServiceMocks.Service { diff --git a/api/client/api_endpoint.go b/api/client/api_endpoint.go index cf5a2ecd0..a097c7e68 100644 --- a/api/client/api_endpoint.go +++ b/api/client/api_endpoint.go @@ -37,11 +37,11 @@ func (r ApiModelsModelIdVersionsVersionIdEndpointEndpointIdContainersGetRequest) /* ModelsModelIdVersionsVersionIdEndpointEndpointIdContainersGet Get all container belong to a version endpoint - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @param endpointId - @return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdContainersGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @param endpointId + @return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdContainersGetRequest */ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdContainersGet(ctx context.Context, modelId int32, versionId int32, endpointId string) ApiModelsModelIdVersionsVersionIdEndpointEndpointIdContainersGetRequest { return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdContainersGetRequest{ @@ -54,8 +54,7 @@ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdCon } // Execute executes the request -// -// @return Container +// @return Container func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdContainersGetExecute(r ApiModelsModelIdVersionsVersionIdEndpointEndpointIdContainersGetRequest) (*Container, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -161,11 +160,11 @@ func (r ApiModelsModelIdVersionsVersionIdEndpointEndpointIdDeleteRequest) Execut /* ModelsModelIdVersionsVersionIdEndpointEndpointIdDelete Undeploy the specified model version deployment - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @param endpointId - @return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdDeleteRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @param endpointId + @return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdDeleteRequest */ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdDelete(ctx context.Context, modelId int32, versionId int32, endpointId string) ApiModelsModelIdVersionsVersionIdEndpointEndpointIdDeleteRequest { return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdDeleteRequest{ @@ -273,11 +272,11 @@ func (r ApiModelsModelIdVersionsVersionIdEndpointEndpointIdGetRequest) Execute() /* ModelsModelIdVersionsVersionIdEndpointEndpointIdGet Get version endpoint resource - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @param endpointId - @return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @param endpointId + @return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdGetRequest */ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdGet(ctx context.Context, modelId int32, versionId int32, endpointId string) ApiModelsModelIdVersionsVersionIdEndpointEndpointIdGetRequest { return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdGetRequest{ @@ -290,8 +289,7 @@ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdGet } // Execute executes the request -// -// @return VersionEndpoint +// @return VersionEndpoint func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdGetExecute(r ApiModelsModelIdVersionsVersionIdEndpointEndpointIdGetRequest) (*VersionEndpoint, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -403,11 +401,11 @@ func (r ApiModelsModelIdVersionsVersionIdEndpointEndpointIdPutRequest) Execute() /* ModelsModelIdVersionsVersionIdEndpointEndpointIdPut Modify version endpoint, this API will redeploy the associated deployment - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @param endpointId - @return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdPutRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @param endpointId + @return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdPutRequest */ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdPut(ctx context.Context, modelId int32, versionId int32, endpointId string) ApiModelsModelIdVersionsVersionIdEndpointEndpointIdPutRequest { return ApiModelsModelIdVersionsVersionIdEndpointEndpointIdPutRequest{ @@ -420,8 +418,7 @@ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdPut } // Execute executes the request -// -// @return VersionEndpoint +// @return VersionEndpoint func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointEndpointIdPutExecute(r ApiModelsModelIdVersionsVersionIdEndpointEndpointIdPutRequest) (*VersionEndpoint, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPut @@ -528,10 +525,10 @@ func (r ApiModelsModelIdVersionsVersionIdEndpointGetRequest) Execute() ([]Versio /* ModelsModelIdVersionsVersionIdEndpointGet List all endpoint of a model version - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @return ApiModelsModelIdVersionsVersionIdEndpointGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdEndpointGetRequest */ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointGet(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdEndpointGetRequest { return ApiModelsModelIdVersionsVersionIdEndpointGetRequest{ @@ -543,8 +540,7 @@ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointGet(ctx conte } // Execute executes the request -// -// @return []VersionEndpoint +// @return []VersionEndpoint func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointGetExecute(r ApiModelsModelIdVersionsVersionIdEndpointGetRequest) ([]VersionEndpoint, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -654,10 +650,10 @@ func (r ApiModelsModelIdVersionsVersionIdEndpointPostRequest) Execute() (*Versio /* ModelsModelIdVersionsVersionIdEndpointPost Deploy specific version of the models - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @return ApiModelsModelIdVersionsVersionIdEndpointPostRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdEndpointPostRequest */ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointPost(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdEndpointPostRequest { return ApiModelsModelIdVersionsVersionIdEndpointPostRequest{ @@ -669,8 +665,7 @@ func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointPost(ctx cont } // Execute executes the request -// -// @return VersionEndpoint +// @return VersionEndpoint func (a *EndpointAPIService) ModelsModelIdVersionsVersionIdEndpointPostExecute(r ApiModelsModelIdVersionsVersionIdEndpointPostRequest) (*VersionEndpoint, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost diff --git a/api/client/api_environment.go b/api/client/api_environment.go index fee604679..f3cb910ee 100644 --- a/api/client/api_environment.go +++ b/api/client/api_environment.go @@ -41,8 +41,8 @@ EnvironmentsGet List available environment Environment can be filtered by optional `name` parameter - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiEnvironmentsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiEnvironmentsGetRequest */ func (a *EnvironmentAPIService) EnvironmentsGet(ctx context.Context) ApiEnvironmentsGetRequest { return ApiEnvironmentsGetRequest{ @@ -52,8 +52,7 @@ func (a *EnvironmentAPIService) EnvironmentsGet(ctx context.Context) ApiEnvironm } // Execute executes the request -// -// @return []Environment +// @return []Environment func (a *EnvironmentAPIService) EnvironmentsGetExecute(r ApiEnvironmentsGetRequest) ([]Environment, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet diff --git a/api/client/api_log.go b/api/client/api_log.go index 4cc9adabe..a83066ebe 100644 --- a/api/client/api_log.go +++ b/api/client/api_log.go @@ -135,8 +135,8 @@ func (r ApiLogsGetRequest) Execute() (*http.Response, error) { /* LogsGet Retrieve log from a container - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiLogsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiLogsGetRequest */ func (a *LogAPIService) LogsGet(ctx context.Context) ApiLogsGetRequest { return ApiLogsGetRequest{ diff --git a/api/client/api_model_endpoints.go b/api/client/api_model_endpoints.go index 5bbaeef17..f5f5c0e19 100644 --- a/api/client/api_model_endpoints.go +++ b/api/client/api_model_endpoints.go @@ -35,9 +35,9 @@ func (r ApiModelsModelIdEndpointsGetRequest) Execute() ([]ModelEndpoint, *http.R /* ModelsModelIdEndpointsGet List model endpoint - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @return ApiModelsModelIdEndpointsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @return ApiModelsModelIdEndpointsGetRequest */ func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsGet(ctx context.Context, modelId int32) ApiModelsModelIdEndpointsGetRequest { return ApiModelsModelIdEndpointsGetRequest{ @@ -48,8 +48,7 @@ func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsGet(ctx context.Context } // Execute executes the request -// -// @return []ModelEndpoint +// @return []ModelEndpoint func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsGetExecute(r ApiModelsModelIdEndpointsGetRequest) ([]ModelEndpoint, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -152,10 +151,10 @@ func (r ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest) Execute() (*http. /* ModelsModelIdEndpointsModelEndpointIdDelete Stop serving traffic to the model endpoint, then delete it. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param modelEndpointId - @return ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param modelEndpointId + @return ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest */ func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdDelete(ctx context.Context, modelId int32, modelEndpointId int32) ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest { return ApiModelsModelIdEndpointsModelEndpointIdDeleteRequest{ @@ -260,10 +259,10 @@ func (r ApiModelsModelIdEndpointsModelEndpointIdGetRequest) Execute() (*ModelEnd /* ModelsModelIdEndpointsModelEndpointIdGet Get a model endpoint - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param modelEndpointId - @return ApiModelsModelIdEndpointsModelEndpointIdGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param modelEndpointId + @return ApiModelsModelIdEndpointsModelEndpointIdGetRequest */ func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdGet(ctx context.Context, modelId int32, modelEndpointId int32) ApiModelsModelIdEndpointsModelEndpointIdGetRequest { return ApiModelsModelIdEndpointsModelEndpointIdGetRequest{ @@ -275,8 +274,7 @@ func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdGet(ctx } // Execute executes the request -// -// @return ModelEndpoint +// @return ModelEndpoint func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdGetExecute(r ApiModelsModelIdEndpointsModelEndpointIdGetRequest) (*ModelEndpoint, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -386,10 +384,10 @@ func (r ApiModelsModelIdEndpointsModelEndpointIdPutRequest) Execute() (*ModelEnd /* ModelsModelIdEndpointsModelEndpointIdPut Update model endpoint data. Mainly used to update its rule. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param modelEndpointId - @return ApiModelsModelIdEndpointsModelEndpointIdPutRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param modelEndpointId + @return ApiModelsModelIdEndpointsModelEndpointIdPutRequest */ func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdPut(ctx context.Context, modelId int32, modelEndpointId int32) ApiModelsModelIdEndpointsModelEndpointIdPutRequest { return ApiModelsModelIdEndpointsModelEndpointIdPutRequest{ @@ -401,8 +399,7 @@ func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdPut(ctx } // Execute executes the request -// -// @return ModelEndpoint +// @return ModelEndpoint func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsModelEndpointIdPutExecute(r ApiModelsModelIdEndpointsModelEndpointIdPutRequest) (*ModelEndpoint, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPut @@ -514,9 +511,9 @@ func (r ApiModelsModelIdEndpointsPostRequest) Execute() (*ModelEndpoint, *http.R /* ModelsModelIdEndpointsPost Create a model endpoint - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @return ApiModelsModelIdEndpointsPostRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @return ApiModelsModelIdEndpointsPostRequest */ func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsPost(ctx context.Context, modelId int32) ApiModelsModelIdEndpointsPostRequest { return ApiModelsModelIdEndpointsPostRequest{ @@ -527,8 +524,7 @@ func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsPost(ctx context.Contex } // Execute executes the request -// -// @return ModelEndpoint +// @return ModelEndpoint func (a *ModelEndpointsAPIService) ModelsModelIdEndpointsPostExecute(r ApiModelsModelIdEndpointsPostRequest) (*ModelEndpoint, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost @@ -642,9 +638,9 @@ func (r ApiProjectsProjectIdModelEndpointsGetRequest) Execute() ([]ModelEndpoint /* ProjectsProjectIdModelEndpointsGet List existing model endpoints for all models in particular project - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId Filter list of model endpoints by specific `project_id` - @return ApiProjectsProjectIdModelEndpointsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Filter list of model endpoints by specific `project_id` + @return ApiProjectsProjectIdModelEndpointsGetRequest */ func (a *ModelEndpointsAPIService) ProjectsProjectIdModelEndpointsGet(ctx context.Context, projectId int32) ApiProjectsProjectIdModelEndpointsGetRequest { return ApiProjectsProjectIdModelEndpointsGetRequest{ @@ -655,8 +651,7 @@ func (a *ModelEndpointsAPIService) ProjectsProjectIdModelEndpointsGet(ctx contex } // Execute executes the request -// -// @return []ModelEndpoint +// @return []ModelEndpoint func (a *ModelEndpointsAPIService) ProjectsProjectIdModelEndpointsGetExecute(r ApiProjectsProjectIdModelEndpointsGetRequest) ([]ModelEndpoint, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet diff --git a/api/client/api_model_schema.go b/api/client/api_model_schema.go index f13e795c7..5396dc1c5 100644 --- a/api/client/api_model_schema.go +++ b/api/client/api_model_schema.go @@ -35,9 +35,9 @@ func (r ApiModelsModelIdSchemasGetRequest) Execute() ([]ModelSchema, *http.Respo /* ModelsModelIdSchemasGet List all of the model schemas - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @return ApiModelsModelIdSchemasGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @return ApiModelsModelIdSchemasGetRequest */ func (a *ModelSchemaAPIService) ModelsModelIdSchemasGet(ctx context.Context, modelId int32) ApiModelsModelIdSchemasGetRequest { return ApiModelsModelIdSchemasGetRequest{ @@ -48,8 +48,7 @@ func (a *ModelSchemaAPIService) ModelsModelIdSchemasGet(ctx context.Context, mod } // Execute executes the request -// -// @return []ModelSchema +// @return []ModelSchema func (a *ModelSchemaAPIService) ModelsModelIdSchemasGetExecute(r ApiModelsModelIdSchemasGetRequest) ([]ModelSchema, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -157,9 +156,9 @@ func (r ApiModelsModelIdSchemasPutRequest) Execute() (*ModelSchema, *http.Respon /* ModelsModelIdSchemasPut Creating new schemas for a model - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @return ApiModelsModelIdSchemasPutRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @return ApiModelsModelIdSchemasPutRequest */ func (a *ModelSchemaAPIService) ModelsModelIdSchemasPut(ctx context.Context, modelId int32) ApiModelsModelIdSchemasPutRequest { return ApiModelsModelIdSchemasPutRequest{ @@ -170,8 +169,7 @@ func (a *ModelSchemaAPIService) ModelsModelIdSchemasPut(ctx context.Context, mod } // Execute executes the request -// -// @return ModelSchema +// @return ModelSchema func (a *ModelSchemaAPIService) ModelsModelIdSchemasPutExecute(r ApiModelsModelIdSchemasPutRequest) (*ModelSchema, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPut @@ -276,10 +274,10 @@ func (r ApiModelsModelIdSchemasSchemaIdDeleteRequest) Execute() (*http.Response, /* ModelsModelIdSchemasSchemaIdDelete Delete schema - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param schemaId - @return ApiModelsModelIdSchemasSchemaIdDeleteRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param schemaId + @return ApiModelsModelIdSchemasSchemaIdDeleteRequest */ func (a *ModelSchemaAPIService) ModelsModelIdSchemasSchemaIdDelete(ctx context.Context, modelId int32, schemaId int32) ApiModelsModelIdSchemasSchemaIdDeleteRequest { return ApiModelsModelIdSchemasSchemaIdDeleteRequest{ @@ -384,10 +382,10 @@ func (r ApiModelsModelIdSchemasSchemaIdGetRequest) Execute() (*ModelSchema, *htt /* ModelsModelIdSchemasSchemaIdGet Get detail of the schema - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param schemaId - @return ApiModelsModelIdSchemasSchemaIdGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param schemaId + @return ApiModelsModelIdSchemasSchemaIdGetRequest */ func (a *ModelSchemaAPIService) ModelsModelIdSchemasSchemaIdGet(ctx context.Context, modelId int32, schemaId int32) ApiModelsModelIdSchemasSchemaIdGetRequest { return ApiModelsModelIdSchemasSchemaIdGetRequest{ @@ -399,8 +397,7 @@ func (a *ModelSchemaAPIService) ModelsModelIdSchemasSchemaIdGet(ctx context.Cont } // Execute executes the request -// -// @return ModelSchema +// @return ModelSchema func (a *ModelSchemaAPIService) ModelsModelIdSchemasSchemaIdGetExecute(r ApiModelsModelIdSchemasSchemaIdGetRequest) (*ModelSchema, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet diff --git a/api/client/api_models.go b/api/client/api_models.go index 294e67b66..41b692a69 100644 --- a/api/client/api_models.go +++ b/api/client/api_models.go @@ -34,8 +34,8 @@ func (r ApiAlertsTeamsGetRequest) Execute() ([]string, *http.Response, error) { /* AlertsTeamsGet Lists teams for alert notification channel. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiAlertsTeamsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiAlertsTeamsGetRequest */ func (a *ModelsAPIService) AlertsTeamsGet(ctx context.Context) ApiAlertsTeamsGetRequest { return ApiAlertsTeamsGetRequest{ @@ -45,8 +45,7 @@ func (a *ModelsAPIService) AlertsTeamsGet(ctx context.Context) ApiAlertsTeamsGet } // Execute executes the request -// -// @return []string +// @return []string func (a *ModelsAPIService) AlertsTeamsGetExecute(r ApiAlertsTeamsGetRequest) ([]string, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -147,9 +146,9 @@ func (r ApiModelsModelIdAlertsGetRequest) Execute() ([]ModelEndpointAlert, *http /* ModelsModelIdAlertsGet Lists alerts for given model. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @return ApiModelsModelIdAlertsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @return ApiModelsModelIdAlertsGetRequest */ func (a *ModelsAPIService) ModelsModelIdAlertsGet(ctx context.Context, modelId int32) ApiModelsModelIdAlertsGetRequest { return ApiModelsModelIdAlertsGetRequest{ @@ -160,8 +159,7 @@ func (a *ModelsAPIService) ModelsModelIdAlertsGet(ctx context.Context, modelId i } // Execute executes the request -// -// @return []ModelEndpointAlert +// @return []ModelEndpointAlert func (a *ModelsAPIService) ModelsModelIdAlertsGetExecute(r ApiModelsModelIdAlertsGetRequest) ([]ModelEndpointAlert, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -264,10 +262,10 @@ func (r ApiModelsModelIdEndpointsModelEndpointIdAlertGetRequest) Execute() (*Mod /* ModelsModelIdEndpointsModelEndpointIdAlertGet Gets alert for given model endpoint. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param modelEndpointId - @return ApiModelsModelIdEndpointsModelEndpointIdAlertGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param modelEndpointId + @return ApiModelsModelIdEndpointsModelEndpointIdAlertGetRequest */ func (a *ModelsAPIService) ModelsModelIdEndpointsModelEndpointIdAlertGet(ctx context.Context, modelId int32, modelEndpointId string) ApiModelsModelIdEndpointsModelEndpointIdAlertGetRequest { return ApiModelsModelIdEndpointsModelEndpointIdAlertGetRequest{ @@ -279,8 +277,7 @@ func (a *ModelsAPIService) ModelsModelIdEndpointsModelEndpointIdAlertGet(ctx con } // Execute executes the request -// -// @return ModelEndpointAlert +// @return ModelEndpointAlert func (a *ModelsAPIService) ModelsModelIdEndpointsModelEndpointIdAlertGetExecute(r ApiModelsModelIdEndpointsModelEndpointIdAlertGetRequest) (*ModelEndpointAlert, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -390,10 +387,10 @@ func (r ApiModelsModelIdEndpointsModelEndpointIdAlertPostRequest) Execute() (*ht /* ModelsModelIdEndpointsModelEndpointIdAlertPost Creates alert for given model endpoint. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param modelEndpointId - @return ApiModelsModelIdEndpointsModelEndpointIdAlertPostRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param modelEndpointId + @return ApiModelsModelIdEndpointsModelEndpointIdAlertPostRequest */ func (a *ModelsAPIService) ModelsModelIdEndpointsModelEndpointIdAlertPost(ctx context.Context, modelId int32, modelEndpointId string) ApiModelsModelIdEndpointsModelEndpointIdAlertPostRequest { return ApiModelsModelIdEndpointsModelEndpointIdAlertPostRequest{ @@ -506,10 +503,10 @@ func (r ApiModelsModelIdEndpointsModelEndpointIdAlertPutRequest) Execute() (*htt /* ModelsModelIdEndpointsModelEndpointIdAlertPut Creates alert for given model endpoint. - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param modelEndpointId - @return ApiModelsModelIdEndpointsModelEndpointIdAlertPutRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param modelEndpointId + @return ApiModelsModelIdEndpointsModelEndpointIdAlertPutRequest */ func (a *ModelsAPIService) ModelsModelIdEndpointsModelEndpointIdAlertPut(ctx context.Context, modelId int32, modelEndpointId string) ApiModelsModelIdEndpointsModelEndpointIdAlertPutRequest { return ApiModelsModelIdEndpointsModelEndpointIdAlertPutRequest{ @@ -622,9 +619,9 @@ func (r ApiProjectsProjectIdModelsGetRequest) Execute() ([]Model, *http.Response /* ProjectsProjectIdModelsGet List existing models - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId Filter list of models by specific `project_id` - @return ApiProjectsProjectIdModelsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Filter list of models by specific `project_id` + @return ApiProjectsProjectIdModelsGetRequest */ func (a *ModelsAPIService) ProjectsProjectIdModelsGet(ctx context.Context, projectId int32) ApiProjectsProjectIdModelsGetRequest { return ApiProjectsProjectIdModelsGetRequest{ @@ -635,8 +632,7 @@ func (a *ModelsAPIService) ProjectsProjectIdModelsGet(ctx context.Context, proje } // Execute executes the request -// -// @return []Model +// @return []Model func (a *ModelsAPIService) ProjectsProjectIdModelsGetExecute(r ApiProjectsProjectIdModelsGetRequest) ([]Model, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -742,10 +738,10 @@ func (r ApiProjectsProjectIdModelsModelIdDeleteRequest) Execute() (int32, *http. /* ProjectsProjectIdModelsModelIdDelete Delete model - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId project id of the project to be deleted - @param modelId model id of the model to be deleted - @return ApiProjectsProjectIdModelsModelIdDeleteRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId project id of the project to be deleted + @param modelId model id of the model to be deleted + @return ApiProjectsProjectIdModelsModelIdDeleteRequest */ func (a *ModelsAPIService) ProjectsProjectIdModelsModelIdDelete(ctx context.Context, projectId int32, modelId int32) ApiProjectsProjectIdModelsModelIdDeleteRequest { return ApiProjectsProjectIdModelsModelIdDeleteRequest{ @@ -757,8 +753,7 @@ func (a *ModelsAPIService) ProjectsProjectIdModelsModelIdDelete(ctx context.Cont } // Execute executes the request -// -// @return int32 +// @return int32 func (a *ModelsAPIService) ProjectsProjectIdModelsModelIdDeleteExecute(r ApiProjectsProjectIdModelsModelIdDeleteRequest) (int32, *http.Response, error) { var ( localVarHTTPMethod = http.MethodDelete @@ -862,10 +857,10 @@ func (r ApiProjectsProjectIdModelsModelIdGetRequest) Execute() ([]Model, *http.R /* ProjectsProjectIdModelsModelIdGet Get model - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId project id of the project to be retrieved - @param modelId model id of the model to be retrieved - @return ApiProjectsProjectIdModelsModelIdGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId project id of the project to be retrieved + @param modelId model id of the model to be retrieved + @return ApiProjectsProjectIdModelsModelIdGetRequest */ func (a *ModelsAPIService) ProjectsProjectIdModelsModelIdGet(ctx context.Context, projectId int32, modelId int32) ApiProjectsProjectIdModelsModelIdGetRequest { return ApiProjectsProjectIdModelsModelIdGetRequest{ @@ -877,8 +872,7 @@ func (a *ModelsAPIService) ProjectsProjectIdModelsModelIdGet(ctx context.Context } // Execute executes the request -// -// @return []Model +// @return []Model func (a *ModelsAPIService) ProjectsProjectIdModelsModelIdGetExecute(r ApiProjectsProjectIdModelsModelIdGetRequest) ([]Model, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -987,9 +981,9 @@ func (r ApiProjectsProjectIdModelsPostRequest) Execute() (*Model, *http.Response /* ProjectsProjectIdModelsPost Register a new models - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId Create new model in a specific `project_id` - @return ApiProjectsProjectIdModelsPostRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId Create new model in a specific `project_id` + @return ApiProjectsProjectIdModelsPostRequest */ func (a *ModelsAPIService) ProjectsProjectIdModelsPost(ctx context.Context, projectId int32) ApiProjectsProjectIdModelsPostRequest { return ApiProjectsProjectIdModelsPostRequest{ @@ -1000,8 +994,7 @@ func (a *ModelsAPIService) ProjectsProjectIdModelsPost(ctx context.Context, proj } // Execute executes the request -// -// @return Model +// @return Model func (a *ModelsAPIService) ProjectsProjectIdModelsPostExecute(r ApiProjectsProjectIdModelsPostRequest) (*Model, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost diff --git a/api/client/api_prediction_jobs.go b/api/client/api_prediction_jobs.go index a66a65fdb..7f1e977b5 100644 --- a/api/client/api_prediction_jobs.go +++ b/api/client/api_prediction_jobs.go @@ -22,6 +22,154 @@ import ( // PredictionJobsAPIService PredictionJobsAPI service type PredictionJobsAPIService service +type ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest struct { + ctx context.Context + ApiService *PredictionJobsAPIService + modelId int32 + versionId int32 + page *int32 + pageSize *int32 + search *string +} + +func (r ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest) Page(page int32) ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest { + r.page = &page + return r +} + +// Number of items on each page. It defaults to 10. +func (r ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest) PageSize(pageSize int32) ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest { + r.pageSize = &pageSize + return r +} + +// Search job name for a partial match of the search text +func (r ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest) Search(search string) ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest { + r.search = &search + return r +} + +func (r ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest) Execute() (*ListJobsPaginatedResponse, *http.Response, error) { + return r.ApiService.ModelsModelIdVersionsVersionIdJobsByPageGetExecute(r) +} + +/* +ModelsModelIdVersionsVersionIdJobsByPageGet List all prediction jobs of a model version with pagination + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest +*/ +func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsByPageGet(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest { + return ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest{ + ApiService: a, + ctx: ctx, + modelId: modelId, + versionId: versionId, + } +} + +// Execute executes the request +// @return ListJobsPaginatedResponse +func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsByPageGetExecute(r ApiModelsModelIdVersionsVersionIdJobsByPageGetRequest) (*ListJobsPaginatedResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListJobsPaginatedResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PredictionJobsAPIService.ModelsModelIdVersionsVersionIdJobsByPageGet") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/models/{model_id}/versions/{version_id}/jobs-by-page" + localVarPath = strings.Replace(localVarPath, "{"+"model_id"+"}", url.PathEscape(parameterValueToString(r.modelId, "modelId")), -1) + localVarPath = strings.Replace(localVarPath, "{"+"version_id"+"}", url.PathEscape(parameterValueToString(r.versionId, "versionId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.page != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "") + } + if r.pageSize != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "page_size", r.pageSize, "") + } + if r.search != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "search", r.search, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"*/*"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Bearer"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type ApiModelsModelIdVersionsVersionIdJobsGetRequest struct { ctx context.Context ApiService *PredictionJobsAPIService @@ -34,12 +182,14 @@ func (r ApiModelsModelIdVersionsVersionIdJobsGetRequest) Execute() ([]Prediction } /* -ModelsModelIdVersionsVersionIdJobsGet List all prediction jobs of a model version +ModelsModelIdVersionsVersionIdJobsGet List all prediction jobs of a model version. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdJobsGetRequest - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @return ApiModelsModelIdVersionsVersionIdJobsGetRequest +Deprecated */ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsGet(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdJobsGetRequest { return ApiModelsModelIdVersionsVersionIdJobsGetRequest{ @@ -51,8 +201,8 @@ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsGet(ctx con } // Execute executes the request -// -// @return []PredictionJob +// @return []PredictionJob +// Deprecated func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsGetExecute(r ApiModelsModelIdVersionsVersionIdJobsGetRequest) ([]PredictionJob, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -157,11 +307,11 @@ func (r ApiModelsModelIdVersionsVersionIdJobsJobIdContainersGetRequest) Execute( /* ModelsModelIdVersionsVersionIdJobsJobIdContainersGet Get all container belong to a prediction job - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @param jobId - @return ApiModelsModelIdVersionsVersionIdJobsJobIdContainersGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @param jobId + @return ApiModelsModelIdVersionsVersionIdJobsJobIdContainersGetRequest */ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsJobIdContainersGet(ctx context.Context, modelId int32, versionId int32, jobId string) ApiModelsModelIdVersionsVersionIdJobsJobIdContainersGetRequest { return ApiModelsModelIdVersionsVersionIdJobsJobIdContainersGetRequest{ @@ -174,8 +324,7 @@ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsJobIdContai } // Execute executes the request -// -// @return Container +// @return Container func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsJobIdContainersGetExecute(r ApiModelsModelIdVersionsVersionIdJobsJobIdContainersGetRequest) (*Container, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -281,11 +430,11 @@ func (r ApiModelsModelIdVersionsVersionIdJobsJobIdGetRequest) Execute() (*Predic /* ModelsModelIdVersionsVersionIdJobsJobIdGet Get prediction jobs with given id - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @param jobId - @return ApiModelsModelIdVersionsVersionIdJobsJobIdGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @param jobId + @return ApiModelsModelIdVersionsVersionIdJobsJobIdGetRequest */ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsJobIdGet(ctx context.Context, modelId int32, versionId int32, jobId int32) ApiModelsModelIdVersionsVersionIdJobsJobIdGetRequest { return ApiModelsModelIdVersionsVersionIdJobsJobIdGetRequest{ @@ -298,8 +447,7 @@ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsJobIdGet(ct } // Execute executes the request -// -// @return PredictionJob +// @return PredictionJob func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsJobIdGetExecute(r ApiModelsModelIdVersionsVersionIdJobsJobIdGetRequest) (*PredictionJob, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -405,11 +553,11 @@ func (r ApiModelsModelIdVersionsVersionIdJobsJobIdStopPutRequest) Execute() (*ht /* ModelsModelIdVersionsVersionIdJobsJobIdStopPut Stop prediction jobs with given id - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @param jobId - @return ApiModelsModelIdVersionsVersionIdJobsJobIdStopPutRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @param jobId + @return ApiModelsModelIdVersionsVersionIdJobsJobIdStopPutRequest */ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsJobIdStopPut(ctx context.Context, modelId int32, versionId int32, jobId int32) ApiModelsModelIdVersionsVersionIdJobsJobIdStopPutRequest { return ApiModelsModelIdVersionsVersionIdJobsJobIdStopPutRequest{ @@ -522,10 +670,10 @@ func (r ApiModelsModelIdVersionsVersionIdJobsPostRequest) Execute() (*Prediction /* ModelsModelIdVersionsVersionIdJobsPost Create a prediction job from the given model version - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @return ApiModelsModelIdVersionsVersionIdJobsPostRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdJobsPostRequest */ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsPost(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdJobsPostRequest { return ApiModelsModelIdVersionsVersionIdJobsPostRequest{ @@ -537,8 +685,7 @@ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsPost(ctx co } // Execute executes the request -// -// @return PredictionJob +// @return PredictionJob func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsPostExecute(r ApiModelsModelIdVersionsVersionIdJobsPostRequest) (*PredictionJob, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost @@ -630,6 +777,204 @@ func (a *PredictionJobsAPIService) ModelsModelIdVersionsVersionIdJobsPostExecute return localVarReturnValue, localVarHTTPResponse, nil } +type ApiProjectsProjectIdJobsByPageGetRequest struct { + ctx context.Context + ApiService *PredictionJobsAPIService + projectId int32 + page *int32 + id *int32 + name *string + search *string + modelId *int32 + versionId *int32 + status *string + error_ *string + pageSize *int32 +} + +func (r ApiProjectsProjectIdJobsByPageGetRequest) Page(page int32) ApiProjectsProjectIdJobsByPageGetRequest { + r.page = &page + return r +} + +func (r ApiProjectsProjectIdJobsByPageGetRequest) Id(id int32) ApiProjectsProjectIdJobsByPageGetRequest { + r.id = &id + return r +} + +func (r ApiProjectsProjectIdJobsByPageGetRequest) Name(name string) ApiProjectsProjectIdJobsByPageGetRequest { + r.name = &name + return r +} + +// Search job name for a partial match of the search text +func (r ApiProjectsProjectIdJobsByPageGetRequest) Search(search string) ApiProjectsProjectIdJobsByPageGetRequest { + r.search = &search + return r +} + +func (r ApiProjectsProjectIdJobsByPageGetRequest) ModelId(modelId int32) ApiProjectsProjectIdJobsByPageGetRequest { + r.modelId = &modelId + return r +} + +func (r ApiProjectsProjectIdJobsByPageGetRequest) VersionId(versionId int32) ApiProjectsProjectIdJobsByPageGetRequest { + r.versionId = &versionId + return r +} + +func (r ApiProjectsProjectIdJobsByPageGetRequest) Status(status string) ApiProjectsProjectIdJobsByPageGetRequest { + r.status = &status + return r +} + +func (r ApiProjectsProjectIdJobsByPageGetRequest) Error_(error_ string) ApiProjectsProjectIdJobsByPageGetRequest { + r.error_ = &error_ + return r +} + +// Number of items on each page. It defaults to 10. +func (r ApiProjectsProjectIdJobsByPageGetRequest) PageSize(pageSize int32) ApiProjectsProjectIdJobsByPageGetRequest { + r.pageSize = &pageSize + return r +} + +func (r ApiProjectsProjectIdJobsByPageGetRequest) Execute() (*ListJobsPaginatedResponse, *http.Response, error) { + return r.ApiService.ProjectsProjectIdJobsByPageGetExecute(r) +} + +/* +ProjectsProjectIdJobsByPageGet List all prediction jobs created using the model with pagination + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @return ApiProjectsProjectIdJobsByPageGetRequest +*/ +func (a *PredictionJobsAPIService) ProjectsProjectIdJobsByPageGet(ctx context.Context, projectId int32) ApiProjectsProjectIdJobsByPageGetRequest { + return ApiProjectsProjectIdJobsByPageGetRequest{ + ApiService: a, + ctx: ctx, + projectId: projectId, + } +} + +// Execute executes the request +// @return ListJobsPaginatedResponse +func (a *PredictionJobsAPIService) ProjectsProjectIdJobsByPageGetExecute(r ApiProjectsProjectIdJobsByPageGetRequest) (*ListJobsPaginatedResponse, *http.Response, error) { + var ( + localVarHTTPMethod = http.MethodGet + localVarPostBody interface{} + formFiles []formFile + localVarReturnValue *ListJobsPaginatedResponse + ) + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "PredictionJobsAPIService.ProjectsProjectIdJobsByPageGet") + if err != nil { + return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/projects/{project_id}/jobs-by-page" + localVarPath = strings.Replace(localVarPath, "{"+"project_id"+"}", url.PathEscape(parameterValueToString(r.projectId, "projectId")), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if r.page != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "page", r.page, "") + } + if r.id != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "id", r.id, "") + } + if r.name != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "") + } + if r.search != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "search", r.search, "") + } + if r.modelId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "model_id", r.modelId, "") + } + if r.versionId != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "version_id", r.versionId, "") + } + if r.status != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "") + } + if r.error_ != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "error", r.error_, "") + } + if r.pageSize != nil { + parameterAddToHeaderOrQuery(localVarQueryParams, "page_size", r.pageSize, "") + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"*/*"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["Bearer"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["Authorization"] = key + } + } + } + req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.callAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := &GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type ApiProjectsProjectIdJobsGetRequest struct { ctx context.Context ApiService *PredictionJobsAPIService @@ -677,11 +1022,13 @@ func (r ApiProjectsProjectIdJobsGetRequest) Execute() ([]PredictionJob, *http.Re } /* -ProjectsProjectIdJobsGet List all prediction jobs created using the model +ProjectsProjectIdJobsGet List all prediction jobs created using the model. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. + + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @return ApiProjectsProjectIdJobsGetRequest - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId - @return ApiProjectsProjectIdJobsGetRequest +Deprecated */ func (a *PredictionJobsAPIService) ProjectsProjectIdJobsGet(ctx context.Context, projectId int32) ApiProjectsProjectIdJobsGetRequest { return ApiProjectsProjectIdJobsGetRequest{ @@ -692,8 +1039,8 @@ func (a *PredictionJobsAPIService) ProjectsProjectIdJobsGet(ctx context.Context, } // Execute executes the request -// -// @return []PredictionJob +// @return []PredictionJob +// Deprecated func (a *PredictionJobsAPIService) ProjectsProjectIdJobsGetExecute(r ApiProjectsProjectIdJobsGetRequest) ([]PredictionJob, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet diff --git a/api/client/api_project.go b/api/client/api_project.go index 04f54b3da..d70dd900e 100644 --- a/api/client/api_project.go +++ b/api/client/api_project.go @@ -42,8 +42,8 @@ ProjectsGet List existing projects Projects can be filtered by optional `name` parameter - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiProjectsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiProjectsGetRequest */ func (a *ProjectAPIService) ProjectsGet(ctx context.Context) ApiProjectsGetRequest { return ApiProjectsGetRequest{ @@ -53,8 +53,7 @@ func (a *ProjectAPIService) ProjectsGet(ctx context.Context) ApiProjectsGetReque } // Execute executes the request -// -// @return []Project +// @return []Project func (a *ProjectAPIService) ProjectsGetExecute(r ApiProjectsGetRequest) ([]Project, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -164,8 +163,8 @@ func (r ApiProjectsPostRequest) Execute() (*Project, *http.Response, error) { /* ProjectsPost Create new project - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiProjectsPostRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiProjectsPostRequest */ func (a *ProjectAPIService) ProjectsPost(ctx context.Context) ApiProjectsPostRequest { return ApiProjectsPostRequest{ @@ -175,8 +174,7 @@ func (a *ProjectAPIService) ProjectsPost(ctx context.Context) ApiProjectsPostReq } // Execute executes the request -// -// @return Project +// @return Project func (a *ProjectAPIService) ProjectsPostExecute(r ApiProjectsPostRequest) (*Project, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost @@ -282,9 +280,9 @@ func (r ApiProjectsProjectIdGetRequest) Execute() (*Project, *http.Response, err /* ProjectsProjectIdGet Get project - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId project id of the project to be retrieved - @return ApiProjectsProjectIdGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId project id of the project to be retrieved + @return ApiProjectsProjectIdGetRequest */ func (a *ProjectAPIService) ProjectsProjectIdGet(ctx context.Context, projectId int32) ApiProjectsProjectIdGetRequest { return ApiProjectsProjectIdGetRequest{ @@ -295,8 +293,7 @@ func (a *ProjectAPIService) ProjectsProjectIdGet(ctx context.Context, projectId } // Execute executes the request -// -// @return Project +// @return Project func (a *ProjectAPIService) ProjectsProjectIdGetExecute(r ApiProjectsProjectIdGetRequest) (*Project, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -405,9 +402,9 @@ func (r ApiProjectsProjectIdPutRequest) Execute() (*Project, *http.Response, err /* ProjectsProjectIdPut Update project - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId project id of the project to be updated - @return ApiProjectsProjectIdPutRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId project id of the project to be updated + @return ApiProjectsProjectIdPutRequest */ func (a *ProjectAPIService) ProjectsProjectIdPut(ctx context.Context, projectId int32) ApiProjectsProjectIdPutRequest { return ApiProjectsProjectIdPutRequest{ @@ -418,8 +415,7 @@ func (a *ProjectAPIService) ProjectsProjectIdPut(ctx context.Context, projectId } // Execute executes the request -// -// @return Project +// @return Project func (a *ProjectAPIService) ProjectsProjectIdPutExecute(r ApiProjectsProjectIdPutRequest) (*Project, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPut diff --git a/api/client/api_secret.go b/api/client/api_secret.go index fb530f7ec..9c1cb44fa 100644 --- a/api/client/api_secret.go +++ b/api/client/api_secret.go @@ -35,9 +35,9 @@ func (r ApiProjectsProjectIdSecretsGetRequest) Execute() ([]Secret, *http.Respon /* ProjectsProjectIdSecretsGet List secret - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId - @return ApiProjectsProjectIdSecretsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @return ApiProjectsProjectIdSecretsGetRequest */ func (a *SecretAPIService) ProjectsProjectIdSecretsGet(ctx context.Context, projectId int32) ApiProjectsProjectIdSecretsGetRequest { return ApiProjectsProjectIdSecretsGetRequest{ @@ -48,8 +48,7 @@ func (a *SecretAPIService) ProjectsProjectIdSecretsGet(ctx context.Context, proj } // Execute executes the request -// -// @return []Secret +// @return []Secret func (a *SecretAPIService) ProjectsProjectIdSecretsGetExecute(r ApiProjectsProjectIdSecretsGetRequest) ([]Secret, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -157,9 +156,9 @@ func (r ApiProjectsProjectIdSecretsPostRequest) Execute() (*Secret, *http.Respon /* ProjectsProjectIdSecretsPost Create secret - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId - @return ApiProjectsProjectIdSecretsPostRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @return ApiProjectsProjectIdSecretsPostRequest */ func (a *SecretAPIService) ProjectsProjectIdSecretsPost(ctx context.Context, projectId int32) ApiProjectsProjectIdSecretsPostRequest { return ApiProjectsProjectIdSecretsPostRequest{ @@ -170,8 +169,7 @@ func (a *SecretAPIService) ProjectsProjectIdSecretsPost(ctx context.Context, pro } // Execute executes the request -// -// @return Secret +// @return Secret func (a *SecretAPIService) ProjectsProjectIdSecretsPostExecute(r ApiProjectsProjectIdSecretsPostRequest) (*Secret, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost @@ -276,10 +274,10 @@ func (r ApiProjectsProjectIdSecretsSecretIdDeleteRequest) Execute() (*http.Respo /* ProjectsProjectIdSecretsSecretIdDelete Delete secret - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId - @param secretId - @return ApiProjectsProjectIdSecretsSecretIdDeleteRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param secretId + @return ApiProjectsProjectIdSecretsSecretIdDeleteRequest */ func (a *SecretAPIService) ProjectsProjectIdSecretsSecretIdDelete(ctx context.Context, projectId int32, secretId int32) ApiProjectsProjectIdSecretsSecretIdDeleteRequest { return ApiProjectsProjectIdSecretsSecretIdDeleteRequest{ @@ -390,10 +388,10 @@ func (r ApiProjectsProjectIdSecretsSecretIdPatchRequest) Execute() (*Secret, *ht /* ProjectsProjectIdSecretsSecretIdPatch Update secret - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param projectId - @param secretId - @return ApiProjectsProjectIdSecretsSecretIdPatchRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param projectId + @param secretId + @return ApiProjectsProjectIdSecretsSecretIdPatchRequest */ func (a *SecretAPIService) ProjectsProjectIdSecretsSecretIdPatch(ctx context.Context, projectId int32, secretId int32) ApiProjectsProjectIdSecretsSecretIdPatchRequest { return ApiProjectsProjectIdSecretsSecretIdPatchRequest{ @@ -405,8 +403,7 @@ func (a *SecretAPIService) ProjectsProjectIdSecretsSecretIdPatch(ctx context.Con } // Execute executes the request -// -// @return Secret +// @return Secret func (a *SecretAPIService) ProjectsProjectIdSecretsSecretIdPatchExecute(r ApiProjectsProjectIdSecretsSecretIdPatchRequest) (*Secret, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPatch diff --git a/api/client/api_standard_transformer.go b/api/client/api_standard_transformer.go index 1e663fcc3..d22427904 100644 --- a/api/client/api_standard_transformer.go +++ b/api/client/api_standard_transformer.go @@ -39,8 +39,8 @@ func (r ApiStandardTransformerSimulatePostRequest) Execute() (*StandardTransform /* StandardTransformerSimulatePost Simulate standard transformer - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiStandardTransformerSimulatePostRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @return ApiStandardTransformerSimulatePostRequest */ func (a *StandardTransformerAPIService) StandardTransformerSimulatePost(ctx context.Context) ApiStandardTransformerSimulatePostRequest { return ApiStandardTransformerSimulatePostRequest{ @@ -50,8 +50,7 @@ func (a *StandardTransformerAPIService) StandardTransformerSimulatePost(ctx cont } // Execute executes the request -// -// @return StandardTransformerSimulationResponse +// @return StandardTransformerSimulationResponse func (a *StandardTransformerAPIService) StandardTransformerSimulatePostExecute(r ApiStandardTransformerSimulatePostRequest) (*StandardTransformerSimulationResponse, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost diff --git a/api/client/api_version.go b/api/client/api_version.go index a81c99ebd..8173907d6 100644 --- a/api/client/api_version.go +++ b/api/client/api_version.go @@ -54,9 +54,9 @@ func (r ApiModelsModelIdVersionsGetRequest) Execute() ([]Version, *http.Response /* ModelsModelIdVersionsGet List versions of the models - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @return ApiModelsModelIdVersionsGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @return ApiModelsModelIdVersionsGetRequest */ func (a *VersionAPIService) ModelsModelIdVersionsGet(ctx context.Context, modelId int32) ApiModelsModelIdVersionsGetRequest { return ApiModelsModelIdVersionsGetRequest{ @@ -67,8 +67,7 @@ func (a *VersionAPIService) ModelsModelIdVersionsGet(ctx context.Context, modelI } // Execute executes the request -// -// @return []Version +// @return []Version func (a *VersionAPIService) ModelsModelIdVersionsGetExecute(r ApiModelsModelIdVersionsGetRequest) ([]Version, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -185,9 +184,9 @@ func (r ApiModelsModelIdVersionsPostRequest) Execute() (*Version, *http.Response /* ModelsModelIdVersionsPost Log a new version of the models - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @return ApiModelsModelIdVersionsPostRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @return ApiModelsModelIdVersionsPostRequest */ func (a *VersionAPIService) ModelsModelIdVersionsPost(ctx context.Context, modelId int32) ApiModelsModelIdVersionsPostRequest { return ApiModelsModelIdVersionsPostRequest{ @@ -198,8 +197,7 @@ func (a *VersionAPIService) ModelsModelIdVersionsPost(ctx context.Context, model } // Execute executes the request -// -// @return Version +// @return Version func (a *VersionAPIService) ModelsModelIdVersionsPostExecute(r ApiModelsModelIdVersionsPostRequest) (*Version, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost @@ -304,10 +302,10 @@ func (r ApiModelsModelIdVersionsVersionIdDeleteRequest) Execute() (int32, *http. /* ModelsModelIdVersionsVersionIdDelete Delete version by ID from model - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @return ApiModelsModelIdVersionsVersionIdDeleteRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdDeleteRequest */ func (a *VersionAPIService) ModelsModelIdVersionsVersionIdDelete(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdDeleteRequest { return ApiModelsModelIdVersionsVersionIdDeleteRequest{ @@ -319,8 +317,7 @@ func (a *VersionAPIService) ModelsModelIdVersionsVersionIdDelete(ctx context.Con } // Execute executes the request -// -// @return int32 +// @return int32 func (a *VersionAPIService) ModelsModelIdVersionsVersionIdDeleteExecute(r ApiModelsModelIdVersionsVersionIdDeleteRequest) (int32, *http.Response, error) { var ( localVarHTTPMethod = http.MethodDelete @@ -424,10 +421,10 @@ func (r ApiModelsModelIdVersionsVersionIdGetRequest) Execute() (*Version, *http. /* ModelsModelIdVersionsVersionIdGet Get version by ID from model - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @return ApiModelsModelIdVersionsVersionIdGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdGetRequest */ func (a *VersionAPIService) ModelsModelIdVersionsVersionIdGet(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdGetRequest { return ApiModelsModelIdVersionsVersionIdGetRequest{ @@ -439,8 +436,7 @@ func (a *VersionAPIService) ModelsModelIdVersionsVersionIdGet(ctx context.Contex } // Execute executes the request -// -// @return Version +// @return Version func (a *VersionAPIService) ModelsModelIdVersionsVersionIdGetExecute(r ApiModelsModelIdVersionsVersionIdGetRequest) (*Version, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -550,10 +546,10 @@ func (r ApiModelsModelIdVersionsVersionIdPatchRequest) Execute() (*http.Response /* ModelsModelIdVersionsVersionIdPatch Patch the version - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @return ApiModelsModelIdVersionsVersionIdPatchRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdPatchRequest */ func (a *VersionAPIService) ModelsModelIdVersionsVersionIdPatch(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdPatchRequest { return ApiModelsModelIdVersionsVersionIdPatchRequest{ diff --git a/api/client/api_version_image.go b/api/client/api_version_image.go index 6c3bee365..27a99150e 100644 --- a/api/client/api_version_image.go +++ b/api/client/api_version_image.go @@ -36,10 +36,10 @@ func (r ApiModelsModelIdVersionsVersionIdImageGetRequest) Execute() (*VersionIma /* ModelsModelIdVersionsVersionIdImageGet Get the Docker image for given model version - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @return ApiModelsModelIdVersionsVersionIdImageGetRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdImageGetRequest */ func (a *VersionImageAPIService) ModelsModelIdVersionsVersionIdImageGet(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdImageGetRequest { return ApiModelsModelIdVersionsVersionIdImageGetRequest{ @@ -51,8 +51,7 @@ func (a *VersionImageAPIService) ModelsModelIdVersionsVersionIdImageGet(ctx cont } // Execute executes the request -// -// @return VersionImage +// @return VersionImage func (a *VersionImageAPIService) ModelsModelIdVersionsVersionIdImageGetExecute(r ApiModelsModelIdVersionsVersionIdImageGetRequest) (*VersionImage, *http.Response, error) { var ( localVarHTTPMethod = http.MethodGet @@ -162,10 +161,10 @@ func (r ApiModelsModelIdVersionsVersionIdImagePutRequest) Execute() (*http.Respo /* ModelsModelIdVersionsVersionIdImagePut Build the Docker image for given model version - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param modelId - @param versionId - @return ApiModelsModelIdVersionsVersionIdImagePutRequest + @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + @param modelId + @param versionId + @return ApiModelsModelIdVersionsVersionIdImagePutRequest */ func (a *VersionImageAPIService) ModelsModelIdVersionsVersionIdImagePut(ctx context.Context, modelId int32, versionId int32) ApiModelsModelIdVersionsVersionIdImagePutRequest { return ApiModelsModelIdVersionsVersionIdImagePutRequest{ diff --git a/api/client/model_list_jobs_paginated_response.go b/api/client/model_list_jobs_paginated_response.go new file mode 100644 index 000000000..9902296e7 --- /dev/null +++ b/api/client/model_list_jobs_paginated_response.go @@ -0,0 +1,181 @@ +/* +Merlin + +API Guide for accessing Merlin's model management, deployment, and serving functionalities + +API version: 0.14.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "encoding/json" + "fmt" +) + +// checks if the ListJobsPaginatedResponse type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &ListJobsPaginatedResponse{} + +// ListJobsPaginatedResponse struct for ListJobsPaginatedResponse +type ListJobsPaginatedResponse struct { + Results []PredictionJob `json:"results"` + Paging Paging `json:"paging"` +} + +type _ListJobsPaginatedResponse ListJobsPaginatedResponse + +// NewListJobsPaginatedResponse instantiates a new ListJobsPaginatedResponse object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewListJobsPaginatedResponse(results []PredictionJob, paging Paging) *ListJobsPaginatedResponse { + this := ListJobsPaginatedResponse{} + this.Results = results + this.Paging = paging + return &this +} + +// NewListJobsPaginatedResponseWithDefaults instantiates a new ListJobsPaginatedResponse object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewListJobsPaginatedResponseWithDefaults() *ListJobsPaginatedResponse { + this := ListJobsPaginatedResponse{} + return &this +} + +// GetResults returns the Results field value +func (o *ListJobsPaginatedResponse) GetResults() []PredictionJob { + if o == nil { + var ret []PredictionJob + return ret + } + + return o.Results +} + +// GetResultsOk returns a tuple with the Results field value +// and a boolean to check if the value has been set. +func (o *ListJobsPaginatedResponse) GetResultsOk() ([]PredictionJob, bool) { + if o == nil { + return nil, false + } + return o.Results, true +} + +// SetResults sets field value +func (o *ListJobsPaginatedResponse) SetResults(v []PredictionJob) { + o.Results = v +} + +// GetPaging returns the Paging field value +func (o *ListJobsPaginatedResponse) GetPaging() Paging { + if o == nil { + var ret Paging + return ret + } + + return o.Paging +} + +// GetPagingOk returns a tuple with the Paging field value +// and a boolean to check if the value has been set. +func (o *ListJobsPaginatedResponse) GetPagingOk() (*Paging, bool) { + if o == nil { + return nil, false + } + return &o.Paging, true +} + +// SetPaging sets field value +func (o *ListJobsPaginatedResponse) SetPaging(v Paging) { + o.Paging = v +} + +func (o ListJobsPaginatedResponse) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o ListJobsPaginatedResponse) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["results"] = o.Results + toSerialize["paging"] = o.Paging + return toSerialize, nil +} + +func (o *ListJobsPaginatedResponse) UnmarshalJSON(bytes []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "results", + "paging", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(bytes, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varListJobsPaginatedResponse := _ListJobsPaginatedResponse{} + + err = json.Unmarshal(bytes, &varListJobsPaginatedResponse) + + if err != nil { + return err + } + + *o = ListJobsPaginatedResponse(varListJobsPaginatedResponse) + + return err +} + +type NullableListJobsPaginatedResponse struct { + value *ListJobsPaginatedResponse + isSet bool +} + +func (v NullableListJobsPaginatedResponse) Get() *ListJobsPaginatedResponse { + return v.value +} + +func (v *NullableListJobsPaginatedResponse) Set(val *ListJobsPaginatedResponse) { + v.value = val + v.isSet = true +} + +func (v NullableListJobsPaginatedResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableListJobsPaginatedResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableListJobsPaginatedResponse(val *ListJobsPaginatedResponse) *NullableListJobsPaginatedResponse { + return &NullableListJobsPaginatedResponse{value: val, isSet: true} +} + +func (v NullableListJobsPaginatedResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableListJobsPaginatedResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/client/model_paging.go b/api/client/model_paging.go new file mode 100644 index 000000000..b00285b2c --- /dev/null +++ b/api/client/model_paging.go @@ -0,0 +1,212 @@ +/* +Merlin + +API Guide for accessing Merlin's model management, deployment, and serving functionalities + +API version: 0.14.0 +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package client + +import ( + "encoding/json" + "fmt" +) + +// checks if the Paging type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &Paging{} + +// Paging struct for Paging +type Paging struct { + // Total number of results matching the query criteria + Total int32 `json:"total"` + // Number of the current page + Page int32 `json:"page"` + // Total number of pages + Pages int32 `json:"pages"` +} + +type _Paging Paging + +// NewPaging instantiates a new Paging object +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed +func NewPaging(total int32, page int32, pages int32) *Paging { + this := Paging{} + this.Total = total + this.Page = page + this.Pages = pages + return &this +} + +// NewPagingWithDefaults instantiates a new Paging object +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set +func NewPagingWithDefaults() *Paging { + this := Paging{} + return &this +} + +// GetTotal returns the Total field value +func (o *Paging) GetTotal() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Total +} + +// GetTotalOk returns a tuple with the Total field value +// and a boolean to check if the value has been set. +func (o *Paging) GetTotalOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Total, true +} + +// SetTotal sets field value +func (o *Paging) SetTotal(v int32) { + o.Total = v +} + +// GetPage returns the Page field value +func (o *Paging) GetPage() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Page +} + +// GetPageOk returns a tuple with the Page field value +// and a boolean to check if the value has been set. +func (o *Paging) GetPageOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Page, true +} + +// SetPage sets field value +func (o *Paging) SetPage(v int32) { + o.Page = v +} + +// GetPages returns the Pages field value +func (o *Paging) GetPages() int32 { + if o == nil { + var ret int32 + return ret + } + + return o.Pages +} + +// GetPagesOk returns a tuple with the Pages field value +// and a boolean to check if the value has been set. +func (o *Paging) GetPagesOk() (*int32, bool) { + if o == nil { + return nil, false + } + return &o.Pages, true +} + +// SetPages sets field value +func (o *Paging) SetPages(v int32) { + o.Pages = v +} + +func (o Paging) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o Paging) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + toSerialize["total"] = o.Total + toSerialize["page"] = o.Page + toSerialize["pages"] = o.Pages + return toSerialize, nil +} + +func (o *Paging) UnmarshalJSON(bytes []byte) (err error) { + // This validates that all required properties are included in the JSON object + // by unmarshalling the object into a generic map with string keys and checking + // that every required field exists as a key in the generic map. + requiredProperties := []string{ + "total", + "page", + "pages", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(bytes, &allProperties) + + if err != nil { + return err + } + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varPaging := _Paging{} + + err = json.Unmarshal(bytes, &varPaging) + + if err != nil { + return err + } + + *o = Paging(varPaging) + + return err +} + +type NullablePaging struct { + value *Paging + isSet bool +} + +func (v NullablePaging) Get() *Paging { + return v.value +} + +func (v *NullablePaging) Set(val *Paging) { + v.value = val + v.isSet = true +} + +func (v NullablePaging) IsSet() bool { + return v.isSet +} + +func (v *NullablePaging) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullablePaging(val *Paging) *NullablePaging { + return &NullablePaging{value: val, isSet: true} +} + +func (v NullablePaging) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullablePaging) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/go.mod b/api/go.mod index aeaad4226..1cdfd70b2 100644 --- a/api/go.mod +++ b/api/go.mod @@ -12,7 +12,7 @@ require ( github.com/bboughton/gcp-helpers v0.1.0 github.com/buger/jsonparser v1.1.1 github.com/caraml-dev/merlin-pyspark-app v0.0.3 - github.com/caraml-dev/mlp v1.12.0 + github.com/caraml-dev/mlp v1.12.2-0.20240517121307-b89dab536aab github.com/caraml-dev/protopath v0.1.0 github.com/caraml-dev/universal-prediction-interface v1.0.0 github.com/cenkalti/backoff/v4 v4.2.1 diff --git a/api/go.sum b/api/go.sum index 0a9207274..87e05793a 100644 --- a/api/go.sum +++ b/api/go.sum @@ -159,8 +159,8 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dR github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/caraml-dev/mlp v1.12.0 h1:yb/EgMh+83oKj0C1AhH3R6xt0eSd9GX+incZEOwM7oo= -github.com/caraml-dev/mlp v1.12.0/go.mod h1:Zdz4bALO9WOHXhOgsoLmCjMCJnDVEZEnQFg8rk+u2cE= +github.com/caraml-dev/mlp v1.12.2-0.20240517121307-b89dab536aab h1:+XKM4kEBZz1gEbOHrphso6HxmMGSfss9TyMBIE0hm2M= +github.com/caraml-dev/mlp v1.12.2-0.20240517121307-b89dab536aab/go.mod h1:Zdz4bALO9WOHXhOgsoLmCjMCJnDVEZEnQFg8rk+u2cE= github.com/caraml-dev/protopath v0.1.0 h1:hjJ/U9RGD6QZ0Ee9SIYbVmwPugps4S5EpL6R+5ZrBe0= github.com/caraml-dev/protopath v0.1.0/go.mod h1:hVA2HkTrMYv+Q57gtrzu9/P7EXlNtBUcTz43z6EE010= github.com/caraml-dev/universal-prediction-interface v1.0.0 h1:3Z6adv1XZnBVRzFIeCu3mPcPnJrdB5IByYfdD9K/atI= diff --git a/api/service/mocks/prediction_job_service.go b/api/service/mocks/prediction_job_service.go index 9a8a8ace7..9d26d81a4 100644 --- a/api/service/mocks/prediction_job_service.go +++ b/api/service/mocks/prediction_job_service.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -10,6 +10,8 @@ import ( models "github.com/caraml-dev/merlin/models" + pagination "github.com/caraml-dev/mlp/api/pkg/pagination" + service "github.com/caraml-dev/merlin/service" ) @@ -22,6 +24,10 @@ type PredictionJobService struct { func (_m *PredictionJobService) CreatePredictionJob(ctx context.Context, env *models.Environment, model *models.Model, version *models.Version, predictionJob *models.PredictionJob) (*models.PredictionJob, error) { ret := _m.Called(ctx, env, model, version, predictionJob) + if len(ret) == 0 { + panic("no return value specified for CreatePredictionJob") + } + var r0 *models.PredictionJob var r1 error if rf, ok := ret.Get(0).(func(context.Context, *models.Environment, *models.Model, *models.Version, *models.PredictionJob) (*models.PredictionJob, error)); ok { @@ -48,6 +54,10 @@ func (_m *PredictionJobService) CreatePredictionJob(ctx context.Context, env *mo func (_m *PredictionJobService) GetPredictionJob(ctx context.Context, env *models.Environment, model *models.Model, version *models.Version, id models.ID) (*models.PredictionJob, error) { ret := _m.Called(ctx, env, model, version, id) + if len(ret) == 0 { + panic("no return value specified for GetPredictionJob") + } + var r0 *models.PredictionJob var r1 error if rf, ok := ret.Get(0).(func(context.Context, *models.Environment, *models.Model, *models.Version, models.ID) (*models.PredictionJob, error)); ok { @@ -74,6 +84,10 @@ func (_m *PredictionJobService) GetPredictionJob(ctx context.Context, env *model func (_m *PredictionJobService) ListContainers(ctx context.Context, env *models.Environment, model *models.Model, version *models.Version, predictionJob *models.PredictionJob) ([]*models.Container, error) { ret := _m.Called(ctx, env, model, version, predictionJob) + if len(ret) == 0 { + panic("no return value specified for ListContainers") + } + var r0 []*models.Container var r1 error if rf, ok := ret.Get(0).(func(context.Context, *models.Environment, *models.Model, *models.Version, *models.PredictionJob) ([]*models.Container, error)); ok { @@ -96,36 +110,53 @@ func (_m *PredictionJobService) ListContainers(ctx context.Context, env *models. return r0, r1 } -// ListPredictionJobs provides a mock function with given fields: ctx, project, query -func (_m *PredictionJobService) ListPredictionJobs(ctx context.Context, project mlp.Project, query *service.ListPredictionJobQuery) ([]*models.PredictionJob, error) { - ret := _m.Called(ctx, project, query) +// ListPredictionJobs provides a mock function with given fields: ctx, project, query, paginated +func (_m *PredictionJobService) ListPredictionJobs(ctx context.Context, project mlp.Project, query *service.ListPredictionJobQuery, paginated bool) ([]*models.PredictionJob, *pagination.Paging, error) { + ret := _m.Called(ctx, project, query, paginated) + + if len(ret) == 0 { + panic("no return value specified for ListPredictionJobs") + } var r0 []*models.PredictionJob - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, mlp.Project, *service.ListPredictionJobQuery) ([]*models.PredictionJob, error)); ok { - return rf(ctx, project, query) + var r1 *pagination.Paging + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, mlp.Project, *service.ListPredictionJobQuery, bool) ([]*models.PredictionJob, *pagination.Paging, error)); ok { + return rf(ctx, project, query, paginated) } - if rf, ok := ret.Get(0).(func(context.Context, mlp.Project, *service.ListPredictionJobQuery) []*models.PredictionJob); ok { - r0 = rf(ctx, project, query) + if rf, ok := ret.Get(0).(func(context.Context, mlp.Project, *service.ListPredictionJobQuery, bool) []*models.PredictionJob); ok { + r0 = rf(ctx, project, query, paginated) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]*models.PredictionJob) } } - if rf, ok := ret.Get(1).(func(context.Context, mlp.Project, *service.ListPredictionJobQuery) error); ok { - r1 = rf(ctx, project, query) + if rf, ok := ret.Get(1).(func(context.Context, mlp.Project, *service.ListPredictionJobQuery, bool) *pagination.Paging); ok { + r1 = rf(ctx, project, query, paginated) } else { - r1 = ret.Error(1) + if ret.Get(1) != nil { + r1 = ret.Get(1).(*pagination.Paging) + } } - return r0, r1 + if rf, ok := ret.Get(2).(func(context.Context, mlp.Project, *service.ListPredictionJobQuery, bool) error); ok { + r2 = rf(ctx, project, query, paginated) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 } // StopPredictionJob provides a mock function with given fields: ctx, env, model, version, id func (_m *PredictionJobService) StopPredictionJob(ctx context.Context, env *models.Environment, model *models.Model, version *models.Version, id models.ID) (*models.PredictionJob, error) { ret := _m.Called(ctx, env, model, version, id) + if len(ret) == 0 { + panic("no return value specified for StopPredictionJob") + } + var r0 *models.PredictionJob var r1 error if rf, ok := ret.Get(0).(func(context.Context, *models.Environment, *models.Model, *models.Version, models.ID) (*models.PredictionJob, error)); ok { @@ -148,13 +179,12 @@ func (_m *PredictionJobService) StopPredictionJob(ctx context.Context, env *mode return r0, r1 } -type mockConstructorTestingTNewPredictionJobService interface { +// NewPredictionJobService creates a new instance of PredictionJobService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewPredictionJobService(t interface { mock.TestingT Cleanup(func()) -} - -// NewPredictionJobService creates a new instance of PredictionJobService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewPredictionJobService(t mockConstructorTestingTNewPredictionJobService) *PredictionJobService { +}) *PredictionJobService { mock := &PredictionJobService{} mock.Mock.Test(t) diff --git a/api/service/prediction_job_service.go b/api/service/prediction_job_service.go index 35ac3b5d1..680fc0580 100644 --- a/api/service/prediction_job_service.go +++ b/api/service/prediction_job_service.go @@ -23,6 +23,8 @@ import ( "k8s.io/apimachinery/pkg/api/resource" clock2 "k8s.io/utils/clock" + "github.com/caraml-dev/mlp/api/pkg/pagination" + "github.com/caraml-dev/merlin/batch" "github.com/caraml-dev/merlin/log" "github.com/caraml-dev/merlin/mlp" @@ -33,11 +35,18 @@ import ( "github.com/caraml-dev/merlin/storage" ) +// Pagination config +var ( + MaxPageSize int32 = 50 + DefaultPageSize int32 = 10 + DefaultPage int32 = 1 +) + type PredictionJobService interface { // GetPredictionJob return prediction job with given ID GetPredictionJob(ctx context.Context, env *models.Environment, model *models.Model, version *models.Version, id models.ID) (*models.PredictionJob, error) // ListPredictionJobs return all prediction job created in a project - ListPredictionJobs(ctx context.Context, project mlp.Project, query *ListPredictionJobQuery) ([]*models.PredictionJob, error) + ListPredictionJobs(ctx context.Context, project mlp.Project, query *ListPredictionJobQuery, paginated bool) ([]*models.PredictionJob, *pagination.Paging, error) // CreatePredictionJob creates and start a new prediction job from the given model version CreatePredictionJob(ctx context.Context, env *models.Environment, model *models.Model, version *models.Version, predictionJob *models.PredictionJob) (*models.PredictionJob, error) // ListContainers return all containers which used for the given model version @@ -50,10 +59,13 @@ type PredictionJobService interface { type ListPredictionJobQuery struct { ID models.ID `schema:"id"` Name string `schema:"name"` + Search string `schema:"search"` ModelID models.ID `schema:"model_id"` VersionID models.ID `schema:"version_id"` Status models.State `schema:"status"` Error string `schema:"error"` + Page *int32 `schema:"page"` + PageSize *int32 `schema:"page_size"` } type predictionJobService struct { @@ -63,10 +75,19 @@ type predictionJobService struct { clock clock2.Clock environmentLabel string producer queue.Producer + paginator pagination.Paginator } func NewPredictionJobService(batchControllers map[string]batch.Controller, imageBuilder imagebuilder.ImageBuilder, store storage.PredictionJobStorage, clock clock2.Clock, environmentLabel string, producer queue.Producer) PredictionJobService { - svc := predictionJobService{store: store, imageBuilder: imageBuilder, batchControllers: batchControllers, clock: clock, environmentLabel: environmentLabel, producer: producer} + svc := predictionJobService{ + store: store, + imageBuilder: imageBuilder, + batchControllers: batchControllers, + clock: clock, + environmentLabel: environmentLabel, + producer: producer, + paginator: pagination.NewPaginator(DefaultPage, DefaultPageSize, MaxPageSize), + } return &svc } @@ -76,7 +97,7 @@ func (p *predictionJobService) GetPredictionJob(ctx context.Context, _ *models.E } // ListPredictionJobs return all prediction job created from the given project filtered by the given query -func (p *predictionJobService) ListPredictionJobs(ctx context.Context, project mlp.Project, query *ListPredictionJobQuery) ([]*models.PredictionJob, error) { +func (p *predictionJobService) ListPredictionJobs(ctx context.Context, project mlp.Project, query *ListPredictionJobQuery, paginated bool) ([]*models.PredictionJob, *pagination.Paging, error) { predJobQuery := &models.PredictionJob{ ID: query.ID, Name: query.Name, @@ -87,7 +108,32 @@ func (p *predictionJobService) ListPredictionJobs(ctx context.Context, project m Error: query.Error, } - return p.store.List(predJobQuery) + if paginated { + err := p.paginator.ValidatePaginationParams(query.Page, query.PageSize) + if err != nil { + return nil, nil, err + } + pageOpts := p.paginator.NewPaginationOptions(query.Page, query.PageSize) + // Count total + count := p.store.Count(predJobQuery, query.Search) + // Format opts into paging response + pagingResponse := pagination.ToPaging(pageOpts, int(count)) + if pagingResponse.Page > 1 && pagingResponse.Pages < pagingResponse.Page { + // Invalid query - total pages is less than the requested page + return nil, nil, fmt.Errorf("requested page number %d exceeds total pages: %d", pagingResponse.Page, pagingResponse.Pages) + } + // Get results for current page + offset := int((*pageOpts.Page - 1) * *pageOpts.PageSize) + limit := int(*pageOpts.PageSize) + results, err := p.store.List(predJobQuery, query.Search, &offset, &limit) + if err != nil { + return nil, nil, err + } + return results, pagingResponse, nil + } + + results, err := p.store.List(predJobQuery, query.Search, nil, nil) + return results, nil, err } // CreatePredictionJob creates and start a new prediction job from the given model version diff --git a/api/service/prediction_job_service_test.go b/api/service/prediction_job_service_test.go index c5a570f25..a6c62a182 100644 --- a/api/service/prediction_job_service_test.go +++ b/api/service/prediction_job_service_test.go @@ -134,31 +134,107 @@ func TestGetPredictionJob(t *testing.T) { } func TestListPredictionJob(t *testing.T) { - jobs := []*models.PredictionJob{job} - svc, _, _, mockStorage, _ := newMockPredictionJobService() - query := &ListPredictionJobQuery{ - ID: 1, - Name: "test", - ModelID: 2, - VersionID: 3, - Status: models.JobFailed, - Error: "runtime error", + var intNil *int + var int32Two, int32Three int32 = 2, 3 + tests := map[string]struct { + query ListPredictionJobQuery + isPaginated bool + total int + offset int + limit int + expected []*models.PredictionJob + }{ + "basic": { + query: ListPredictionJobQuery{ + ID: 1, + Name: "test", + ModelID: 2, + VersionID: 3, + Status: models.JobFailed, + Error: "runtime error", + }, + total: 1, + expected: []*models.PredictionJob{job}, + }, + "search": { + query: ListPredictionJobQuery{ + Search: model.Name, + }, + total: 1, + expected: []*models.PredictionJob{job}, + }, + "pagination": { + query: ListPredictionJobQuery{ + ID: 1, + Name: "test", + ModelID: 2, + VersionID: 3, + Status: models.JobFailed, + Error: "runtime error", + Page: &int32Three, + PageSize: &int32Two, + }, + isPaginated: true, + total: 10, + offset: 4, + limit: 2, + expected: []*models.PredictionJob{ + job, + { + ID: 1, + Name: fmt.Sprintf("%s-test", model.Name), + }, + }, + }, + "pagination defaults": { + query: ListPredictionJobQuery{ + ID: 1, + Name: "test", + ModelID: 2, + VersionID: 3, + Status: models.JobFailed, + Error: "runtime error", + }, + isPaginated: true, + total: 10, + offset: 0, + limit: int(DefaultPageSize), + expected: []*models.PredictionJob{ + job, + { + ID: 1, + Name: fmt.Sprintf("%s-test", model.Name), + }, + }, + }, } - expDbQuery := &models.PredictionJob{ - ID: query.ID, - Name: query.Name, - VersionID: query.VersionID, - VersionModelID: query.ModelID, - ProjectID: models.ID(project.ID), - Status: query.Status, - Error: query.Error, + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + svc, _, _, mockStorage, _ := newMockPredictionJobService() + expDbQuery := &models.PredictionJob{ + ID: tt.query.ID, + Name: tt.query.Name, + VersionID: tt.query.VersionID, + VersionModelID: tt.query.ModelID, + ProjectID: models.ID(project.ID), + Status: tt.query.Status, + Error: tt.query.Error, + } + + if tt.isPaginated { + mockStorage.On("List", expDbQuery, tt.query.Search, &tt.offset, &tt.limit).Return(tt.expected, nil) + mockStorage.On("Count", expDbQuery, tt.query.Search).Return(int(tt.total)) + } else { + mockStorage.On("List", expDbQuery, tt.query.Search, intNil, intNil).Return(tt.expected, nil) + } + + j, _, err := svc.ListPredictionJobs(context.Background(), project, &tt.query, tt.isPaginated) + assert.NoError(t, err) + assert.Equal(t, tt.expected, j) + mockStorage.AssertExpectations(t) + }) } - mockStorage.On("List", expDbQuery).Return(jobs, nil) - j, err := svc.ListPredictionJobs(context.Background(), project, query) - assert.NoError(t, err) - assert.Equal(t, jobs, j) - mockStorage.AssertExpectations(t) } func TestCreatePredictionJob(t *testing.T) { diff --git a/api/storage/mocks/prediction_job_storage.go b/api/storage/mocks/prediction_job_storage.go index 642b3366b..d9cc6b5f0 100644 --- a/api/storage/mocks/prediction_job_storage.go +++ b/api/storage/mocks/prediction_job_storage.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.43.0. DO NOT EDIT. package mocks @@ -12,10 +12,32 @@ type PredictionJobStorage struct { mock.Mock } +// Count provides a mock function with given fields: query, search +func (_m *PredictionJobStorage) Count(query *models.PredictionJob, search string) int { + ret := _m.Called(query, search) + + if len(ret) == 0 { + panic("no return value specified for Count") + } + + var r0 int + if rf, ok := ret.Get(0).(func(*models.PredictionJob, string) int); ok { + r0 = rf(query, search) + } else { + r0 = ret.Get(0).(int) + } + + return r0 +} + // Delete provides a mock function with given fields: _a0 func (_m *PredictionJobStorage) Delete(_a0 *models.PredictionJob) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Delete") + } + var r0 error if rf, ok := ret.Get(0).(func(*models.PredictionJob) error); ok { r0 = rf(_a0) @@ -30,6 +52,10 @@ func (_m *PredictionJobStorage) Delete(_a0 *models.PredictionJob) error { func (_m *PredictionJobStorage) Get(ID models.ID) (*models.PredictionJob, error) { ret := _m.Called(ID) + if len(ret) == 0 { + panic("no return value specified for Get") + } + var r0 *models.PredictionJob var r1 error if rf, ok := ret.Get(0).(func(models.ID) (*models.PredictionJob, error)); ok { @@ -56,6 +82,10 @@ func (_m *PredictionJobStorage) Get(ID models.ID) (*models.PredictionJob, error) func (_m *PredictionJobStorage) GetFirstSuccessModelVersionPerModel() (map[models.ID]models.ID, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetFirstSuccessModelVersionPerModel") + } + var r0 map[models.ID]models.ID var r1 error if rf, ok := ret.Get(0).(func() (map[models.ID]models.ID, error)); ok { @@ -78,25 +108,29 @@ func (_m *PredictionJobStorage) GetFirstSuccessModelVersionPerModel() (map[model return r0, r1 } -// List provides a mock function with given fields: query -func (_m *PredictionJobStorage) List(query *models.PredictionJob) ([]*models.PredictionJob, error) { - ret := _m.Called(query) +// List provides a mock function with given fields: query, search, offset, limit +func (_m *PredictionJobStorage) List(query *models.PredictionJob, search string, offset *int, limit *int) ([]*models.PredictionJob, error) { + ret := _m.Called(query, search, offset, limit) + + if len(ret) == 0 { + panic("no return value specified for List") + } var r0 []*models.PredictionJob var r1 error - if rf, ok := ret.Get(0).(func(*models.PredictionJob) ([]*models.PredictionJob, error)); ok { - return rf(query) + if rf, ok := ret.Get(0).(func(*models.PredictionJob, string, *int, *int) ([]*models.PredictionJob, error)); ok { + return rf(query, search, offset, limit) } - if rf, ok := ret.Get(0).(func(*models.PredictionJob) []*models.PredictionJob); ok { - r0 = rf(query) + if rf, ok := ret.Get(0).(func(*models.PredictionJob, string, *int, *int) []*models.PredictionJob); ok { + r0 = rf(query, search, offset, limit) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]*models.PredictionJob) } } - if rf, ok := ret.Get(1).(func(*models.PredictionJob) error); ok { - r1 = rf(query) + if rf, ok := ret.Get(1).(func(*models.PredictionJob, string, *int, *int) error); ok { + r1 = rf(query, search, offset, limit) } else { r1 = ret.Error(1) } @@ -108,6 +142,10 @@ func (_m *PredictionJobStorage) List(query *models.PredictionJob) ([]*models.Pre func (_m *PredictionJobStorage) Save(predictionJob *models.PredictionJob) error { ret := _m.Called(predictionJob) + if len(ret) == 0 { + panic("no return value specified for Save") + } + var r0 error if rf, ok := ret.Get(0).(func(*models.PredictionJob) error); ok { r0 = rf(predictionJob) @@ -118,13 +156,12 @@ func (_m *PredictionJobStorage) Save(predictionJob *models.PredictionJob) error return r0 } -type mockConstructorTestingTNewPredictionJobStorage interface { +// NewPredictionJobStorage creates a new instance of PredictionJobStorage. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewPredictionJobStorage(t interface { mock.TestingT Cleanup(func()) -} - -// NewPredictionJobStorage creates a new instance of PredictionJobStorage. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewPredictionJobStorage(t mockConstructorTestingTNewPredictionJobStorage) *PredictionJobStorage { +}) *PredictionJobStorage { mock := &PredictionJobStorage{} mock.Mock.Test(t) diff --git a/api/storage/prediction_job_storage.go b/api/storage/prediction_job_storage.go index f8eca7ae9..6ec11ccb0 100644 --- a/api/storage/prediction_job_storage.go +++ b/api/storage/prediction_job_storage.go @@ -15,6 +15,8 @@ package storage import ( + "fmt" + "github.com/caraml-dev/merlin/models" "gorm.io/gorm" ) @@ -22,12 +24,13 @@ import ( type PredictionJobStorage interface { // Get get prediction job with given ID Get(ID models.ID) (*models.PredictionJob, error) - // List list all prediction job matching the given query - List(query *models.PredictionJob) (endpoints []*models.PredictionJob, err error) + // List lists all prediction job matching the given query + List(query *models.PredictionJob, search string, offset *int, limit *int) (endpoints []*models.PredictionJob, err error) + // Count returns the count of rows in the given query + Count(query *models.PredictionJob, search string) int // Save save the prediction job to underlying storage Save(predictionJob *models.PredictionJob) error // GetFirstSuccessModelVersionPerModel get first model version resulting in a successful batch prediction job - // GetFirstSuccessModelVersionPerModel get first model version resulting in a successful batch prediction job GetFirstSuccessModelVersionPerModel() (map[models.ID]models.ID, error) Delete(*models.PredictionJob) error } @@ -50,12 +53,41 @@ func (p *predictionJobStorage) Get(id models.ID) (*models.PredictionJob, error) } // List list all prediction job matching the given query -func (p *predictionJobStorage) List(query *models.PredictionJob) (predictionJobs []*models.PredictionJob, err error) { - err = p.query().Select("id, name, version_id, version_model_id, project_id, environment_name, status, error, created_at, updated_at"). - Where(query).Find(&predictionJobs).Error +func (p *predictionJobStorage) List(query *models.PredictionJob, search string, offset *int, limit *int) (predictionJobs []*models.PredictionJob, err error) { + q := p.query().Select("id, name, version_id, version_model_id, project_id, environment_name, status, error, created_at, updated_at"). + Where(query). + Order("updated_at desc") // preserve order in case offset or limit are being set + + // Do a partial match on the name + if search != "" { + q = q.Where(fmt.Sprintf("name ILIKE '%%%s%%'", search)) + } + + if offset != nil { + q = q.Offset(*offset) + } + if limit != nil { + q = q.Limit(*limit) + } + err = q.Find(&predictionJobs).Error return } +func (p *predictionJobStorage) Count(query *models.PredictionJob, search string) int { + var count int64 + var jobs []*models.PredictionJob + + q := p.query().Model(&jobs).Where(query) + + // Do a partial match on the name + if search != "" { + q = q.Where(fmt.Sprintf("name ILIKE '%%%s%%'", search)) + } + + _ = q.Count(&count) + return int(count) +} + // Save save the prediction job to underlying storage func (p *predictionJobStorage) Save(predictionJob *models.PredictionJob) error { return p.db.Save(predictionJob).Error diff --git a/api/storage/prediction_job_storage_test.go b/api/storage/prediction_job_storage_test.go index 8175dab64..c155f2452 100644 --- a/api/storage/prediction_job_storage_test.go +++ b/api/storage/prediction_job_storage_test.go @@ -145,7 +145,7 @@ func TestPredictionJobStorage_SaveAndGet(t *testing.T) { }) } -func TestPredictionJobStorage_List(t *testing.T) { +func TestPredictionJobStorage_List_And_Count(t *testing.T) { database.WithTestDatabase(t, func(t *testing.T, db *gorm.DB) { predJobStore := NewPredictionJobStorage(db) isDefaultPredictionJob := true @@ -179,9 +179,11 @@ func TestPredictionJobStorage_List(t *testing.T) { } db.Create(&v) + time1 := time.Now() + name1 := fmt.Sprintf("%s-%s-%s", m.Name, v.ID, time1) job1 := &models.PredictionJob{ ID: 1, - Name: fmt.Sprintf("%s-%s-%s", m.Name, v.ID, time.Now()), + Name: name1, Metadata: models.Metadata{ Team: "dsp", Stream: "dsp", @@ -241,9 +243,11 @@ func TestPredictionJobStorage_List(t *testing.T) { }, } + time2 := time1.Add(time.Second) + name2 := fmt.Sprintf("%s-%s-%s", m.Name, v.ID, time2) job2 := &models.PredictionJob{ ID: 2, - Name: fmt.Sprintf("%s-%s-%s", m.Name, v.ID, time.Now()), + Name: name2, Metadata: models.Metadata{ Team: "dsp", Stream: "dsp", @@ -311,20 +315,49 @@ func TestPredictionJobStorage_List(t *testing.T) { jobs, err := predJobStore.List(&models.PredictionJob{ ProjectID: models.ID(p.ID), - }) + }, "", nil, nil) assert.NoError(t, err) assert.Len(t, jobs, 2) jobs, err = predJobStore.List(&models.PredictionJob{ VersionModelID: m.ID, - }) + }, "", nil, nil) assert.NoError(t, err) assert.Len(t, jobs, 2) jobs, err = predJobStore.List(&models.PredictionJob{ VersionID: v.ID, - }) + }, "", nil, nil) assert.NoError(t, err) assert.Len(t, jobs, 2) + + // Test search + jobs, err = predJobStore.List(&models.PredictionJob{ + VersionModelID: m.ID, + }, fmt.Sprintf("%s", time1), nil, nil) + assert.NoError(t, err) + assert.Len(t, jobs, 1) + assert.Equal(t, jobs[0].Name, name1) + + // Test offset. Selects the less recently updated jobs. + intOne := 1 + jobs, err = predJobStore.List(&models.PredictionJob{ + VersionModelID: m.ID, + }, "", &intOne, nil) + assert.NoError(t, err) + assert.Len(t, jobs, 1) + assert.Equal(t, jobs[0].Name, name1) + + // Test limit. Selects the most recently updated job. + jobs, err = predJobStore.List(&models.PredictionJob{ + VersionModelID: m.ID, + }, "", nil, &intOne) + assert.NoError(t, err) + assert.Len(t, jobs, 1) + assert.Equal(t, jobs[0].Name, name2) + + // Test Count + count := predJobStore.Count(&models.PredictionJob{VersionModelID: m.ID}, fmt.Sprintf("%s", time1)) + assert.Equal(t, 1, count) }) } diff --git a/python/sdk/client/__init__.py b/python/sdk/client/__init__.py index 9c54dcc4e..2487f4b34 100644 --- a/python/sdk/client/__init__.py +++ b/python/sdk/client/__init__.py @@ -61,6 +61,7 @@ from client.models.image_building_job_state import ImageBuildingJobState from client.models.image_building_job_status import ImageBuildingJobStatus from client.models.label import Label +from client.models.list_jobs_paginated_response import ListJobsPaginatedResponse from client.models.logger import Logger from client.models.logger_config import LoggerConfig from client.models.logger_mode import LoggerMode @@ -77,6 +78,7 @@ from client.models.model_prediction_output_class import ModelPredictionOutputClass from client.models.model_schema import ModelSchema from client.models.operation_tracing import OperationTracing +from client.models.paging import Paging from client.models.pipeline_tracing import PipelineTracing from client.models.prediction_job import PredictionJob from client.models.prediction_job_config import PredictionJobConfig diff --git a/python/sdk/client/api/prediction_jobs_api.py b/python/sdk/client/api/prediction_jobs_api.py index a19bc0f38..5ab5296f7 100644 --- a/python/sdk/client/api/prediction_jobs_api.py +++ b/python/sdk/client/api/prediction_jobs_api.py @@ -23,11 +23,14 @@ except ImportError: from typing_extensions import Annotated +from pydantic import Field +from typing_extensions import Annotated from pydantic import StrictInt, StrictStr from typing import List, Optional from client.models.container import Container +from client.models.list_jobs_paginated_response import ListJobsPaginatedResponse from client.models.prediction_job import PredictionJob from client.api_client import ApiClient @@ -49,10 +52,13 @@ def __init__(self, api_client=None) -> None: @validate_call - def models_model_id_versions_version_id_jobs_get( + def models_model_id_versions_version_id_jobs_by_page_get( self, model_id: StrictInt, version_id: StrictInt, + page: Optional[StrictInt] = None, + page_size: Annotated[Optional[StrictInt], Field(description="Number of items on each page. It defaults to 10.")] = None, + search: Annotated[Optional[StrictStr], Field(description="Search job name for a partial match of the search text")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -65,14 +71,20 @@ def models_model_id_versions_version_id_jobs_get( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> List[PredictionJob]: - """List all prediction jobs of a model version + ) -> ListJobsPaginatedResponse: + """List all prediction jobs of a model version with pagination :param model_id: (required) :type model_id: int :param version_id: (required) :type version_id: int + :param page: + :type page: int + :param page_size: Number of items on each page. It defaults to 10. + :type page_size: int + :param search: Search job name for a partial match of the search text + :type search: str :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 @@ -95,9 +107,12 @@ def models_model_id_versions_version_id_jobs_get( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_get_serialize( + _param = self._models_model_id_versions_version_id_jobs_by_page_get_serialize( model_id=model_id, version_id=version_id, + page=page, + page_size=page_size, + search=search, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -105,7 +120,7 @@ def models_model_id_versions_version_id_jobs_get( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[PredictionJob]", + '200': "ListJobsPaginatedResponse", '404': None } @@ -121,10 +136,13 @@ def models_model_id_versions_version_id_jobs_get( @validate_call - def models_model_id_versions_version_id_jobs_get_with_http_info( + def models_model_id_versions_version_id_jobs_by_page_get_with_http_info( self, model_id: StrictInt, version_id: StrictInt, + page: Optional[StrictInt] = None, + page_size: Annotated[Optional[StrictInt], Field(description="Number of items on each page. It defaults to 10.")] = None, + search: Annotated[Optional[StrictStr], Field(description="Search job name for a partial match of the search text")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -137,14 +155,20 @@ def models_model_id_versions_version_id_jobs_get_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[List[PredictionJob]]: - """List all prediction jobs of a model version + ) -> ApiResponse[ListJobsPaginatedResponse]: + """List all prediction jobs of a model version with pagination :param model_id: (required) :type model_id: int :param version_id: (required) :type version_id: int + :param page: + :type page: int + :param page_size: Number of items on each page. It defaults to 10. + :type page_size: int + :param search: Search job name for a partial match of the search text + :type search: str :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 @@ -167,9 +191,12 @@ def models_model_id_versions_version_id_jobs_get_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_get_serialize( + _param = self._models_model_id_versions_version_id_jobs_by_page_get_serialize( model_id=model_id, version_id=version_id, + page=page, + page_size=page_size, + search=search, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -177,7 +204,7 @@ def models_model_id_versions_version_id_jobs_get_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[PredictionJob]", + '200': "ListJobsPaginatedResponse", '404': None } @@ -193,10 +220,13 @@ def models_model_id_versions_version_id_jobs_get_with_http_info( @validate_call - def models_model_id_versions_version_id_jobs_get_without_preload_content( + def models_model_id_versions_version_id_jobs_by_page_get_without_preload_content( self, model_id: StrictInt, version_id: StrictInt, + page: Optional[StrictInt] = None, + page_size: Annotated[Optional[StrictInt], Field(description="Number of items on each page. It defaults to 10.")] = None, + search: Annotated[Optional[StrictStr], Field(description="Search job name for a partial match of the search text")] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -210,13 +240,19 @@ def models_model_id_versions_version_id_jobs_get_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """List all prediction jobs of a model version + """List all prediction jobs of a model version with pagination :param model_id: (required) :type model_id: int :param version_id: (required) :type version_id: int + :param page: + :type page: int + :param page_size: Number of items on each page. It defaults to 10. + :type page_size: int + :param search: Search job name for a partial match of the search text + :type search: str :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 @@ -239,9 +275,12 @@ def models_model_id_versions_version_id_jobs_get_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_get_serialize( + _param = self._models_model_id_versions_version_id_jobs_by_page_get_serialize( model_id=model_id, version_id=version_id, + page=page, + page_size=page_size, + search=search, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -249,7 +288,7 @@ def models_model_id_versions_version_id_jobs_get_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "List[PredictionJob]", + '200': "ListJobsPaginatedResponse", '404': None } @@ -260,10 +299,13 @@ def models_model_id_versions_version_id_jobs_get_without_preload_content( return response_data.response - def _models_model_id_versions_version_id_jobs_get_serialize( + def _models_model_id_versions_version_id_jobs_by_page_get_serialize( self, model_id, version_id, + page, + page_size, + search, _request_auth, _content_type, _headers, @@ -289,6 +331,18 @@ def _models_model_id_versions_version_id_jobs_get_serialize( if version_id is not None: _path_params['version_id'] = version_id # process the query parameters + if page is not None: + + _query_params.append(('page', page)) + + if page_size is not None: + + _query_params.append(('page_size', page_size)) + + if search is not None: + + _query_params.append(('search', search)) + # process the header parameters # process the form parameters # process the body parameter @@ -309,7 +363,7 @@ def _models_model_id_versions_version_id_jobs_get_serialize( return self.api_client.param_serialize( method='GET', - resource_path='/models/{model_id}/versions/{version_id}/jobs', + resource_path='/models/{model_id}/versions/{version_id}/jobs-by-page', path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -326,11 +380,10 @@ def _models_model_id_versions_version_id_jobs_get_serialize( @validate_call - def models_model_id_versions_version_id_jobs_job_id_containers_get( + def models_model_id_versions_version_id_jobs_get( self, model_id: StrictInt, version_id: StrictInt, - job_id: StrictStr, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -343,16 +396,14 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> Container: - """Get all container belong to a prediction job + ) -> List[PredictionJob]: + """(Deprecated) List all prediction jobs of a model version. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. :param model_id: (required) :type model_id: int :param version_id: (required) :type version_id: int - :param job_id: (required) - :type job_id: str :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 @@ -374,11 +425,11 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 + warnings.warn("GET /models/{model_id}/versions/{version_id}/jobs is deprecated.", DeprecationWarning) - _param = self._models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( + _param = self._models_model_id_versions_version_id_jobs_get_serialize( model_id=model_id, version_id=version_id, - job_id=job_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -386,7 +437,7 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Container", + '200': "List[PredictionJob]", '404': None } @@ -402,11 +453,10 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get( @validate_call - def models_model_id_versions_version_id_jobs_job_id_containers_get_with_http_info( + def models_model_id_versions_version_id_jobs_get_with_http_info( self, model_id: StrictInt, version_id: StrictInt, - job_id: StrictStr, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -419,16 +469,14 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get_with_http_inf _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[Container]: - """Get all container belong to a prediction job + ) -> ApiResponse[List[PredictionJob]]: + """(Deprecated) List all prediction jobs of a model version. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. :param model_id: (required) :type model_id: int :param version_id: (required) :type version_id: int - :param job_id: (required) - :type job_id: str :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 @@ -450,11 +498,11 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get_with_http_inf :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 + warnings.warn("GET /models/{model_id}/versions/{version_id}/jobs is deprecated.", DeprecationWarning) - _param = self._models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( + _param = self._models_model_id_versions_version_id_jobs_get_serialize( model_id=model_id, version_id=version_id, - job_id=job_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -462,7 +510,7 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get_with_http_inf ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Container", + '200': "List[PredictionJob]", '404': None } @@ -478,11 +526,10 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get_with_http_inf @validate_call - def models_model_id_versions_version_id_jobs_job_id_containers_get_without_preload_content( + def models_model_id_versions_version_id_jobs_get_without_preload_content( self, model_id: StrictInt, version_id: StrictInt, - job_id: StrictStr, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -496,15 +543,13 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get_without_prelo _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get all container belong to a prediction job + """(Deprecated) List all prediction jobs of a model version. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. :param model_id: (required) :type model_id: int :param version_id: (required) :type version_id: int - :param job_id: (required) - :type job_id: str :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 @@ -526,11 +571,11 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get_without_prelo :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 + warnings.warn("GET /models/{model_id}/versions/{version_id}/jobs is deprecated.", DeprecationWarning) - _param = self._models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( + _param = self._models_model_id_versions_version_id_jobs_get_serialize( model_id=model_id, version_id=version_id, - job_id=job_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -538,7 +583,7 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get_without_prelo ) _response_types_map: Dict[str, Optional[str]] = { - '200': "Container", + '200': "List[PredictionJob]", '404': None } @@ -549,11 +594,10 @@ def models_model_id_versions_version_id_jobs_job_id_containers_get_without_prelo return response_data.response - def _models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( + def _models_model_id_versions_version_id_jobs_get_serialize( self, model_id, version_id, - job_id, _request_auth, _content_type, _headers, @@ -578,8 +622,6 @@ def _models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( _path_params['model_id'] = model_id if version_id is not None: _path_params['version_id'] = version_id - if job_id is not None: - _path_params['job_id'] = job_id # process the query parameters # process the header parameters # process the form parameters @@ -601,7 +643,7 @@ def _models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( return self.api_client.param_serialize( method='GET', - resource_path='/models/{model_id}/versions/{version_id}/jobs/{job_id}/containers', + resource_path='/models/{model_id}/versions/{version_id}/jobs', path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -618,11 +660,11 @@ def _models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( @validate_call - def models_model_id_versions_version_id_jobs_job_id_get( + def models_model_id_versions_version_id_jobs_job_id_containers_get( self, model_id: StrictInt, version_id: StrictInt, - job_id: StrictInt, + job_id: StrictStr, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -635,8 +677,8 @@ def models_model_id_versions_version_id_jobs_job_id_get( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> PredictionJob: - """Get prediction jobs with given id + ) -> Container: + """Get all container belong to a prediction job :param model_id: (required) @@ -644,7 +686,7 @@ def models_model_id_versions_version_id_jobs_job_id_get( :param version_id: (required) :type version_id: int :param job_id: (required) - :type job_id: int + :type job_id: str :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 @@ -667,7 +709,7 @@ def models_model_id_versions_version_id_jobs_job_id_get( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_job_id_get_serialize( + _param = self._models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( model_id=model_id, version_id=version_id, job_id=job_id, @@ -678,7 +720,7 @@ def models_model_id_versions_version_id_jobs_job_id_get( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "PredictionJob", + '200': "Container", '404': None } @@ -694,11 +736,11 @@ def models_model_id_versions_version_id_jobs_job_id_get( @validate_call - def models_model_id_versions_version_id_jobs_job_id_get_with_http_info( + def models_model_id_versions_version_id_jobs_job_id_containers_get_with_http_info( self, model_id: StrictInt, version_id: StrictInt, - job_id: StrictInt, + job_id: StrictStr, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -711,8 +753,8 @@ def models_model_id_versions_version_id_jobs_job_id_get_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[PredictionJob]: - """Get prediction jobs with given id + ) -> ApiResponse[Container]: + """Get all container belong to a prediction job :param model_id: (required) @@ -720,7 +762,7 @@ def models_model_id_versions_version_id_jobs_job_id_get_with_http_info( :param version_id: (required) :type version_id: int :param job_id: (required) - :type job_id: int + :type job_id: str :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 @@ -743,7 +785,7 @@ def models_model_id_versions_version_id_jobs_job_id_get_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_job_id_get_serialize( + _param = self._models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( model_id=model_id, version_id=version_id, job_id=job_id, @@ -754,7 +796,7 @@ def models_model_id_versions_version_id_jobs_job_id_get_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "PredictionJob", + '200': "Container", '404': None } @@ -770,11 +812,11 @@ def models_model_id_versions_version_id_jobs_job_id_get_with_http_info( @validate_call - def models_model_id_versions_version_id_jobs_job_id_get_without_preload_content( + def models_model_id_versions_version_id_jobs_job_id_containers_get_without_preload_content( self, model_id: StrictInt, version_id: StrictInt, - job_id: StrictInt, + job_id: StrictStr, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -788,7 +830,7 @@ def models_model_id_versions_version_id_jobs_job_id_get_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Get prediction jobs with given id + """Get all container belong to a prediction job :param model_id: (required) @@ -796,7 +838,7 @@ def models_model_id_versions_version_id_jobs_job_id_get_without_preload_content( :param version_id: (required) :type version_id: int :param job_id: (required) - :type job_id: int + :type job_id: str :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 @@ -819,7 +861,7 @@ def models_model_id_versions_version_id_jobs_job_id_get_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_job_id_get_serialize( + _param = self._models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( model_id=model_id, version_id=version_id, job_id=job_id, @@ -830,7 +872,7 @@ def models_model_id_versions_version_id_jobs_job_id_get_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "PredictionJob", + '200': "Container", '404': None } @@ -841,7 +883,7 @@ def models_model_id_versions_version_id_jobs_job_id_get_without_preload_content( return response_data.response - def _models_model_id_versions_version_id_jobs_job_id_get_serialize( + def _models_model_id_versions_version_id_jobs_job_id_containers_get_serialize( self, model_id, version_id, @@ -893,7 +935,7 @@ def _models_model_id_versions_version_id_jobs_job_id_get_serialize( return self.api_client.param_serialize( method='GET', - resource_path='/models/{model_id}/versions/{version_id}/jobs/{job_id}', + resource_path='/models/{model_id}/versions/{version_id}/jobs/{job_id}/containers', path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -910,7 +952,7 @@ def _models_model_id_versions_version_id_jobs_job_id_get_serialize( @validate_call - def models_model_id_versions_version_id_jobs_job_id_stop_put( + def models_model_id_versions_version_id_jobs_job_id_get( self, model_id: StrictInt, version_id: StrictInt, @@ -927,8 +969,8 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> None: - """Stop prediction jobs with given id + ) -> PredictionJob: + """Get prediction jobs with given id :param model_id: (required) @@ -959,7 +1001,7 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( + _param = self._models_model_id_versions_version_id_jobs_job_id_get_serialize( model_id=model_id, version_id=version_id, job_id=job_id, @@ -970,6 +1012,8 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put( ) _response_types_map: Dict[str, Optional[str]] = { + '200': "PredictionJob", + '404': None } response_data = self.api_client.call_api( @@ -984,7 +1028,7 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put( @validate_call - def models_model_id_versions_version_id_jobs_job_id_stop_put_with_http_info( + def models_model_id_versions_version_id_jobs_job_id_get_with_http_info( self, model_id: StrictInt, version_id: StrictInt, @@ -1001,8 +1045,8 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[None]: - """Stop prediction jobs with given id + ) -> ApiResponse[PredictionJob]: + """Get prediction jobs with given id :param model_id: (required) @@ -1033,7 +1077,7 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( + _param = self._models_model_id_versions_version_id_jobs_job_id_get_serialize( model_id=model_id, version_id=version_id, job_id=job_id, @@ -1044,6 +1088,8 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { + '200': "PredictionJob", + '404': None } response_data = self.api_client.call_api( @@ -1058,7 +1104,7 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put_with_http_info( @validate_call - def models_model_id_versions_version_id_jobs_job_id_stop_put_without_preload_content( + def models_model_id_versions_version_id_jobs_job_id_get_without_preload_content( self, model_id: StrictInt, version_id: StrictInt, @@ -1076,7 +1122,7 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put_without_preload_con _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Stop prediction jobs with given id + """Get prediction jobs with given id :param model_id: (required) @@ -1107,7 +1153,7 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put_without_preload_con :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( + _param = self._models_model_id_versions_version_id_jobs_job_id_get_serialize( model_id=model_id, version_id=version_id, job_id=job_id, @@ -1118,6 +1164,8 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put_without_preload_con ) _response_types_map: Dict[str, Optional[str]] = { + '200': "PredictionJob", + '404': None } response_data = self.api_client.call_api( @@ -1127,7 +1175,7 @@ def models_model_id_versions_version_id_jobs_job_id_stop_put_without_preload_con return response_data.response - def _models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( + def _models_model_id_versions_version_id_jobs_job_id_get_serialize( self, model_id, version_id, @@ -1164,6 +1212,12 @@ def _models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( # process the body parameter + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) # authentication setting @@ -1172,8 +1226,8 @@ def _models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( ] return self.api_client.param_serialize( - method='PUT', - resource_path='/models/{model_id}/versions/{version_id}/jobs/{job_id}/stop', + method='GET', + resource_path='/models/{model_id}/versions/{version_id}/jobs/{job_id}', path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1190,11 +1244,11 @@ def _models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( @validate_call - def models_model_id_versions_version_id_jobs_post( + def models_model_id_versions_version_id_jobs_job_id_stop_put( self, model_id: StrictInt, version_id: StrictInt, - body: Optional[PredictionJob] = None, + job_id: StrictInt, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1207,16 +1261,16 @@ def models_model_id_versions_version_id_jobs_post( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> PredictionJob: - """Create a prediction job from the given model version + ) -> None: + """Stop prediction jobs with given id :param model_id: (required) :type model_id: int :param version_id: (required) :type version_id: int - :param body: - :type body: PredictionJob + :param job_id: (required) + :type job_id: int :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 @@ -1239,10 +1293,10 @@ def models_model_id_versions_version_id_jobs_post( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_post_serialize( + _param = self._models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( model_id=model_id, version_id=version_id, - body=body, + job_id=job_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1250,8 +1304,6 @@ def models_model_id_versions_version_id_jobs_post( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "PredictionJob", - '404': None } response_data = self.api_client.call_api( @@ -1266,11 +1318,11 @@ def models_model_id_versions_version_id_jobs_post( @validate_call - def models_model_id_versions_version_id_jobs_post_with_http_info( + def models_model_id_versions_version_id_jobs_job_id_stop_put_with_http_info( self, model_id: StrictInt, version_id: StrictInt, - body: Optional[PredictionJob] = None, + job_id: StrictInt, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1283,16 +1335,16 @@ def models_model_id_versions_version_id_jobs_post_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[PredictionJob]: - """Create a prediction job from the given model version + ) -> ApiResponse[None]: + """Stop prediction jobs with given id :param model_id: (required) :type model_id: int :param version_id: (required) :type version_id: int - :param body: - :type body: PredictionJob + :param job_id: (required) + :type job_id: int :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 @@ -1315,10 +1367,10 @@ def models_model_id_versions_version_id_jobs_post_with_http_info( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_post_serialize( + _param = self._models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( model_id=model_id, version_id=version_id, - body=body, + job_id=job_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1326,8 +1378,6 @@ def models_model_id_versions_version_id_jobs_post_with_http_info( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "PredictionJob", - '404': None } response_data = self.api_client.call_api( @@ -1342,11 +1392,11 @@ def models_model_id_versions_version_id_jobs_post_with_http_info( @validate_call - def models_model_id_versions_version_id_jobs_post_without_preload_content( + def models_model_id_versions_version_id_jobs_job_id_stop_put_without_preload_content( self, model_id: StrictInt, version_id: StrictInt, - body: Optional[PredictionJob] = None, + job_id: StrictInt, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1360,15 +1410,15 @@ def models_model_id_versions_version_id_jobs_post_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """Create a prediction job from the given model version + """Stop prediction jobs with given id :param model_id: (required) :type model_id: int :param version_id: (required) :type version_id: int - :param body: - :type body: PredictionJob + :param job_id: (required) + :type job_id: int :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 @@ -1391,10 +1441,10 @@ def models_model_id_versions_version_id_jobs_post_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._models_model_id_versions_version_id_jobs_post_serialize( + _param = self._models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( model_id=model_id, version_id=version_id, - body=body, + job_id=job_id, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1402,8 +1452,6 @@ def models_model_id_versions_version_id_jobs_post_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "PredictionJob", - '404': None } response_data = self.api_client.call_api( @@ -1413,11 +1461,11 @@ def models_model_id_versions_version_id_jobs_post_without_preload_content( return response_data.response - def _models_model_id_versions_version_id_jobs_post_serialize( + def _models_model_id_versions_version_id_jobs_job_id_stop_put_serialize( self, model_id, version_id, - body, + job_id, _request_auth, _content_type, _headers, @@ -1442,20 +1490,14 @@ def _models_model_id_versions_version_id_jobs_post_serialize( _path_params['model_id'] = model_id if version_id is not None: _path_params['version_id'] = version_id + if job_id is not None: + _path_params['job_id'] = job_id # process the query parameters # process the header parameters # process the form parameters # process the body parameter - if body is not None: - _body_params = body - # set the HTTP header `Accept` - _header_params['Accept'] = self.api_client.select_header_accept( - [ - '*/*' - ] - ) # authentication setting @@ -1464,8 +1506,715 @@ def _models_model_id_versions_version_id_jobs_post_serialize( ] return self.api_client.param_serialize( - method='POST', - resource_path='/models/{model_id}/versions/{version_id}/jobs', + method='PUT', + resource_path='/models/{model_id}/versions/{version_id}/jobs/{job_id}/stop', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def models_model_id_versions_version_id_jobs_post( + self, + model_id: StrictInt, + version_id: StrictInt, + body: Optional[PredictionJob] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> PredictionJob: + """Create a prediction job from the given model version + + + :param model_id: (required) + :type model_id: int + :param version_id: (required) + :type version_id: int + :param body: + :type body: PredictionJob + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._models_model_id_versions_version_id_jobs_post_serialize( + model_id=model_id, + version_id=version_id, + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PredictionJob", + '404': None + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def models_model_id_versions_version_id_jobs_post_with_http_info( + self, + model_id: StrictInt, + version_id: StrictInt, + body: Optional[PredictionJob] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[PredictionJob]: + """Create a prediction job from the given model version + + + :param model_id: (required) + :type model_id: int + :param version_id: (required) + :type version_id: int + :param body: + :type body: PredictionJob + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._models_model_id_versions_version_id_jobs_post_serialize( + model_id=model_id, + version_id=version_id, + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PredictionJob", + '404': None + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def models_model_id_versions_version_id_jobs_post_without_preload_content( + self, + model_id: StrictInt, + version_id: StrictInt, + body: Optional[PredictionJob] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """Create a prediction job from the given model version + + + :param model_id: (required) + :type model_id: int + :param version_id: (required) + :type version_id: int + :param body: + :type body: PredictionJob + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._models_model_id_versions_version_id_jobs_post_serialize( + model_id=model_id, + version_id=version_id, + body=body, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "PredictionJob", + '404': None + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _models_model_id_versions_version_id_jobs_post_serialize( + self, + model_id, + version_id, + body, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> Tuple: + + _host = None + + _collection_formats: Dict[str, str] = { + + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if model_id is not None: + _path_params['model_id'] = model_id + if version_id is not None: + _path_params['version_id'] = version_id + # process the query parameters + # process the header parameters + # process the form parameters + # process the body parameter + if body is not None: + _body_params = body + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'Bearer' + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/models/{model_id}/versions/{version_id}/jobs', + path_params=_path_params, + query_params=_query_params, + header_params=_header_params, + body=_body_params, + post_params=_form_params, + files=_files, + auth_settings=_auth_settings, + collection_formats=_collection_formats, + _host=_host, + _request_auth=_request_auth + ) + + + + + @validate_call + def projects_project_id_jobs_by_page_get( + self, + project_id: StrictInt, + page: Optional[StrictInt] = None, + id: Optional[StrictInt] = None, + name: Optional[StrictStr] = None, + search: Annotated[Optional[StrictStr], Field(description="Search job name for a partial match of the search text")] = None, + model_id: Optional[StrictInt] = None, + version_id: Optional[StrictInt] = None, + status: Optional[StrictStr] = None, + error: Optional[StrictStr] = None, + page_size: Annotated[Optional[StrictInt], Field(description="Number of items on each page. It defaults to 10.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ListJobsPaginatedResponse: + """List all prediction jobs created using the model with pagination + + + :param project_id: (required) + :type project_id: int + :param page: + :type page: int + :param id: + :type id: int + :param name: + :type name: str + :param search: Search job name for a partial match of the search text + :type search: str + :param model_id: + :type model_id: int + :param version_id: + :type version_id: int + :param status: + :type status: str + :param error: + :type error: str + :param page_size: Number of items on each page. It defaults to 10. + :type page_size: int + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._projects_project_id_jobs_by_page_get_serialize( + project_id=project_id, + page=page, + id=id, + name=name, + search=search, + model_id=model_id, + version_id=version_id, + status=status, + error=error, + page_size=page_size, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListJobsPaginatedResponse", + '404': None + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ).data + + + @validate_call + def projects_project_id_jobs_by_page_get_with_http_info( + self, + project_id: StrictInt, + page: Optional[StrictInt] = None, + id: Optional[StrictInt] = None, + name: Optional[StrictStr] = None, + search: Annotated[Optional[StrictStr], Field(description="Search job name for a partial match of the search text")] = None, + model_id: Optional[StrictInt] = None, + version_id: Optional[StrictInt] = None, + status: Optional[StrictStr] = None, + error: Optional[StrictStr] = None, + page_size: Annotated[Optional[StrictInt], Field(description="Number of items on each page. It defaults to 10.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> ApiResponse[ListJobsPaginatedResponse]: + """List all prediction jobs created using the model with pagination + + + :param project_id: (required) + :type project_id: int + :param page: + :type page: int + :param id: + :type id: int + :param name: + :type name: str + :param search: Search job name for a partial match of the search text + :type search: str + :param model_id: + :type model_id: int + :param version_id: + :type version_id: int + :param status: + :type status: str + :param error: + :type error: str + :param page_size: Number of items on each page. It defaults to 10. + :type page_size: int + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._projects_project_id_jobs_by_page_get_serialize( + project_id=project_id, + page=page, + id=id, + name=name, + search=search, + model_id=model_id, + version_id=version_id, + status=status, + error=error, + page_size=page_size, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListJobsPaginatedResponse", + '404': None + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + response_data.read() + return self.api_client.response_deserialize( + response_data=response_data, + response_types_map=_response_types_map, + ) + + + @validate_call + def projects_project_id_jobs_by_page_get_without_preload_content( + self, + project_id: StrictInt, + page: Optional[StrictInt] = None, + id: Optional[StrictInt] = None, + name: Optional[StrictStr] = None, + search: Annotated[Optional[StrictStr], Field(description="Search job name for a partial match of the search text")] = None, + model_id: Optional[StrictInt] = None, + version_id: Optional[StrictInt] = None, + status: Optional[StrictStr] = None, + error: Optional[StrictStr] = None, + page_size: Annotated[Optional[StrictInt], Field(description="Number of items on each page. It defaults to 10.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """List all prediction jobs created using the model with pagination + + + :param project_id: (required) + :type project_id: int + :param page: + :type page: int + :param id: + :type id: int + :param name: + :type name: str + :param search: Search job name for a partial match of the search text + :type search: str + :param model_id: + :type model_id: int + :param version_id: + :type version_id: int + :param status: + :type status: str + :param error: + :type error: str + :param page_size: Number of items on each page. It defaults to 10. + :type page_size: int + :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. + :type _request_timeout: int, tuple(int, int), optional + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the + authentication in the spec for a single request. + :type _request_auth: dict, optional + :param _content_type: force content-type for the request. + :type _content_type: str, Optional + :param _headers: set to override the headers for a single + request; this effectively ignores the headers + in the spec for a single request. + :type _headers: dict, optional + :param _host_index: set to override the host_index for a single + request; this effectively ignores the host_index + in the spec for a single request. + :type _host_index: int, optional + :return: Returns the result object. + """ # noqa: E501 + + _param = self._projects_project_id_jobs_by_page_get_serialize( + project_id=project_id, + page=page, + id=id, + name=name, + search=search, + model_id=model_id, + version_id=version_id, + status=status, + error=error, + page_size=page_size, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ListJobsPaginatedResponse", + '404': None + + } + response_data = self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _projects_project_id_jobs_by_page_get_serialize( + self, + project_id, + page, + id, + name, + search, + model_id, + version_id, + status, + error, + page_size, + _request_auth, + _content_type, + _headers, + _host_index, + ) -> Tuple: + + _host = None + + _collection_formats: Dict[str, str] = { + + } + + _path_params: Dict[str, str] = {} + _query_params: List[Tuple[str, str]] = [] + _header_params: Dict[str, Optional[str]] = _headers or {} + _form_params: List[Tuple[str, str]] = [] + _files: Dict[str, str] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + if project_id is not None: + _path_params['project_id'] = project_id + # process the query parameters + if page is not None: + + _query_params.append(('page', page)) + + if id is not None: + + _query_params.append(('id', id)) + + if name is not None: + + _query_params.append(('name', name)) + + if search is not None: + + _query_params.append(('search', search)) + + if model_id is not None: + + _query_params.append(('model_id', model_id)) + + if version_id is not None: + + _query_params.append(('version_id', version_id)) + + if status is not None: + + _query_params.append(('status', status)) + + if error is not None: + + _query_params.append(('error', error)) + + if page_size is not None: + + _query_params.append(('page_size', page_size)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + [ + '*/*' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + 'Bearer' + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/projects/{project_id}/jobs-by-page', path_params=_path_params, query_params=_query_params, header_params=_header_params, @@ -1504,7 +2253,7 @@ def projects_project_id_jobs_get( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> List[PredictionJob]: - """List all prediction jobs created using the model + """(Deprecated) List all prediction jobs created using the model. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. :param project_id: (required) @@ -1542,6 +2291,7 @@ def projects_project_id_jobs_get( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 + warnings.warn("GET /projects/{project_id}/jobs is deprecated.", DeprecationWarning) _param = self._projects_project_id_jobs_get_serialize( project_id=project_id, @@ -1596,7 +2346,7 @@ def projects_project_id_jobs_get_with_http_info( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> ApiResponse[List[PredictionJob]]: - """List all prediction jobs created using the model + """(Deprecated) List all prediction jobs created using the model. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. :param project_id: (required) @@ -1634,6 +2384,7 @@ def projects_project_id_jobs_get_with_http_info( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 + warnings.warn("GET /projects/{project_id}/jobs is deprecated.", DeprecationWarning) _param = self._projects_project_id_jobs_get_serialize( project_id=project_id, @@ -1688,7 +2439,7 @@ def projects_project_id_jobs_get_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """List all prediction jobs created using the model + """(Deprecated) List all prediction jobs created using the model. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. :param project_id: (required) @@ -1726,6 +2477,7 @@ def projects_project_id_jobs_get_without_preload_content( :type _host_index: int, optional :return: Returns the result object. """ # noqa: E501 + warnings.warn("GET /projects/{project_id}/jobs is deprecated.", DeprecationWarning) _param = self._projects_project_id_jobs_get_serialize( project_id=project_id, diff --git a/python/sdk/client/models/__init__.py b/python/sdk/client/models/__init__.py index f1bd7be48..7f387a5bd 100644 --- a/python/sdk/client/models/__init__.py +++ b/python/sdk/client/models/__init__.py @@ -32,6 +32,7 @@ from client.models.image_building_job_state import ImageBuildingJobState from client.models.image_building_job_status import ImageBuildingJobStatus from client.models.label import Label +from client.models.list_jobs_paginated_response import ListJobsPaginatedResponse from client.models.logger import Logger from client.models.logger_config import LoggerConfig from client.models.logger_mode import LoggerMode @@ -48,6 +49,7 @@ from client.models.model_prediction_output_class import ModelPredictionOutputClass from client.models.model_schema import ModelSchema from client.models.operation_tracing import OperationTracing +from client.models.paging import Paging from client.models.pipeline_tracing import PipelineTracing from client.models.prediction_job import PredictionJob from client.models.prediction_job_config import PredictionJobConfig diff --git a/python/sdk/client/models/list_jobs_paginated_response.py b/python/sdk/client/models/list_jobs_paginated_response.py new file mode 100644 index 000000000..9632e46fe --- /dev/null +++ b/python/sdk/client/models/list_jobs_paginated_response.py @@ -0,0 +1,101 @@ +# coding: utf-8 + +""" + Merlin + + API Guide for accessing Merlin's model management, deployment, and serving functionalities + + The version of the OpenAPI document: 0.14.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, ClassVar, Dict, List +from pydantic import BaseModel +from client.models.paging import Paging +from client.models.prediction_job import PredictionJob +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class ListJobsPaginatedResponse(BaseModel): + """ + ListJobsPaginatedResponse + """ # noqa: E501 + results: List[PredictionJob] + paging: Paging + __properties: ClassVar[List[str]] = ["results", "paging"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of ListJobsPaginatedResponse from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + }, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in results (list) + _items = [] + if self.results: + for _item in self.results: + if _item: + _items.append(_item.to_dict()) + _dict['results'] = _items + # override the default output from pydantic by calling `to_dict()` of paging + if self.paging: + _dict['paging'] = self.paging.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of ListJobsPaginatedResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "results": [PredictionJob.from_dict(_item) for _item in obj.get("results")] if obj.get("results") is not None else None, + "paging": Paging.from_dict(obj.get("paging")) if obj.get("paging") is not None else None + }) + return _obj + + diff --git a/python/sdk/client/models/paging.py b/python/sdk/client/models/paging.py new file mode 100644 index 000000000..d2f3151f1 --- /dev/null +++ b/python/sdk/client/models/paging.py @@ -0,0 +1,92 @@ +# coding: utf-8 + +""" + Merlin + + API Guide for accessing Merlin's model management, deployment, and serving functionalities + + The version of the OpenAPI document: 0.14.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + +from typing import Any, ClassVar, Dict, List +from pydantic import BaseModel, StrictInt +from pydantic import Field +try: + from typing import Self +except ImportError: + from typing_extensions import Self + +class Paging(BaseModel): + """ + Paging + """ # noqa: E501 + total: StrictInt = Field(description="Total number of results matching the query criteria") + page: StrictInt = Field(description="Number of the current page") + pages: StrictInt = Field(description="Total number of pages") + __properties: ClassVar[List[str]] = ["total", "page", "pages"] + + model_config = { + "populate_by_name": True, + "validate_assignment": True + } + + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of Paging from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + """Return the dictionary representation of the model using alias. + + This has the following differences from calling pydantic's + `self.model_dump(by_alias=True)`: + + * `None` is only added to the output dict for nullable fields that + were set at model initialization. Other fields with value `None` + are ignored. + """ + _dict = self.model_dump( + by_alias=True, + exclude={ + }, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Dict) -> Self: + """Create an instance of Paging from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "total": obj.get("total"), + "page": obj.get("page"), + "pages": obj.get("pages") + }) + return _obj + + diff --git a/python/sdk/client_README.md b/python/sdk/client_README.md index 63f3ad2b4..e051f0ea3 100644 --- a/python/sdk/client_README.md +++ b/python/sdk/client_README.md @@ -104,12 +104,14 @@ Class | Method | HTTP request | Description *ModelsApi* | [**projects_project_id_models_model_id_delete**](client/docs/ModelsApi.md#projects_project_id_models_model_id_delete) | **DELETE** /projects/{project_id}/models/{model_id} | Delete model *ModelsApi* | [**projects_project_id_models_model_id_get**](client/docs/ModelsApi.md#projects_project_id_models_model_id_get) | **GET** /projects/{project_id}/models/{model_id} | Get model *ModelsApi* | [**projects_project_id_models_post**](client/docs/ModelsApi.md#projects_project_id_models_post) | **POST** /projects/{project_id}/models | Register a new models -*PredictionJobsApi* | [**models_model_id_versions_version_id_jobs_get**](client/docs/PredictionJobsApi.md#models_model_id_versions_version_id_jobs_get) | **GET** /models/{model_id}/versions/{version_id}/jobs | List all prediction jobs of a model version +*PredictionJobsApi* | [**models_model_id_versions_version_id_jobs_by_page_get**](client/docs/PredictionJobsApi.md#models_model_id_versions_version_id_jobs_by_page_get) | **GET** /models/{model_id}/versions/{version_id}/jobs-by-page | List all prediction jobs of a model version with pagination +*PredictionJobsApi* | [**models_model_id_versions_version_id_jobs_get**](client/docs/PredictionJobsApi.md#models_model_id_versions_version_id_jobs_get) | **GET** /models/{model_id}/versions/{version_id}/jobs | List all prediction jobs of a model version. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. *PredictionJobsApi* | [**models_model_id_versions_version_id_jobs_job_id_containers_get**](client/docs/PredictionJobsApi.md#models_model_id_versions_version_id_jobs_job_id_containers_get) | **GET** /models/{model_id}/versions/{version_id}/jobs/{job_id}/containers | Get all container belong to a prediction job *PredictionJobsApi* | [**models_model_id_versions_version_id_jobs_job_id_get**](client/docs/PredictionJobsApi.md#models_model_id_versions_version_id_jobs_job_id_get) | **GET** /models/{model_id}/versions/{version_id}/jobs/{job_id} | Get prediction jobs with given id *PredictionJobsApi* | [**models_model_id_versions_version_id_jobs_job_id_stop_put**](client/docs/PredictionJobsApi.md#models_model_id_versions_version_id_jobs_job_id_stop_put) | **PUT** /models/{model_id}/versions/{version_id}/jobs/{job_id}/stop | Stop prediction jobs with given id *PredictionJobsApi* | [**models_model_id_versions_version_id_jobs_post**](client/docs/PredictionJobsApi.md#models_model_id_versions_version_id_jobs_post) | **POST** /models/{model_id}/versions/{version_id}/jobs | Create a prediction job from the given model version -*PredictionJobsApi* | [**projects_project_id_jobs_get**](client/docs/PredictionJobsApi.md#projects_project_id_jobs_get) | **GET** /projects/{project_id}/jobs | List all prediction jobs created using the model +*PredictionJobsApi* | [**projects_project_id_jobs_by_page_get**](client/docs/PredictionJobsApi.md#projects_project_id_jobs_by_page_get) | **GET** /projects/{project_id}/jobs-by-page | List all prediction jobs created using the model with pagination +*PredictionJobsApi* | [**projects_project_id_jobs_get**](client/docs/PredictionJobsApi.md#projects_project_id_jobs_get) | **GET** /projects/{project_id}/jobs | List all prediction jobs created using the model. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. *ProjectApi* | [**projects_get**](client/docs/ProjectApi.md#projects_get) | **GET** /projects | List existing projects *ProjectApi* | [**projects_post**](client/docs/ProjectApi.md#projects_post) | **POST** /projects | Create new project *ProjectApi* | [**projects_project_id_get**](client/docs/ProjectApi.md#projects_project_id_get) | **GET** /projects/{project_id} | Get project @@ -148,6 +150,7 @@ Class | Method | HTTP request | Description - [ImageBuildingJobState](client/docs/ImageBuildingJobState.md) - [ImageBuildingJobStatus](client/docs/ImageBuildingJobStatus.md) - [Label](client/docs/Label.md) + - [ListJobsPaginatedResponse](client/docs/ListJobsPaginatedResponse.md) - [Logger](client/docs/Logger.md) - [LoggerConfig](client/docs/LoggerConfig.md) - [LoggerMode](client/docs/LoggerMode.md) @@ -164,6 +167,7 @@ Class | Method | HTTP request | Description - [ModelPredictionOutputClass](client/docs/ModelPredictionOutputClass.md) - [ModelSchema](client/docs/ModelSchema.md) - [OperationTracing](client/docs/OperationTracing.md) + - [Paging](client/docs/Paging.md) - [PipelineTracing](client/docs/PipelineTracing.md) - [PredictionJob](client/docs/PredictionJob.md) - [PredictionJobConfig](client/docs/PredictionJobConfig.md) diff --git a/python/sdk/merlin/model.py b/python/sdk/merlin/model.py index 975ccbe37..9683bff4b 100644 --- a/python/sdk/merlin/model.py +++ b/python/sdk/merlin/model.py @@ -1559,12 +1559,25 @@ def list_prediction_job(self) -> List[PredictionJob]: :return: list of prediction jobs """ job_client = client.PredictionJobsApi(self._api_client) - res = job_client.models_model_id_versions_version_id_jobs_get( - model_id=self.model.id, version_id=self.id + + res = job_client.models_model_id_versions_version_id_jobs_by_page_get( + model_id=self.model.id, version_id=self.id, page=1 ) jobs = [] - for j in res: + for j in res.results: jobs.append(PredictionJob(j, self._api_client)) + + # Paginated response. Parse the rest of the pages. + total_pages = res.paging.pages + page = 2 + while page <= total_pages: + res = job_client.models_model_id_versions_version_id_jobs_by_page_get( + model_id=self.model.id, version_id=self.id, page=page + ) + for j in res.results: + jobs.append(PredictionJob(j, self._api_client)) + page += 1 + return jobs def start_server( diff --git a/python/sdk/test/model_test.py b/python/sdk/test/model_test.py index 0fc68b97d..e57c4e226 100644 --- a/python/sdk/test/model_test.py +++ b/python/sdk/test/model_test.py @@ -941,12 +941,33 @@ def test_undeploy_default_env(self, version): def test_list_prediction_job(self, version): responses.add( method="GET", - url="/v1/models/1/versions/1/jobs", - body=json.dumps( - [job_1.to_dict(), job_2.to_dict()], default=serialize_datetime - ), + url="/v1/models/1/versions/1/jobs-by-page?page=1", + body=json.dumps({ + "results": [job_1.to_dict()], + "paging": { + "page": 1, + "pages": 2, + "total": 2, + }, + }, default=serialize_datetime), + status=200, + content_type="application/json", + match_querystring=True, + ) + responses.add( + method="GET", + url="/v1/models/1/versions/1/jobs-by-page?page=2", + body=json.dumps({ + "results": [job_2.to_dict()], + "paging": { + "page": 2, + "pages": 2, + "total": 2, + }, + }, default=serialize_datetime), status=200, content_type="application/json", + match_querystring=True, ) jobs = version.list_prediction_job() assert len(jobs) == 2 diff --git a/swagger.yaml b/swagger.yaml index e6cc23940..ae980e553 100644 --- a/swagger.yaml +++ b/swagger.yaml @@ -290,9 +290,10 @@ paths: x-codegen-request-body-name: body "/projects/{project_id}/jobs": get: + deprecated: true tags: - prediction_jobs - summary: List all prediction jobs created using the model + summary: List all prediction jobs created using the model. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. parameters: - name: project_id in: path @@ -335,6 +336,67 @@ paths: "404": description: Project with given `project_id` not found content: {} + "/projects/{project_id}/jobs-by-page": + get: + tags: + - prediction_jobs + summary: List all prediction jobs created using the model with pagination + parameters: + - name: project_id + in: path + required: true + schema: + type: integer + - name: page + in: query + schema: + type: integer + format: int32 + - name: id + in: query + schema: + type: integer + - name: name + in: query + schema: + type: string + - name: search + description: Search job name for a partial match of the search text + in: query + schema: + type: string + - name: model_id + in: query + schema: + type: integer + - name: version_id + in: query + schema: + type: integer + - name: status + in: query + schema: + type: string + - name: error + in: query + schema: + type: string + - name: page_size + description: Number of items on each page. It defaults to 10. + in: query + schema: + type: integer + format: int32 + responses: + "200": + description: OK + content: + "*/*": + schema: + "$ref": "#/components/schemas/ListJobsPaginatedResponse" + "404": + description: Page not found + content: {} "/models/{model_id}/versions": get: tags: @@ -1184,9 +1246,10 @@ paths: x-codegen-request-body-name: body "/models/{model_id}/versions/{version_id}/jobs": get: + deprecated: true tags: - prediction_jobs - summary: List all prediction jobs of a model version + summary: List all prediction jobs of a model version. This endpoint is deprecated. Please use the corresponding /jobs-by-page endpoint instead. parameters: - name: model_id in: path @@ -1332,6 +1395,48 @@ paths: "404": description: Version endpoint with given `endpoint_id` not found content: {} + "/models/{model_id}/versions/{version_id}/jobs-by-page": + get: + tags: + - prediction_jobs + summary: List all prediction jobs of a model version with pagination + parameters: + - name: model_id + in: path + required: true + schema: + type: integer + - name: version_id + in: path + required: true + schema: + type: integer + - name: page + in: query + schema: + type: integer + format: int32 + - name: page_size + description: Number of items on each page. It defaults to 10. + in: query + schema: + type: integer + format: int32 + - name: search + description: Search job name for a partial match of the search text + in: query + schema: + type: string + responses: + "200": + description: OK + content: + "*/*": + schema: + "$ref": "#/components/schemas/ListJobsPaginatedResponse" + "404": + description: Page not found + content: {} "/standard_transformer/simulate": post: tags: @@ -2334,6 +2439,37 @@ components: enum: - HTTP_JSON - UPI_V1 + Paging: + required: + - total + - page + - pages + type: object + properties: + total: + type: integer + format: int32 + description: Total number of results matching the query criteria + page: + type: integer + format: int32 + description: Number of the current page + pages: + type: integer + format: int32 + description: Total number of pages + ListJobsPaginatedResponse: + type: object + required: + - results + - paging + properties: + results: + type: array + items: + "$ref": "#/components/schemas/PredictionJob" + paging: + "$ref": "#/components/schemas/Paging" securitySchemes: Bearer: type: apiKey