Skip to content

Conversation

@ruivieira
Copy link
Member

@ruivieira ruivieira commented Jul 30, 2025

Summary by Sourcery

Add support for an OCI subject in LMEvalJob outputs by extending the OCISpec type, updating the CRD schema, injecting the OCI_SUBJECT env var in pods, and adding a corresponding unit test

New Features:

  • Introduce Subject field in OCISpec to allow specifying OCI artifact subjects
  • Expose OCI_SUBJECT environment variable in pods when a Subject is provided

Documentation:

  • Update CRD schema and documentation to include the optional Subject property

Tests:

  • Add unit test to verify OCI_SUBJECT environment variable is correctly set

@ruivieira ruivieira self-assigned this Jul 30, 2025
@ruivieira ruivieira added kind/enhancement New feature or request lm-eval Issues related to LM-Eval labels Jul 30, 2025
@openshift-ci
Copy link

openshift-ci bot commented Jul 30, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ruivieira
Copy link
Member Author

@sourcery-ai review

@ruivieira ruivieira requested a review from tarilabs July 30, 2025 00:40
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jul 30, 2025

Reviewer's Guide

This PR introduces a new optional “Subject” field to the OCISpec of LMEvalJob, updating the API type, CRD schema, pod‐creation logic to include OCI_SUBJECT when provided, and adds a corresponding unit test.

Class diagram for updated OCISpec with Subject field

classDiagram
    class OCISpec {
        string path
        string subject
        corev1.SecretKeySelector* username
        corev1.SecretKeySelector* password
        string tag
        // ... other fields
    }
Loading

File-Level Changes

Change Details Files
Define Subject field in OCISpec with validation
  • Added Subject string field to OCISpec struct with JSON tags and validation pattern
  • Extended CRD YAML schema to include subject description, pattern, and optionality
api/lmes/v1alpha1/lmevaljob_types.go
config/crd/bases/trustyai.opendatahub.io_lmevaljobs.yaml
Inject OCI_SUBJECT env var during pod creation
  • Appended OCI_SUBJECT environment variable when Subject is non-empty in CreatePod
controllers/lmes/lmevaljob_controller.go
Add unit test for OCI_SUBJECT support
  • Introduced OCIWithSubject subtest to verify OCI_SUBJECT is set in the pod’s envVars
controllers/lmes/lmevaljob_controller_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ruivieira - I've reviewed your changes - here's some feedback:

  • Add a nil-check for job.Spec.Outputs and OCISpec before accessing Subject to avoid a potential runtime panic when OCISpec is not provided.
  • The CRD’s validation pattern for Subject is very generic and only allows uppercase letters; consider tightening it (e.g. matching sha256:[a-f0-9]{64}) or at least allowing lowercase to match typical OCI digest formats.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add a nil-check for job.Spec.Outputs and OCISpec before accessing Subject to avoid a potential runtime panic when OCISpec is not provided.
- The CRD’s validation pattern for Subject is very generic and only allows uppercase letters; consider tightening it (e.g. matching sha256:[a-f0-9]{64}) or at least allowing lowercase to match typical OCI digest formats.

## Individual Comments

