Skip to content

Fix missing origin for mlmodelc files#2799

Merged
aaronsky merged 4 commits intobazelbuild:masterfrom
jflan-dd:jflan/coreml-provider-fix
Nov 11, 2025
Merged

Fix missing origin for mlmodelc files#2799
aaronsky merged 4 commits intobazelbuild:masterfrom
jflan-dd:jflan/coreml-provider-fix

Conversation

@jflan-dd
Copy link
Copy Markdown
Contributor

Bundling a .mlmodel file into a resource bundle results in the following error:

	File "/private/var/tmp/_bazel_johnflanagan/a29065da0d532a50315a8974596a3ed4/external/rules_apple+/apple/internal/testing/ios_rules.bzl", line 77, column 60, in _ios_unit_test_bundle_impl
		return apple_test_bundle_support.apple_test_bundle_impl(
	File "/private/var/tmp/_bazel_johnflanagan/a29065da0d532a50315a8974596a3ed4/external/rules_apple+/apple/internal/testing/apple_test_bundle_support.bzl", line 545, column 41, in _apple_test_bundle_impl
		processor_result = processor.process(
	File "/private/var/tmp/_bazel_johnflanagan/a29065da0d532a50315a8974596a3ed4/external/rules_apple+/apple/internal/processor.bzl", line 748, column 36, in _process
		partial_outputs = [partial.call(p) for p in partials]
	File "/private/var/tmp/_bazel_johnflanagan/a29065da0d532a50315a8974596a3ed4/external/bazel_skylib+/lib/partial.bzl", line 43, column 28, in _call
		return partial.function(*function_args, **function_kwargs)
	File "/private/var/tmp/_bazel_johnflanagan/a29065da0d532a50315a8974596a3ed4/external/rules_apple+/apple/internal/partials/resources.bzl", line 299, column 26, in _resources_partial_impl
		resources.deduplicate(
	File "/private/var/tmp/_bazel_johnflanagan/a29065da0d532a50315a8974596a3ed4/external/rules_apple+/apple/internal/resources.bzl", line 997, column 42, in _deduplicate
		deduplicated = _deduplicate_field(
	File "/private/var/tmp/_bazel_johnflanagan/a29065da0d532a50315a8974596a3ed4/external/rules_apple+/apple/internal/resources.bzl", line 942, column 49, in _deduplicate_field
		path_origins = processed_origins[short_path]
Error: key "example.resource_bundle-intermediates/Example_Resources.bundle/FastViTT8F16.mlmodelc" not found in dictionary

I made an example repo to demonstrate the issue here:
https://github.com/jflan-dd/coreml-FastViT-T8

This fix adds the .mlmodel to .mlmodelc mapping to processed_origins

@mattrobmattrob
Copy link
Copy Markdown
Contributor

Thanks for the fix, @jflan-dd. Is there any addition to this relatively simple test that could help with this regressing in the future?

apple_core_ml_library(
name = "SampleCoreML",
mlmodel = "@build_bazel_rules_apple//test/testdata/resources:sample.mlpackage",
)
swift_apple_core_ml_library(
name = "SampleSwiftCoreML",
mlmodel = "@build_bazel_rules_apple//test/testdata/resources:sample.mlpackage",
)

@jflan-dd
Copy link
Copy Markdown
Contributor Author

@mattrobmattrob I'll try and get the tests updated tomorrow

@jflan-dd
Copy link
Copy Markdown
Contributor Author

I added a test. I'm new to writing tests for Bazel. I'm very open to nitpick-y feedback.

@aaronsky aaronsky enabled auto-merge (squash) October 30, 2025 10:46
@aaronsky aaronsky merged commit 99515aa into bazelbuild:master Nov 11, 2025
8 checks passed
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