Skip to content

Commit

Permalink
Fixing Eval implementation (#300)
Browse files Browse the repository at this point in the history
Signed-off-by: Vishesh Tanksale <[email protected]>
  • Loading branch information
visheshtanksale authored Jan 24, 2025
1 parent 4e0745e commit 70dfee2
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 125 deletions.
52 changes: 48 additions & 4 deletions api/apps/v1alpha1/nemo_common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ limitations under the License.

package v1alpha1

type Mongodb struct {
Endpoint string `json:"endpoint"`
}

type ArgoWorkFlows struct {
Endpoint string `json:"endpoint"`
ServiceAccount string `json:"serviceAccount"`
Expand All @@ -32,3 +28,51 @@ type Milvus struct {
type DataStore struct {
Endpoint string `json:"endpoint"`
}

type DatabaseConfig struct {
// Host is the hostname of the database.
// Required, must not be empty.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Host string `json:"host,omitempty"`
// Port is the port where the database is reachable at.
// If specified, this must be a valid port number, 0 < databasePort < 65536.
// Defaults to 5432.
//
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
// +kubebuilder:default:=5432
Port int32 `json:"port,omitempty"`
// DatabaseName is the database name for a NEMO Service.
// Required, must not be empty.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
DatabaseName string `json:"databaseName,omitempty"`
// DatabaseCredentials stores the configuration to retrieve the database credentials.
// Required, must not be nil.
//
// +kubebuilder:validation:Required
Credentials *DatabaseCredentials `json:"credentials,omitempty"`
}

type DatabaseCredentials struct {
// User is the non-root username for a NEMO Service in the database.
// Required, must not be empty.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
User string `json:"user,omitempty"`
// SecretName is the name of the secret which has the database credentials for a NEMO service user.
// Required, must not be empty.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
SecretName string `json:"secretName,omitempty"`
// PasswordKey is the name of the key in the `CredentialsSecret` secret for the database credentials.
// Defaults to "password".
//
// +kubebuilder:default:="password"
PasswordKey string `json:"passwordKey,omitempty"`
}
48 changes: 0 additions & 48 deletions api/apps/v1alpha1/nemo_entitystore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,54 +85,6 @@ type NemoEntitystoreSpec struct {
DatabaseConfig *DatabaseConfig `json:"databaseConfig,omitempty"`
}

type DatabaseConfig struct {
// Host is the hostname of the database.
// Required, must not be empty.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
Host string `json:"host,omitempty"`
// Port is the port where the database is reachable at.
// If specified, this must be a valid port number, 0 < databasePort < 65536.
// Defaults to 5432.
//
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=65535
// +kubebuilder:default:=5432
Port int32 `json:"port,omitempty"`
// DatabaseName is the database name for NEMO EntityStore.
// Required, must not be empty.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
DatabaseName string `json:"databaseName,omitempty"`
// DatabaseCredentials stores the configuration to retrieve the database credentials.
// Required, must not be nil.
//
// +kubebuilder:validation:Required
Credentials *DatabaseCredentials `json:"credentials,omitempty"`
}

type DatabaseCredentials struct {
// User is the non-root username for NEMO EntityStore in the database.
// Required, must not be empty.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
User string `json:"user,omitempty"`
// SecretName is the name of the secret which has the database credentials for the NEMO entitystore user.
// Required, must not be empty.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
SecretName string `json:"secretName,omitempty"`
// PasswordKey is the name of the key in the `CredentialsSecret` secret for the database credentials.
// Defaults to "password".
//
// +kubebuilder:default:="password"
PasswordKey string `json:"passwordKey,omitempty"`
}

// NemoEntitystoreStatus defines the observed state of NemoEntitystore
type NemoEntitystoreStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
Expand Down
40 changes: 19 additions & 21 deletions api/apps/v1alpha1/nemo_evaluator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ type NemoEvaluatorSpec struct {
GroupID *int64 `json:"groupID,omitempty"`
RuntimeClass string `json:"runtimeClass,omitempty"`

Mongodb *Mongodb `json:"mongodb,omitempty"`
ArgoWorkFlows *ArgoWorkFlows `json:"argoWorkFlows,omitempty"`
Milvus *Milvus `json:"milvus,omitempty"`
DataStore *DataStore `json:"dataStore,omitempty"`
// DatabaseConfig stores the database configuration for NEMO entitystore.
// Required, must not be nil.
//
// +kubebuilder:validation:Required
DatabaseConfig *DatabaseConfig `json:"databaseConfig,omitempty"`
ArgoWorkFlows *ArgoWorkFlows `json:"argoWorkFlows,omitempty"`
Milvus *Milvus `json:"milvus,omitempty"`
DataStore *DataStore `json:"dataStore,omitempty"`
}

// NemoEvaluatorStatus defines the observed state of NemoEvaluator
Expand Down Expand Up @@ -156,12 +160,19 @@ func (n *NemoEvaluator) GetStandardEnv() []corev1.EnvVar {
Value: "7331",
},
{
Name: "DATABASE_URI",
Value: n.Spec.Mongodb.Endpoint,
Name: "POSTGRES_DB_PASSWORD",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
Key: n.Spec.DatabaseConfig.Credentials.PasswordKey,
LocalObjectReference: corev1.LocalObjectReference{
Name: n.Spec.DatabaseConfig.Credentials.SecretName,
},
},
},
},
{
Name: "DATABASE_NAME",
Value: "evaluations",
Name: "POSTGRES_URI",
Value: fmt.Sprintf("postgresql://%s:$(POSTGRES_DB_PASSWORD)@%s:%d/%s", n.Spec.DatabaseConfig.Credentials.User, n.Spec.DatabaseConfig.Host, n.Spec.DatabaseConfig.Port, n.Spec.DatabaseConfig.DatabaseName),
},
{
Name: "ARGO_HOST",
Expand All @@ -179,19 +190,6 @@ func (n *NemoEvaluator) GetStandardEnv() []corev1.EnvVar {
Name: "DATA_STORE_HOST",
Value: n.Spec.DataStore.Endpoint,
},
{
Name: "DATABASE_USERNAME",
Value: "root",
},
{
Name: "DATABASE_PASSWORD",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
Key: "mongodb-root-password",
LocalObjectReference: corev1.LocalObjectReference{Name: "myrelease-mongodb"},
},
},
},
{
Name: "EVAL_CONTAINER",
Value: n.GetImage(),
Expand Down
23 changes: 4 additions & 19 deletions api/apps/v1alpha1/zz_generated.deepcopy.go

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

6 changes: 3 additions & 3 deletions bundle/manifests/apps.nvidia.com_nemoentitystores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ spec:
type: string
secretName:
description: |-
SecretName is the name of the secret which has the database credentials for the NEMO entitystore user.
SecretName is the name of the secret which has the database credentials for a NEMO service user.
Required, must not be empty.
minLength: 1
type: string
user:
description: |-
User is the non-root username for NEMO EntityStore in the database.
User is the non-root username for a NEMO Service in the database.
Required, must not be empty.
minLength: 1
type: string
Expand All @@ -97,7 +97,7 @@ spec:
type: object
databaseName:
description: |-
DatabaseName is the database name for NEMO EntityStore.
DatabaseName is the database name for a NEMO Service.
Required, must not be empty.
minLength: 1
type: string
Expand Down
68 changes: 61 additions & 7 deletions bundle/manifests/apps.nvidia.com_nemoevaluators.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,65 @@ spec:
required:
- endpoint
type: object
databaseConfig:
description: |-
DatabaseConfig stores the database configuration for NEMO entitystore.
Required, must not be nil.
properties:
credentials:
description: |-
DatabaseCredentials stores the configuration to retrieve the database credentials.
Required, must not be nil.
properties:
passwordKey:
default: password
description: |-
PasswordKey is the name of the key in the `CredentialsSecret` secret for the database credentials.
Defaults to "password".
type: string
secretName:
description: |-
SecretName is the name of the secret which has the database credentials for a NEMO service user.
Required, must not be empty.
minLength: 1
type: string
user:
description: |-
User is the non-root username for a NEMO Service in the database.
Required, must not be empty.
minLength: 1
type: string
required:
- secretName
- user
type: object
databaseName:
description: |-
DatabaseName is the database name for a NEMO Service.
Required, must not be empty.
minLength: 1
type: string
host:
description: |-
Host is the hostname of the database.
Required, must not be empty.
minLength: 1
type: string
port:
default: 5432
description: |-
Port is the port where the database is reachable at.
If specified, this must be a valid port number, 0 < databasePort < 65536.
Defaults to 5432.
format: int32
maximum: 65535
minimum: 1
type: integer
required:
- credentials
- databaseName
- host
type: object
env:
items:
description: EnvVar represents an environment variable present in
Expand Down Expand Up @@ -725,13 +784,6 @@ spec:
required:
- endpoint
type: object
mongodb:
properties:
endpoint:
type: string
required:
- endpoint
type: object
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -2126,6 +2178,8 @@ spec:
userID:
format: int64
type: integer
required:
- databaseConfig
type: object
status:
description: NemoEvaluatorStatus defines the observed state of NemoEvaluator
Expand Down
6 changes: 3 additions & 3 deletions config/crd/bases/apps.nvidia.com_nemoentitystores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ spec:
type: string
secretName:
description: |-
SecretName is the name of the secret which has the database credentials for the NEMO entitystore user.
SecretName is the name of the secret which has the database credentials for a NEMO service user.
Required, must not be empty.
minLength: 1
type: string
user:
description: |-
User is the non-root username for NEMO EntityStore in the database.
User is the non-root username for a NEMO Service in the database.
Required, must not be empty.
minLength: 1
type: string
Expand All @@ -97,7 +97,7 @@ spec:
type: object
databaseName:
description: |-
DatabaseName is the database name for NEMO EntityStore.
DatabaseName is the database name for a NEMO Service.
Required, must not be empty.
minLength: 1
type: string
Expand Down
Loading

0 comments on commit 70dfee2

Please sign in to comment.