Skip to content

Commit

Permalink
Fixing MLX tests (making it optional/skipped unfortunately).
Browse files Browse the repository at this point in the history
  • Loading branch information
Narsil committed Jul 30, 2024
1 parent 0e355da commit 10ebfca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
shell: bash

- name: Install (mlx)
if: (matrix.os == 'macos-latest' || matrix.os == 'macos-13') && matrix.version.python == '3.11'
if: matrix.os == 'macos-latest'
run: |
pip install .[mlx]
shell: bash
Expand Down
11 changes: 9 additions & 2 deletions bindings/python/tests/test_mlx_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@
import unittest


HAS_MLX = True
if platform.system() == "Darwin":
# This platform is not supported, we don't want to crash on import
# This test will be skipped anyway.
import mlx.core as mx
try:
import mlx.core as mx
except ImportError:
HAS_MLX = False
from safetensors import safe_open
from safetensors.mlx import load_file, save_file
else:
HAS_MLX = False


# MLX only exists on Mac
@unittest.skipIf(platform.system() != "Darwin", "Mlx is not available on non Mac")
@unittest.skipIf(not HAS_MLX, "Mlx is not available.")
class LoadTestCase(unittest.TestCase):
def setUp(self):
data = {
Expand All @@ -26,7 +33,7 @@ def setUp(self):
self.mlx_filename = "./tests/data/mlx_load.npz"
self.sf_filename = "./tests/data/mlx_load.safetensors"

serialized = mx.savez(self.mlx_filename, **data)
mx.savez(self.mlx_filename, **data)
save_file(data, self.sf_filename)

def test_zero_sized(self):
Expand Down

0 comments on commit 10ebfca

Please sign in to comment.