Skip to content

Conversation

@BarryWu0812
Copy link
Contributor

@BarryWu0812 BarryWu0812 commented Aug 15, 2025

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.

@codecov
Copy link

codecov bot commented Aug 15, 2025

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.

@machichima
Copy link
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"

@BarryWu0812 BarryWu0812 requested a review from machichima August 17, 2025 14:56
@BarryWu0812 BarryWu0812 requested a review from machichima August 18, 2025 07:53
machichima
machichima previously approved these changes Aug 18, 2025
Copy link
Member

@machichima machichima left a comment

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

Copy link
Member

@pingsutw pingsutw left a comment

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 <[email protected]>
Copy link
Member

@machichima machichima left a comment

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
Copy link

welcome bot commented Aug 27, 2025

Congrats on merging your first pull request! 🎉

Atharva1723 pushed a commit to Atharva1723/flytekit that referenced this pull request Oct 5, 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.

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

3 participants