clarifai-python icon indicating copy to clipboard operation
clarifai-python copied to clipboard

PR-323 Unit tests for toolkits.

Open mogith-pn opened this issue 8 months ago β€’ 1 comments

Why

  • Current tests workflow in the SDK covers all the functionality and basic tests to simulate the upload model and run model, but we needed an integrated unit tests for each toolkit for model upload.

How

  • This pull request introduces a new workflow for maintainer-specific tests, adds support for a vLLM-based OpenAI-compatible server, and implements end-to-end testing for model uploads using dummy configurations. Key changes include the addition of a GitHub Actions workflow, a new model class for vLLM integration, configuration and dependency files, and comprehensive test cases.
  • Workflow and Testing Enhancements: .github/workflows/maintainer_tests.yml: Added a new GitHub Actions workflow for maintainer-specific tests, triggered manually via workflow_dispatch. This workflow sets up Python 3.11, installs dependencies, and runs tests marked with the maintainer_approval marker.
  • vLLM Model Integration: tests/runners/dummy_vllm_models/1/model.py: Introduced the VllmFacebookOpt125M model class, which integrates with a vLLM-based OpenAI-compatible server. The class includes methods to load the model and perform predictions. A utility function, vllm_openai_server, was added to start the server with configurable parameters.
  • Configuration and Dependencies: tests/runners/dummy_vllm_models/config.yaml: Added a configuration file specifying model metadata, build information, and inference compute requirements, including Hugging Face checkpoints. tests/runners/dummy_vllm_models/requirements.txt: Added dependencies for the vLLM server and related libraries, including torch, transformers, and clarifai.
  • End-to-End Testing: tests/runners/test_vllm_model_upload.py: Added end-to-end tests for the model upload flow. Tests include creating a temporary Clarifai app, validating configurations, uploading a model version, and cleaning up resources. Fixtures were added for reusable test setup.

Tests

  • Tested locally with the changes.

mogith-pn avatar Jun 23 '25 13:06 mogith-pn

I personally like the maintainer-approved label. Wonder what @luv-bansal @zeiler think about it.

ackizilkale avatar Jul 02 '25 18:07 ackizilkale

not sure what you mean but @luv-bansal you're reviewing this one right?

zeiler avatar Jul 05 '25 15:07 zeiler

not sure what you mean but @luv-bansal you're reviewing this one right?

@zeiler - We have introduced a term maintainer-approved from this PR. It mocks the model upload with vLLM toolkit. We wrote this tests to catch any errors due to SDK version. Since this test is a heavy and takes some time to run, it was made to run only after adding the label maintainer-approved. This is done by some open-source repositories. So after initial commits and PR approval this label can be added by any one of member from clarifai-org and then it triggers this tests.

mogith-pn avatar Jul 08 '25 12:07 mogith-pn

Code Coverage

Package Line Rate Health
clarifai 43% ❌
clarifai.cli 42% ❌
clarifai.cli.templates 28% ❌
clarifai.client 69% βž–
clarifai.client.auth 66% βž–
clarifai.constants 100% βœ”
clarifai.datasets 100% βœ”
clarifai.datasets.export 80% βœ”
clarifai.datasets.upload 75% βž–
clarifai.datasets.upload.loaders 37% ❌
clarifai.models 100% βœ”
clarifai.modules 0% ❌
clarifai.rag 72% βž–
clarifai.runners 12% ❌
clarifai.runners.models 59% βž–
clarifai.runners.pipeline_steps 45% ❌
clarifai.runners.pipelines 85% βœ”
clarifai.runners.utils 62% βž–
clarifai.runners.utils.data_types 72% βž–
clarifai.schema 100% βœ”
clarifai.urls 60% βž–
clarifai.utils 56% βž–
clarifai.utils.evaluation 67% βž–
clarifai.workflows 95% βœ”
Summary 62% (7347 / 11809) βž–

Minimum allowed line rate is 50%

github-actions[bot] avatar Jul 17 '25 09:07 github-actions[bot]