Skip to content

Add clarifai model init CLI command #611

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

Merged
merged 7 commits into from
May 30, 2025
Merged

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 29, 2025

This PR implements the clarifai model init CLI command to help users quickly scaffold new model projects with the proper directory structure and template files.

Features

The new command creates the following structure in the specified directory:

├── 1/
│   └── model.py
├── requirements.txt
└── config.yaml

Usage

# Initialize in current directory with default ModelClass
clarifai model init

# Initialize in specific path
clarifai model init /path/to/my-model

# Initialize with MCP model type
clarifai model init --model-type-id mcp

# Initialize with OpenAI model type  
clarifai model init --model-type-id openai

Model Type Support

  • Default: Uses ModelClass for general-purpose models
  • MCP: Uses MCPModelClass with FastMCP server template including tools, resources, and prompts
  • OpenAI: Uses OpenAIModelClass for OpenAI-compatible API wrappers

Template Features

  • TODO Comments: All templates include # TODO: please fill in comments for easy discovery with grep
  • Latest SDK Version: requirements.txt automatically includes the current clarifai SDK version (11.4.7)
  • Proper Configuration: config.yaml is pre-configured with the appropriate model_type_id
  • File Protection: Won't overwrite existing files, shows warnings instead
  • Comprehensive Examples: Each template includes example implementations and best practices

User Guidance

After initialization, users get clear next steps:

  1. Search for TODO comments in generated files
  2. Update model configuration in config.yaml
  3. Add model dependencies to requirements.txt
  4. Implement model logic in 1/model.py

This significantly reduces the friction for users to get started with custom Clarifai models by providing proper scaffolding and guidance.

Fixes #610.

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:

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: zeiler <2138258+zeiler@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Add clarifai model init to CLI Add clarifai model init CLI command May 29, 2025
@Copilot Copilot AI requested a review from zeiler May 29, 2025 14:22
Copilot finished work on behalf of zeiler May 29, 2025 14:22
Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>
Copilot finished work on behalf of srikanthbachala20 May 29, 2025 14:39
zeiler
zeiler previously requested changes May 30, 2025
… add accelerator requests, remove unsupported checkpoint types

Co-authored-by: zeiler <2138258+zeiler@users.noreply.github.com>
Copilot finished work on behalf of zeiler May 30, 2025 04:40
@srikanthbachala20 srikanthbachala20 requested a review from Copilot May 30, 2025 12:12
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the CLI command "init" to quickly scaffold new model projects with the proper directory structure and template files.

  • Added model scaffolding templates for default, MCP, and OpenAI model types.
  • Extended the CLI to generate model.py, requirements.txt, and config.yaml files based on user input.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
clarifai/cli/model_templates.py Added templates for default, MCP, and OpenAI model types.
clarifai/cli/model.py Introduced the "init" CLI command to scaffold model projects.

@srikanthbachala20
Copy link
Contributor

Lint the code as per .ruff.toml guidelines

Co-authored-by: srikanthbachala20 <170492893+srikanthbachala20@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented May 30, 2025

Lint the code as per .ruff.toml guidelines

Linted the code according to the .ruff.toml guidelines in commit b23849a. Fixed whitespace issues in blank lines and added missing newline at the end of file.

Copilot finished work on behalf of srikanthbachala20 May 30, 2025 12:23
Copy link

Code Coverage

Package Line Rate Health
clarifai 43%
clarifai.cli 41%
clarifai.client 71%
clarifai.client.auth 74%
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 61%
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 94%
Summary 65% (6368 / 9732)

Minimum allowed line rate is 50%

@srikanthbachala20 srikanthbachala20 marked this pull request as ready for review May 30, 2025 13:00
@Clarifai Clarifai deleted a comment from Copilot AI May 30, 2025
@srikanthbachala20 srikanthbachala20 dismissed zeiler’s stale review May 30, 2025 15:04

The requested changes were resolved but still this is obstructing PR merge

@srikanthbachala20 srikanthbachala20 merged commit 2ba02f7 into master May 30, 2025
14 of 15 checks passed
@srikanthbachala20 srikanthbachala20 deleted the copilot/fix-610 branch May 30, 2025 15:04
@srikanthbachala20 srikanthbachala20 mentioned this pull request May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Add clarifai model init to CLI
4 participants