EAGLE-6325 Add pipeline run CLI similar to model predict
Summary
This PR implements a new pipeline run CLI command that enables users to run pipelines through the command line and monitor their progress with real-time log streaming, similar to the existing model predict functionality.
Changes Made
π― New CLI Commands
- Added
clarifai pipeline runandclarifai pl runcommands - Supports both pipeline ID/user ID/app ID parameters and pipeline URL
- Configurable timeout (default 1 hour) and monitoring interval (default 10 seconds)
- Config file support for all parameters
π CLI Options
--config PATH Path to the pipeline run config file
--pipeline_id TEXT Pipeline ID to run
--pipeline_version_id TEXT Pipeline Version ID to run
--user_id TEXT User ID of the pipeline
--app_id TEXT App ID that contains the pipeline
--pipeline_url TEXT Pipeline URL to run
--timeout INTEGER Maximum time to wait (default 3600s)
--monitor_interval INTEGER Status check interval (default 10s)
π§ Pipeline Client Implementation
- Created new
clarifai.client.pipeline.Pipelineclass following existing patterns - Implements pipeline execution using
PostPipelineVersionRunsAPI - Real-time monitoring with
GetPipelineVersionRunAPI - Log streaming using
ListLogEntriesAPI - Proper error handling and timeout management
π Monitoring Features
- Real-time log display during pipeline execution
- Progress monitoring with status updates every 10 seconds (configurable)
- Timeout handling with user-friendly error messages
- Follows same patterns as
_monitor_pipeline_step_build
Usage Examples
# Run with pipeline IDs
clarifai pipeline run --pipeline_id my-pipeline --user_id my-user --app_id my-app
# Run with pipeline URL
clarifai pl run --pipeline_url https://clarifai.com/user/app/pipelines/my-pipeline
# Run with config file
clarifai pipeline run --config pipeline_run_config.yaml
# Run with custom timeout and monitoring
clarifai pl run --pipeline_url URL --timeout 1800 --monitor_interval 5
Testing
- β Added comprehensive unit tests for CLI commands (3 new test cases)
- β All existing pipeline tests continue to pass (47 total tests)
- β Mock-based testing for pipeline client functionality
- β Error handling and validation testing
- β Code formatting and linting compliance
Files Modified
-
clarifai/cli/pipeline.py- Added run command implementation -
clarifai/client/__init__.py- Added Pipeline to exports -
clarifai/client/pipeline.py- New Pipeline client class -
tests/cli/test_pipeline.py- Added CLI tests for run command -
tests/test_pipeline_client.py- New client tests
The implementation follows the same patterns as the existing model predict command and integrates seamlessly with the existing CLI infrastructure.
Fixes #643.
π¬ Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.
[!WARNING]
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
api.clarifai.com
- Triggering command:
python /tmp/test_error.py(dns block)If you need me to access, download, or install something from one of these locations, you can either:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
| Package | Line Rate | Health |
|---|---|---|
| clarifai | 43% | β |
| clarifai.cli | 46% | β |
| 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 | 58% | β |
| clarifai.runners.pipeline_steps | 0% | β |
| clarifai.runners.pipelines | 85% | β |
| clarifai.runners.utils | 62% | β |
| clarifai.runners.utils.data_types | 72% | β |
| clarifai.schema | 100% | β |
| clarifai.urls | 58% | β |
| clarifai.utils | 73% | β |
| clarifai.utils.evaluation | 67% | β |
| clarifai.workflows | 95% | β |
| Summary | 63% (7147 / 11392) | β |
Minimum allowed line rate is 50%