Skip to content

Dynamic platform detection for ImageSpec to support cross-platform development - #3315

Merged
pingsutw merged 4 commits into
flyteorg:masterfrom
BarryWu0812:#6565
Aug 27, 2025
Merged

Dynamic platform detection for ImageSpec to support cross-platform development#3315
pingsutw merged 4 commits into
flyteorg:masterfrom
BarryWu0812:#6565

Conversation

@BarryWu0812

@BarryWu0812 BarryWu0812 commented Aug 15, 2025

Copy link
Copy Markdown
Contributor

Tracking issue

Closes flyteorg/flyte#6565

Why are the changes needed?

The ImageSpec should automatically detect the current machine's architecture and set an appropriate default platform:
"linux/arm64" for Apple Silicon Macs (ARM64)
"linux/amd64" for Intel Macs (x86_64)

What changes were proposed in this pull request?

Use platform.machine() to detect the current machine's architecture

How was this patch tested?

Unit test

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Summary by Bito

This pull request enhances the ImageSpec class with dynamic platform detection, automatically configuring the default platform based on the machine's architecture for both Apple Silicon and Intel Macs. This improvement boosts cross-platform usability for developers in varied environments. Additionally, the platform parameter has been made optional to facilitate this functionality.

…velopment

Signed-off-by: Barry Wu <a0987818905@gmail.com>
@codecov

codecov Bot commented Aug 15, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.42%. Comparing base (eb5a67f) to head (38ecf5c).
⚠️ Report is 1 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (eb5a67f) and HEAD (38ecf5c). Click for more details.

HEAD has 93 uploads less than BASE
Flag BASE (eb5a67f) HEAD (38ecf5c)
100 7
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3315      +/-   ##
==========================================
- Coverage   85.26%   79.42%   -5.84%     
==========================================
  Files         386      215     -171     
  Lines       30276    22520    -7756     
  Branches     2969     2951      -18     
==========================================
- Hits        25814    17886    -7928     
- Misses       3615     3806     +191     
+ Partials      847      828      -19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread flytekit/image_spec/image_spec.py Outdated
@machichima

Copy link
Copy Markdown
Member

I recommend using field(default_factory=...) for defining default value for platform

platform: str = field(default_factory=_get_default_platform)

the get default platform function can be like:

  def _get_default_platform():
      import platform
      machine = platform.machine().lower()
      if machine in ("arm64", "aarch64"):
          return "linux/arm64"
      return "linux/amd64"

…registry on ARM64 machine

Signed-off-by: Barry Wu <a0987818905@gmail.com>
@BarryWu0812
BarryWu0812 requested a review from machichima August 17, 2025 14:56
Comment thread flytekit/image_spec/image_spec.py
Comment thread flytekit/image_spec/image_spec.py
@BarryWu0812
BarryWu0812 requested a review from machichima August 18, 2025 07:53
Signed-off-by: Barry Wu <a0987818905@gmail.com>
machichima
machichima previously approved these changes Aug 18, 2025

@machichima machichima left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

cc @pingsutw

@pingsutw pingsutw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, there is a lint error, could you take a look

Signed-off-by: Barry Wu <a0987818905@gmail.com>

@machichima machichima left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@pingsutw
pingsutw merged commit 12ce1b9 into flyteorg:master Aug 27, 2025
251 of 257 checks passed
@welcome

welcome Bot commented Aug 27, 2025

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉

Atharva1723 pushed a commit to Atharva1723/flytekit that referenced this pull request Oct 5, 2025
…velopment (flyteorg#3315)

Signed-off-by: Barry Wu <a0987818905@gmail.com>
Signed-off-by: Atharva <atharvakulkarni172003@gmail.com>
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.

[Core feature] Dynamic platform detection for ImageSpec to support cross-platform development

3 participants