Skip to content

[EAGLE-6930] Add platform specification to config.yaml for model versions#855

Merged
wemoveon2 merged 5 commits intomasterfrom
copilot/add-platform-to-config-yaml
Nov 24, 2025
Merged

[EAGLE-6930] Add platform specification to config.yaml for model versions#855
wemoveon2 merged 5 commits intomasterfrom
copilot/add-platform-to-config-yaml

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 24, 2025

Why

The API now supports specifying target platform(s) for Docker image builds (e.g., linux/amd64,linux/arm64), but the Python SDK didn't expose this capability to users through the config.yaml file.

How

  • Read platform from config.yaml under build_info section
  • Set model_version.build_info.platform in get_model_version_proto() when field exists in protobuf
  • Forward-compatible: logs warning if clarifai-grpc version lacks the field, continues upload normally
  • Updated templates (model, pipeline, pipeline_step) with commented platform examples
  • Validates that platform is not None or empty string before setting

Tests

  • Modified existing test_model_uploader_flow integration test to include platform specification
  • Test adds "linux/amd64,linux/arm64" to build_info in config during test setup
  • Test verifies platform using GetModelVersion API call after upload
  • Code handles both presence and absence of platform field gracefully (forward-compatible)
  • All code passes ruff linting and formatting checks
  • CodeQL security scan passes with 0 alerts

Notes

Example usage:

build_info:
  python_version: "3.12"
  platform: "linux/amd64,linux/arm64"

Requires clarifai-grpc update with BuildInfo.platform field for full functionality. Until then, feature degrades gracefully with warning.

Original prompt

We recently added a new feature to the API to allow users to specify the platform their model image will be built for.

		mvReq := &api.ModelVersion{
			OutputInfo: &api.OutputInfo{Params: params},
			InferenceComputeInfo: &api.ComputeInfo{
				CpuLimit: "500m", CpuRequests: "100m",
				CpuMemory: "500Mi", CpuMemoryRequests: "500Mi",
			},
			PretrainedModelConfig: &api.PretrainedModelConfig{
				InputFieldsMap: &types.Struct{Fields: map[string]*types.Value{
					"text": {Kind: &types.Value_StringValue{StringValue: "text"}},
				}},
				OutputFieldsMap: &types.Struct{Fields: map[string]*types.Value{
					"text": {Kind: &types.Value_StringValue{StringValue: "text"}},
				}},
			},
			BuildInfo: &api.BuildInfo{
				Platform: "linux/amd64,linux/arm64",
			},
		}

Add code to allow users to specify their build platform in the config.yaml during PostModelVersionsUpload

The way to specify is to set model_version.build_info.platform in the *api.PostModelVersionsUploadRequest_UploadConfig


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 24, 2025 18:53
- Read platform from config.yaml build_info section
- Set platform on model_version.build_info when protobuf field is available
- Add forward-compatible code with graceful fallback
- Update templates to include platform example
- Add comprehensive tests for platform configuration

Co-authored-by: wemoveon2 <86081107+wemoveon2@users.noreply.github.com>
- Add clarifying comment for empty string check in platform validation
- Improve test model to actually process input text
- Ensure code quality and maintainability

Co-authored-by: wemoveon2 <86081107+wemoveon2@users.noreply.github.com>
@wemoveon2
Copy link
Copy Markdown
Contributor

@copilot instead of writing new tests, modify an existing test doing PostModelVersionsUpload and add amd and arm to the specifications. confirm the model was built for the platforms with a GetModelVersions request like

		mvRes, err := f.client.GetModelVersion(f.allScopeCtx, getModelVersionReq)
		checkResponseSuccess(t, mvRes, err, "get model version")
		testifai.AssertEqual(t, mvRes.ModelVersion.GetBuildInfo().GetPlatform(), "linux/amd64")

- Remove standalone test_build_info_platform.py test file
- Add platform specification to dummy_models_path fixture
- Add GetModelVersion verification in test_model_uploader_flow
- Verify platform is set to "linux/amd64,linux/arm64"

Co-authored-by: wemoveon2 <86081107+wemoveon2@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 24, 2025

@copilot instead of writing new tests, modify an existing test doing PostModelVersionsUpload and add amd and arm to the specifications. confirm the model was built for the platforms with a GetModelVer...

Done! I've modified the existing test_model_uploader_flow test instead of creating a new test file. The changes include:

  1. Added platform specification ("linux/amd64,linux/arm64") to the build_info in the dummy_models_path fixture
  2. After uploading the model version, added GetModelVersion request to verify the platform was set correctly
  3. Added assertion to confirm the platform matches the expected value
  4. Removed the standalone test_build_info_platform.py file

Changes in commit 3563f2c

Co-authored-by: wemoveon2 <86081107+wemoveon2@users.noreply.github.com>
@wemoveon2 wemoveon2 marked this pull request as ready for review November 24, 2025 21:29
Copilot AI changed the title [WIP] Add platform specification to config.yaml for model versions Add platform specification to config.yaml for model versions Nov 24, 2025
@github-actions
Copy link
Copy Markdown

Code Coverage

Package Line Rate Health
clarifai 45%
clarifai.cli 45%
clarifai.cli.templates 33%
clarifai.client 67%
clarifai.client.auth 67%
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 53%
clarifai.runners.models 62%
clarifai.runners.pipeline_steps 41%
clarifai.runners.pipelines 77%
clarifai.runners.utils 63%
clarifai.runners.utils.data_types 72%
clarifai.schema 100%
clarifai.urls 58%
clarifai.utils 59%
clarifai.utils.evaluation 67%
clarifai.workflows 95%
Summary 62% (8429 / 13568)

Minimum allowed line rate is 50%

@wemoveon2 wemoveon2 enabled auto-merge (squash) November 24, 2025 21:53
@wemoveon2 wemoveon2 merged commit b027816 into master Nov 24, 2025
23 of 24 checks passed
@wemoveon2 wemoveon2 deleted the copilot/add-platform-to-config-yaml branch November 24, 2025 22:15
@wemoveon2 wemoveon2 changed the title Add platform specification to config.yaml for model versions [EAGLE-6930] Add platform specification to config.yaml for model versions Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants