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

EAGLE-6325 Add pipeline run CLI similar to model predict

Open Copilot opened this issue 8 months ago β€’ 1 comments

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 run and clarifai pl run commands
  • 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.Pipeline class following existing patterns
  • Implements pipeline execution using PostPipelineVersionRuns API
  • Real-time monitoring with GetPipelineVersionRun API
  • Log streaming using ListLogEntries API
  • 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.

Copilot avatar Jun 24 '25 10:06 Copilot

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:

Copilot avatar Jun 27 '25 06:06 Copilot

Code Coverage

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%

github-actions[bot] avatar Jul 01 '25 12:07 github-actions[bot]