### Comment 1
<location> `controllers/lmes/lmevaljob_controller_test.go:4011` </location>
<code_context>
+	t.Run("OCIWithSubject", func(t *testing.T) {
</code_context>

<issue_to_address>
Consider adding negative and edge case tests for OCI_SUBJECT.

Please add tests for cases where the Subject field is omitted, empty, or contains special/invalid characters, to ensure OCI_SUBJECT is handled correctly in all scenarios.

Suggested implementation:

```golang
	t.Run("OCIWithSubject", func(t *testing.T) {
		job := &lmesv1alpha1.LMEvalJob{
			ObjectMeta: v1.ObjectMeta{
				Name:      "test-oci-subject",
				Namespace: "default",
			},
			Spec: lmesv1alpha1.LMEvalJobSpec{
				Model: "test",
				TaskList: lmesv1alpha1.TaskList{
					TaskNames: []string{"task1"},
				},
			},
			// Add a valid subject
			Subject: "valid-subject-123",
		}
		// ... existing test logic for valid subject ...
	})

	t.Run("OCIWithSubjectOmitted", func(t *testing.T) {
		job := &lmesv1alpha1.LMEvalJob{
			ObjectMeta: v1.ObjectMeta{
				Name:      "test-oci-subject-omitted",
				Namespace: "default",
			},
			Spec: lmesv1alpha1.LMEvalJobSpec{
				Model: "test",
				TaskList: lmesv1alpha1.TaskList{
					TaskNames: []string{"task1"},
				},
			},
			// Subject field omitted
		}
		// ... test logic to assert OCI_SUBJECT is handled as expected when omitted ...
	})

	t.Run("OCIWithSubjectEmpty", func(t *testing.T) {
		job := &lmesv1alpha1.LMEvalJob{
			ObjectMeta: v1.ObjectMeta{
				Name:      "test-oci-subject-empty",
				Namespace: "default",
			},
			Spec: lmesv1alpha1.LMEvalJobSpec{
				Model: "test",
				TaskList: lmesv1alpha1.TaskList{
					TaskNames: []string{"task1"},
				},
			},
			Subject: "",
		}
		// ... test logic to assert OCI_SUBJECT is handled as expected when empty ...
	})

	t.Run("OCIWithSubjectSpecialChars", func(t *testing.T) {
		job := &lmesv1alpha1.LMEvalJob{
			ObjectMeta: v1.ObjectMeta{
				Name:      "test-oci-subject-special",
				Namespace: "default",
			},
			Spec: lmesv1alpha1.LMEvalJobSpec{
				Model: "test",
				TaskList: lmesv1alpha1.TaskList{
					TaskNames: []string{"task1"},
				},
			},
			Subject: "!@#$%^&*()_+|~=`{}[]:\";'<>?,./",
		}
		// ... test logic to assert OCI_SUBJECT is handled as expected with special/invalid characters ...
	})

```

You will need to fill in the test logic for each new test case to assert the correct handling of the `OCI_SUBJECT` environment variable (e.g., check if it is set, unset, or sanitized as appropriate for your application). If there is a helper function or assertion pattern used in the original "OCIWithSubject" test, reuse it for consistency.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

@tarilabs tarilabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks a lot @ruivieira ! One comment below:
otherwise
/lgtm

@github-actions
Copy link

PR image build and manifest generation completed successfully!

📦 PR image: quay.io/trustyai/trustyai-service-operator-ci:d82331f9cbd3e959a866d5f06e768f2b621f3bbb

📦 LMES driver image: quay.io/trustyai/ta-lmes-driver-ci:d82331f9cbd3e959a866d5f06e768f2b621f3bbb

📦 LMES job image: quay.io/trustyai/ta-lmes-job-ci:d82331f9cbd3e959a866d5f06e768f2b621f3bbb

📦 Guardrails orchestrator image: quay.io/trustyai/ta-guardrails-orchestrator-ci:d82331f9cbd3e959a866d5f06e768f2b621f3bbb

🗂️ CI manifests

      devFlags:
        manifests:
          - contextDir: config
            sourcePath: ''
            uri: https://api.github.com/repos/trustyai-explainability/trustyai-service-operator-ci/tarball/operator-d82331f9cbd3e959a866d5f06e768f2b621f3bbb

@ruivieira ruivieira merged commit 33463bc into trustyai-explainability:dev/oci Jul 30, 2025
3 of 5 checks passed
tarilabs pushed a commit to tarilabs/trustyai-service-operator that referenced this pull request Sep 17, 2025
…y#530)

* feat: Add subject to LMEval CRD's OCI outputs

* chore: Add more test cases
tarilabs pushed a commit to tarilabs/trustyai-service-operator that referenced this pull request Nov 18, 2025
…y#530)

* feat: Add subject to LMEval CRD's OCI outputs

* chore: Add more test cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or request lgtm lm-eval Issues related to LM-Eval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants