Skip to content

RHOAIENG-26843, RHOAIENG-26066: tests: add scikit-learn smoke test #1171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jiridanek
Copy link
Member

@jiridanek jiridanek commented Jun 19, 2025

Description

Adds a smoke test to tests/containers/workbenches/jupyterlab/jupyterlab_test.py to verify basic scikit-learn functionality. This test is intended to catch regressions in scikit-learn that might occur due to package updates, such as the one in #1126.

The test:

  • Starts a JupyterLab container.
  • Creates and runs a Python script within the container that:
    • Imports sklearn and numpy.
    • Trains a simple LogisticRegression model on a small sample dataset.
    • Makes a prediction and asserts its correctness.
    • Prints a success message.
  • Asserts that the script executes successfully (exit code 0) and the success message is present in the output.

How Has This Been Tested?

The new test test_sklearn_smoke was added to the existing pytest suite. Due to sandbox limitations preventing access to the Docker daemon, the test could not be fully run to completion in the development environment. However, the test logic is standard and relies on the existing WorkbenchContainer infrastructure. It is expected to pass in the CI environment where Docker is available.

The following dependencies were installed to attempt local execution: pytest<8, pytest-subtests, testcontainers, docker, pandas-stubs, types-requests, types-setuptools, allure-pytest, python-on-whales, podman.

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work (to the extent possible within sandbox limitations; CI will provide full validation).

Summary by CodeRabbit

  • Tests
    • Added a new test to verify basic scikit-learn functionality within the JupyterLab container, ensuring correct model training and prediction.

Adds a smoke test to verify basic scikit-learn functionality
in JupyterLab images.

This test trains a simple Logistic Regression model and checks
predictions to ensure the scikit-learn installation is working
correctly after package updates.
Copy link
Contributor

coderabbitai bot commented Jun 19, 2025

Walkthrough

A new test method was added to the JupyterLab container image test suite that runs a Python script inside the container to train and predict with a logistic regression model using scikit-learn. The test verifies the output and ensures the container lifecycle is handled properly.

Changes

File(s) Change Summary
tests/containers/workbenches/jupyterlab/jupyterlab_test.py Added test_sklearn_smoke method to run a scikit-learn logistic regression script inside the container and verify its output.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35cd2bb and a964b72.

📒 Files selected for processing (1)
  • tests/containers/workbenches/jupyterlab/jupyterlab_test.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/containers/workbenches/jupyterlab/jupyterlab_test.py
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: check-generated-code
  • GitHub Check: pytest-tests
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@openshift-ci openshift-ci bot requested review from caponetto and jstourac June 19, 2025 08:14
@jiridanek jiridanek changed the title feat: Add scikit-learn smoke test feat: add scikit-learn smoke test Jun 19, 2025
Copy link
Contributor

openshift-ci bot commented Jun 19, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign paulovmr for approval. For more information see the Code Review Process.

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

@openshift-ci openshift-ci bot added size/m and removed size/m labels Jun 19, 2025
@jiridanek jiridanek changed the title feat: add scikit-learn smoke test RHOAIENG-26843, RHOAIENG-26066: tests: add scikit-learn smoke test Jun 19, 2025
@openshift-ci openshift-ci bot added size/m and removed size/m labels Jun 19, 2025
@openshift-ci openshift-ci bot added size/m and removed size/m labels Jun 19, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/containers/workbenches/jupyterlab/jupyterlab_test.py (1)

118-118: Fix inline comment formatting.

Static analysis detected spacing issues with inline comments.

-    @allure.issue("RHOAIENG-27131") # Assuming a new issue number for this test
+    @allure.issue("RHOAIENG-27131")  # Assuming a new issue number for this test
-            print(f"Script output:\n{output_str}") # For debugging
+            print(f"Script output:\n{output_str}")  # For debugging

Also applies to: 163-163

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ca4289 and b62c796.

📒 Files selected for processing (1)
  • tests/containers/workbenches/jupyterlab/jupyterlab_test.py (1 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
tests/containers/workbenches/jupyterlab/jupyterlab_test.py

118-118: Insert at least two spaces before an inline comment

Insert spaces

(E261)


163-163: Insert at least two spaces before an inline comment

Insert spaces

(E261)

🔇 Additional comments (3)
tests/containers/workbenches/jupyterlab/jupyterlab_test.py (3)

122-143: Well-designed smoke test script.

The scikit-learn test script is well-structured with appropriate assertions and covers the essential functionality: importing libraries, training a model, making predictions, and verifying results.


120-170: Excellent implementation following established patterns.

The test method follows the same robust pattern as other tests in the class:

  • Proper container lifecycle management with try/finally
  • Appropriate use of temporary directories for file handling
  • Comprehensive output verification with both exit code and content checks
  • Clean integration with the existing test infrastructure

The smoke test will effectively detect regressions in scikit-learn functionality as intended.


118-118: Verify the Allure issue number.

The comment indicates this is an assumed issue number. Ensure the correct issue number is used before merging.

@jstourac
Copy link
Member

So, the ruff is unhappy, but otherwise this LGTM.

@jiridanek
Copy link
Member Author

I have the fix locally; looking at the code, imo it's very wrong... will have to make manual changes

@jiridanek
Copy link
Member Author

eh, never mind, it's not as bad as I thought (it must've improved copyting the script when I was asking for changes...) ok... still want to work on it a bit myself

@openshift-ci openshift-ci bot added size/m and removed size/m labels Jun 19, 2025
@jiridanek jiridanek added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jun 19, 2025
@openshift-ci openshift-ci bot added size/m and removed size/m labels Jun 19, 2025
@openshift-ci openshift-ci bot added size/m and removed size/m labels Jun 19, 2025
@jiridanek
Copy link
Member Author

currently fails on some images because not everything contains sklearn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/m tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants