Skip to content

Commit 28b1a5b

Browse files
committed
Fix Functional Tests to accomodate dyanmic sample config JSON generation
Signed-off-by: Giulio Frasca <[email protected]>
1 parent 0331a6b commit 28b1a5b

File tree

22 files changed

+182
-42
lines changed

22 files changed

+182
-42
lines changed

api/v1/dspipeline_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type ManagedPipelineOptions struct {
6262
// Set to one of the following values:
6363
//
6464
// - "Managed" : This pipeline is automatically imported.
65-
// - "Removed" : This pipeline is not automatically imported when a new pipeline server or DSPA is created. If previously set to "Managed", setting to "Removed" does not remove existing preloaded pipelines but does prevent future updates from being imported.
65+
// - "Removed" : This pipeline is not automatically imported. If previously set to "Managed", setting to "Removed" does not remove existing managed pipelines but does prevent future updates from being imported.
6666
//
6767
// +kubebuilder:validation:Enum=Managed;Removed
6868
// +kubebuilder:default=Removed
@@ -90,7 +90,6 @@ type APIServer struct {
9090
EnableRoute bool `json:"enableOauth"`
9191
// Include the Iris sample pipeline with the deployment of this DSP API Server. Default: true
9292
// +kubebuilder:default:=false
93-
// +Deprecated
9493
// +kubebuilder:validation:Optional
9594
EnableSamplePipeline bool `json:"enableSamplePipeline"`
9695
// Launcher/Executor image used during pipeline execution.

api/v1alpha1/dspipeline_types.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ type ManagedPipelineOptions struct {
6262
// Set to one of the following values:
6363
//
6464
// - "Managed" : This pipeline is automatically imported.
65-
// - "Removed" : This pipeline is not automatically imported when a new pipeline server or DSPA is created. If previously set to "Managed", setting to "Removed" does not remove existing preloaded pipelines but does prevent future updates from being imported.
66-
//
65+
// - "Removed" : This pipeline is not automatically imported. If previously set to "Managed", setting to "Removed" does not remove existing managed pipelines but does prevent future updates from being imported. //
6766
// +kubebuilder:validation:Enum=Managed;Removed
6867
// +kubebuilder:default=Removed
6968
// +kubebuilder:validation:Optional
@@ -90,7 +89,6 @@ type APIServer struct {
9089
EnableRoute bool `json:"enableOauth"`
9190
// Include the Iris sample pipeline with the deployment of this DSP API Server. Default: true
9291
// +kubebuilder:default:=false
93-
// +Deprecated
9492
// +kubebuilder:validation:Optional
9593
EnableSamplePipeline bool `json:"enableSamplePipeline"`
9694
// Launcher/Executor image used during pipeline execution.

config/configmaps/files/config.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ Images:
1515
RHELAI: $(IMAGES_RHELAI)
1616
ManagedPipelinesMetadata:
1717
Instructlab:
18-
Name: "[InstructLab] LLM Training Pipeline"
19-
Description:
18+
Name: Instructlab
19+
Description: InstructLab fine-tunes models using synthetic data generation (SDG) techniques and a structured taxonomy to create diverse, high-quality training datasets.
2020
Filepath: /pipelines/instructlab.yaml
21-
VersionName: "[InstructLab] LLM Training Pipeline"
22-
# VersionDescription: "TODO - Add a Version Description"
21+
VersionName: Instructlab
2322
Iris:
2423
Name: "[Demo] iris-training"
2524
Description: "[source code](https://github.com/opendatahub-io/data-science-pipelines/tree/master/samples/iris-sklearn) A simple pipeline to demonstrate a basic ML Training workflow"
2625
Filepath: /samples/iris-pipeline-compiled.yaml
2726
VersionName: "[Demo] iris-training"
28-
# VersionDescription: "TODO - Add a Version Description"
2927
DSPO:
3028
HealthCheck:
3129
Database:

config/crd/bases/datasciencepipelinesapplications.opendatahub.io_datasciencepipelinesapplications.yaml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,10 @@ spec:
169169
default: Removed
170170
description: "Set to one of the following values: \n -
171171
\"Managed\" : This pipeline is automatically imported.
172-
- \"Removed\" : This pipeline is not automatically imported
173-
when a new pipeline server or DSPA is created. If previously
174-
set to \"Managed\", setting to \"Removed\" does not
175-
remove existing preloaded pipelines but does prevent
176-
future updates from being imported."
172+
- \"Removed\" : This pipeline is not automatically imported.
173+
If previously set to \"Managed\", setting to \"Removed\"
174+
does not remove existing managed pipelines but does
175+
prevent future updates from being imported."
177176
enum:
178177
- Managed
179178
- Removed
@@ -1133,11 +1132,10 @@ spec:
11331132
default: Removed
11341133
description: "Set to one of the following values: \n -
11351134
\"Managed\" : This pipeline is automatically imported.
1136-
- \"Removed\" : This pipeline is not automatically imported
1137-
when a new pipeline server or DSPA is created. If previously
1138-
set to \"Managed\", setting to \"Removed\" does not
1139-
remove existing preloaded pipelines but does prevent
1140-
future updates from being imported."
1135+
- \"Removed\" : This pipeline is not automatically imported.
1136+
If previously set to \"Managed\", setting to \"Removed\"
1137+
does not remove existing managed pipelines but does
1138+
prevent future updates from being imported.\t//"
11411139
enum:
11421140
- Managed
11431141
- Removed

config/overlays/make-deploy/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ patchesStrategicMerge:
99
images:
1010
- name: controller
1111
newName: quay.io/gmfrasca/dspo
12-
newTag: managed-pipelines-v0.0.3
12+
newTag: managed-pipelines-v0.0.5

controllers/apiserver.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package controllers
1818
import (
1919
"context"
2020
"crypto/sha256"
21-
"encoding/hex"
2221
"encoding/json"
2322
"fmt"
2423
"strings"
@@ -50,19 +49,19 @@ func (r *DSPAReconciler) GenerateSamplePipelineMetadataBlock(pipeline string) (m
5049
item := make(map[string]string)
5150

5251
// Get Required Fields
53-
pName, err := config.GetStringConfigOrError(fmt.Sprintf("ManagedPipelinesMetadata.%s.Name", pipeline))
52+
pName, err := config.GetStringConfig(fmt.Sprintf("ManagedPipelinesMetadata.%s.Name", pipeline))
5453
if err != nil {
5554
return nil, err
5655
}
57-
pFile, err := config.GetStringConfigOrError(fmt.Sprintf("ManagedPipelinesMetadata.%s.Filepath", pipeline))
56+
pFile, err := config.GetStringConfig(fmt.Sprintf("ManagedPipelinesMetadata.%s.Filepath", pipeline))
5857
if err != nil {
5958
return nil, err
6059
}
61-
platformVersion := config.GetStringConfigWithDefault("PlatformVersion", config.DefaultPlatformVersion)
60+
platformVersion := config.GetStringConfigWithDefault("DSPO.PlatformVersion", config.DefaultPlatformVersion)
6261

6362
// Get optional fields
6463
pDesc := config.GetStringConfigWithDefault(fmt.Sprintf("ManagedPipelinesMetadata.%s.Description", pipeline), "")
65-
pVerName := config.GetStringConfigWithDefault(fmt.Sprintf("ManagedPipelinesMetadata.%s.VersionName", pipeline), "")
64+
pVerName := config.GetStringConfigWithDefault(fmt.Sprintf("ManagedPipelinesMetadata.%s.VersionName", pipeline), pName)
6665
pVerDesc := config.GetStringConfigWithDefault(fmt.Sprintf("ManagedPipelinesMetadata.%s.VersionDescription", pipeline), "")
6766

6867
// Create Sample Config item
@@ -76,7 +75,7 @@ func (r *DSPAReconciler) GenerateSamplePipelineMetadataBlock(pipeline string) (m
7675

7776
}
7877

79-
func (r *DSPAReconciler) GetSampleConfig(ctx context.Context, dsp *dspa.DataSciencePipelinesApplication, params *DSPAParams) (string, error) {
78+
func (r *DSPAReconciler) GetSampleConfig(dsp *dspa.DataSciencePipelinesApplication) (string, error) {
8079
// Check if InstructLab Pipeline enabled in this DSPA
8180
enableInstructLabPipeline := false
8281
if dsp.Spec.APIServer.ManagedPipelines != nil && dsp.Spec.APIServer.ManagedPipelines.InstructLab != nil {
@@ -86,10 +85,10 @@ func (r *DSPAReconciler) GetSampleConfig(ctx context.Context, dsp *dspa.DataScie
8685
}
8786
}
8887

89-
return r.GenerateSampleConfigJSON(enableInstructLabPipeline, dsp.Spec.APIServer.EnableSamplePipeline)
88+
return r.generateSampleConfigJSON(enableInstructLabPipeline, dsp.Spec.APIServer.EnableSamplePipeline)
9089
}
9190

92-
func (r *DSPAReconciler) GenerateSampleConfigJSON(enableInstructLabPipeline, enableIrisPipeline bool) (string, error) {
91+
func (r *DSPAReconciler) generateSampleConfigJSON(enableInstructLabPipeline, enableIrisPipeline bool) (string, error) {
9392

9493
// Now generate a sample config
9594
var pipelineConfig = make([]map[string]string, 0)
@@ -130,17 +129,14 @@ func (r *DSPAReconciler) ReconcileAPIServer(ctx context.Context, dsp *dspav1.Dat
130129
}
131130

132131
log.Info("Generating Sample Config")
133-
sampleConfigJSON, err := r.GetSampleConfig(ctx, dsp, params)
132+
sampleConfigJSON, err := r.GetSampleConfig(dsp)
134133
if err != nil {
135134
return err
136135
}
137136
params.SampleConfigJSON = sampleConfigJSON
138137

139138
// Generate configuration hash for rebooting on sample changes
140-
hasher := sha256.New()
141-
hasher.Write([]byte(sampleConfigJSON))
142-
configHash := hex.EncodeToString(hasher.Sum(nil))
143-
params.APIServerConfigHash = configHash
139+
params.APIServerConfigHash = fmt.Sprintf("%x", sha256.Sum256([]byte(sampleConfigJSON)))
144140

145141
log.Info("Applying APIServer Resources")
146142
err = r.ApplyDir(dsp, params, apiServerTemplatesDir)

controllers/config/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func createResourceRequirement(RequestsCPU resource.Quantity, RequestsMemory res
195195
}
196196
}
197197

198-
func GetStringConfigOrError(configName string) (string, error) {
198+
func GetStringConfig(configName string) (string, error) {
199199
if !viper.IsSet(configName) {
200200
return "", fmt.Errorf("value not set in config for configname %s", configName)
201201
}

controllers/testdata/declarative/case_0/config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ Images:
1616
RuntimeGeneric: runtimegeneric:test0
1717
Toolbox: toolbox:test0
1818
RHELAI: rhelai:test0
19+
ManagedPipelinesMetadata:
20+
Instructlab:
21+
Name: "[InstructLab] LLM Training Pipeline"
22+
Description:
23+
Filepath: /pipelines/instructlab.yaml
24+
VersionName: "[InstructLab] LLM Training Pipeline"
25+
Iris:
26+
Name: "[Demo] iris-training"
27+
Description: "[source code](https://github.com/opendatahub-io/data-science-pipelines/tree/master/samples/iris-sklearn) A simple pipeline to demonstrate a basic ML Training workflow"
28+
Filepath: /samples/iris-pipeline-compiled.yaml
29+
VersionName: "[Demo] iris-training"
1930
DSPO:
31+
PlatformVersion: v0.0.0
2032
ApiServer:
2133
IncludeOwnerReference: false

controllers/testdata/declarative/case_0/expected/created/apiserver_deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ spec:
1616
dspa: testdsp0
1717
template:
1818
metadata:
19+
annotations:
20+
configHash: 33ff9677391ad5d02376e8a13b5dc6a207c37120c38011f7a3bba17d63b4cfbb
1921
labels:
2022
dsp-version: v2
2123
app: ds-pipeline-testdsp0

controllers/testdata/declarative/case_1/config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,16 @@ Images:
1515
RuntimeGeneric: runtimegeneric:test1
1616
Toolbox: toolbox:test1
1717
RHELAI: rhelai:test1
18+
ManagedPipelinesMetadata:
19+
Instructlab:
20+
Name: "[InstructLab] LLM Training Pipeline"
21+
Description:
22+
Filepath: /pipelines/instructlab.yaml
23+
VersionName: "[InstructLab] LLM Training Pipeline"
24+
Iris:
25+
Name: "[Demo] iris-training"
26+
Description: "[source code](https://github.com/opendatahub-io/data-science-pipelines/tree/master/samples/iris-sklearn) A simple pipeline to demonstrate a basic ML Training workflow"
27+
Filepath: /samples/iris-pipeline-compiled.yaml
28+
VersionName: "[Demo] iris-training"
29+
DSPO:
30+
PlatformVersion: v0.0.0

0 commit comments

Comments
 (0)