Use Configuration contexts in Model Upload CLI
The Model Upload CLI (clarifai model upload .) now uses Configuration contexts instead of relying solely on environment variables like CLARIFAI_PAT.
Problem
Previously, the model upload command required users to set environment variables directly:
export CLARIFAI_PAT="your-token"
clarifai model upload .
This approach was inconsistent with other CLI commands like clarifai model local-dev which properly use the configuration context system.
Solution
The upload command now integrates with the configuration context system:
# Set up configuration context (one time)
clarifai config use-context production
# Upload using context (no env vars needed)
clarifai model upload .
Changes Made
-
CLI Integration: Added
@click.pass_contextandvalidate_context(ctx)to the upload command -
Context Parameter Passing: Upload command now passes
ctx.obj.current.patandctx.obj.current.api_baseto the backend -
ModelBuilder Enhancement: Added optional
patandbase_urlparameters to constructor - Smart Authentication: Uses context parameters when provided, falls back to environment variables for backward compatibility
Backward Compatibility
β Fully maintained - existing code using environment variables continues to work unchanged:
# Still works for backward compatibility
export CLARIFAI_PAT="your-token"
clarifai model upload .
Testing
- β Context parameter usage verification
- β Backward compatibility with environment variables
- β CLI integration testing
- β Error handling and validation
- β
Other ModelBuilder commands (
download-checkpoints,signatures) remain unaffected
Fixes #648.
[!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:
samples.clarifai.com
- Triggering command:
python -m pytest tests/REDACTEDs/test_model_signatures.py -xvs --tb=short(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
π¬ Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.
| Package | Line Rate | Health |
|---|---|---|
| clarifai | 43% | β |
| clarifai.cli | 45% | β |
| 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 | 61% | β |
| clarifai.runners.utils.data_types | 72% | β |
| clarifai.schema | 100% | β |
| clarifai.urls | 58% | β |
| clarifai.utils | 73% | β |
| clarifai.utils.evaluation | 67% | β |
| clarifai.workflows | 95% | β |
| Summary | 62% (6955 / 11130) | β |
Minimum allowed line rate is 50%
looks good to me.