From 7101b3dde3dc244d51d22249900ef1d1645cf050 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Tue, 2 Jul 2024 14:22:00 +0200 Subject: [PATCH 01/42] CI run every wednesday instead of everyday --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f2a61a1..3c053e1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,8 +11,8 @@ on: branches: - main schedule: - # Run every day at 7:42am UTC. - - cron: '42 7 * * *' + # Run wednesday at 7:42am UTC. + - cron: '42 8 * * wed' jobs: benchopt_dev: From 07d07e4081ff4e29135780bc20f2e7d833387fac Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 3 Jul 2024 13:46:11 +0200 Subject: [PATCH 02/42] try older numpy --- solvers/snapml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solvers/snapml.py b/solvers/snapml.py index 3048629..9122f7f 100644 --- a/solvers/snapml.py +++ b/solvers/snapml.py @@ -11,7 +11,7 @@ class Solver(BaseSolver): name = "snapml" install_cmd = "conda" - requirements = ["pip:snapml"] + requirements = ["pip:snapml","numpy<2"] parameters = {"gpu": [False, True]} references = [ From a3890e430b714653b6bb8984b23aafc0f6ee1bc3 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 3 Jul 2024 13:54:17 +0200 Subject: [PATCH 03/42] typo --- solvers/snapml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solvers/snapml.py b/solvers/snapml.py index 9122f7f..89a7ee6 100644 --- a/solvers/snapml.py +++ b/solvers/snapml.py @@ -11,7 +11,7 @@ class Solver(BaseSolver): name = "snapml" install_cmd = "conda" - requirements = ["pip:snapml","numpy<2"] + requirements = ["pip:snapml", "pip:numpy<2"] parameters = {"gpu": [False, True]} references = [ From ad52e93540da70df03216a5ed8d228f79980cda7 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 3 Jul 2024 14:17:28 +0200 Subject: [PATCH 04/42] try specific numpy version --- solvers/snapml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solvers/snapml.py b/solvers/snapml.py index 89a7ee6..1746f87 100644 --- a/solvers/snapml.py +++ b/solvers/snapml.py @@ -11,7 +11,7 @@ class Solver(BaseSolver): name = "snapml" install_cmd = "conda" - requirements = ["pip:snapml", "pip:numpy<2"] + requirements = ["numpy==1.26.0", "pip:snapml"] parameters = {"gpu": [False, True]} references = [ From c25816789ddfafa1f6245857c1b128eea9f6c704 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 15:30:33 +0200 Subject: [PATCH 05/42] unspecifying numpy version --- solvers/snapml.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/solvers/snapml.py b/solvers/snapml.py index 1746f87..ac928c9 100644 --- a/solvers/snapml.py +++ b/solvers/snapml.py @@ -11,7 +11,12 @@ class Solver(BaseSolver): name = "snapml" install_cmd = "conda" - requirements = ["numpy==1.26.0", "pip:snapml"] + + """ + Snap ML wheels are built with numpy 1.*, they are not compatible with + numpy>=2. Awaiting compatible wheels, numpy<2 is required for this solver. + """ + requirements = ["numpy'<2'", "pip:snapml"] parameters = {"gpu": [False, True]} references = [ From da13bcdab4bce04ff97e52e16e72b415de9872c0 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 15:55:33 +0200 Subject: [PATCH 06/42] testing with added libomp install --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3c053e1..afe7b9c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ on: jobs: benchopt_dev: - uses: benchopt/template_benchmark/.github/workflows/test_benchmarks.yml@main + uses: wassimmazouz/template_benchmark/.github/workflows/test_benchmarks.yml@adding-libomp-install with: benchopt_branch: benchopt@main benchopt_release: From 443d5d2863681a7a9080232b8aad9157ef7f0649 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 16:13:20 +0200 Subject: [PATCH 07/42] testing with extra exports --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index afe7b9c..69cc821 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ on: schedule: # Run wednesday at 7:42am UTC. - cron: '42 8 * * wed' - +#testing with forked YAML jobs: benchopt_dev: uses: wassimmazouz/template_benchmark/.github/workflows/test_benchmarks.yml@adding-libomp-install From 0b6d4f65491006fcacee7222e58e5f35ac38d820 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 16:25:41 +0200 Subject: [PATCH 08/42] test --- solvers/cd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solvers/cd.py b/solvers/cd.py index 4b874ff..a0df16c 100644 --- a/solvers/cd.py +++ b/solvers/cd.py @@ -20,7 +20,7 @@ class Solver(BaseSolver): requirements = ['numba'] def skip(self, X, y, lmbd, fit_intercept): - # XXX - not implemented but this should be quite easy + # XXX - not implemented but this should be quite easy. if fit_intercept: return True, f"{self.name} does not handle fit_intercept" From 471ed52eaba2de74066ce5235d68dad930de9a6b Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 16:49:03 +0200 Subject: [PATCH 09/42] test with link --- solvers/cd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solvers/cd.py b/solvers/cd.py index a0df16c..4b874ff 100644 --- a/solvers/cd.py +++ b/solvers/cd.py @@ -20,7 +20,7 @@ class Solver(BaseSolver): requirements = ['numba'] def skip(self, X, y, lmbd, fit_intercept): - # XXX - not implemented but this should be quite easy. + # XXX - not implemented but this should be quite easy if fit_intercept: return True, f"{self.name} does not handle fit_intercept" From 22d92fb1f21ca6a4ae1150d5be8de2819f2a09bb Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 17:06:42 +0200 Subject: [PATCH 10/42] fixing comment --- solvers/snapml.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/solvers/snapml.py b/solvers/snapml.py index ac928c9..95dc03a 100644 --- a/solvers/snapml.py +++ b/solvers/snapml.py @@ -12,10 +12,8 @@ class Solver(BaseSolver): install_cmd = "conda" - """ - Snap ML wheels are built with numpy 1.*, they are not compatible with - numpy>=2. Awaiting compatible wheels, numpy<2 is required for this solver. - """ + # Snap ML wheels are built with numpy 1.*, they are not compatible with + # numpy>=2. TODO : upgrade numpy when compatible wheels are released. requirements = ["numpy'<2'", "pip:snapml"] parameters = {"gpu": [False, True]} From da4dd69a851771338e62813a461789c636135d97 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 17:17:18 +0200 Subject: [PATCH 11/42] try llvm --- solvers/cd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solvers/cd.py b/solvers/cd.py index 4b874ff..a0df16c 100644 --- a/solvers/cd.py +++ b/solvers/cd.py @@ -20,7 +20,7 @@ class Solver(BaseSolver): requirements = ['numba'] def skip(self, X, y, lmbd, fit_intercept): - # XXX - not implemented but this should be quite easy + # XXX - not implemented but this should be quite easy. if fit_intercept: return True, f"{self.name} does not handle fit_intercept" From 30542b91c52691d3d0915f44dece2930bd9898ab Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 17:21:09 +0200 Subject: [PATCH 12/42] create directory --- solvers/cd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solvers/cd.py b/solvers/cd.py index a0df16c..4b874ff 100644 --- a/solvers/cd.py +++ b/solvers/cd.py @@ -20,7 +20,7 @@ class Solver(BaseSolver): requirements = ['numba'] def skip(self, X, y, lmbd, fit_intercept): - # XXX - not implemented but this should be quite easy. + # XXX - not implemented but this should be quite easy if fit_intercept: return True, f"{self.name} does not handle fit_intercept" From 81060c46dc049f382e173cf753a092bcfef561c8 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 17:24:52 +0200 Subject: [PATCH 13/42] sudo --- solvers/cd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solvers/cd.py b/solvers/cd.py index 4b874ff..a0df16c 100644 --- a/solvers/cd.py +++ b/solvers/cd.py @@ -20,7 +20,7 @@ class Solver(BaseSolver): requirements = ['numba'] def skip(self, X, y, lmbd, fit_intercept): - # XXX - not implemented but this should be quite easy + # XXX - not implemented but this should be quite easy. if fit_intercept: return True, f"{self.name} does not handle fit_intercept" From 47df2ae9a42e7904d8ee39b26c96d1882e73b9c1 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 4 Jul 2024 17:29:38 +0200 Subject: [PATCH 14/42] sudo 2 --- solvers/cd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solvers/cd.py b/solvers/cd.py index a0df16c..4b874ff 100644 --- a/solvers/cd.py +++ b/solvers/cd.py @@ -20,7 +20,7 @@ class Solver(BaseSolver): requirements = ['numba'] def skip(self, X, y, lmbd, fit_intercept): - # XXX - not implemented but this should be quite easy. + # XXX - not implemented but this should be quite easy if fit_intercept: return True, f"{self.name} does not handle fit_intercept" From 82e70cfc3dc5c2168183a8b0bdca554ac42020d7 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 10 Jul 2024 11:33:28 +0200 Subject: [PATCH 15/42] ci trigger From e9544cecbb353ac46f09159a30155f70059bb712 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 10 Jul 2024 12:56:21 +0200 Subject: [PATCH 16/42] ci trigger From 0ea9a0fc3cf889b872756f9777f3bd72b8262529 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 10 Jul 2024 13:17:19 +0200 Subject: [PATCH 17/42] ci trigger From 8ef307d895a179f23274d8798fe2750e52f4f548 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 10 Jul 2024 15:31:54 +0200 Subject: [PATCH 18/42] ci trigger From aef59c6bf8d3e3b985c29770b1976e44c6d73a4c Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 10 Jul 2024 15:46:02 +0200 Subject: [PATCH 19/42] ci trigger From c7f384250d9c6c7735e4f014c9fb3a4c0ff382f3 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 10 Jul 2024 15:46:03 +0200 Subject: [PATCH 20/42] ci trigger From 606d4704b83643b44599a97c81145becb36990ab Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 10:41:05 +0200 Subject: [PATCH 21/42] back to created link From 97ef31c31cae7c4816af5a1fe4c200d8d26d6f1b Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 10:56:22 +0200 Subject: [PATCH 22/42] separate tasks From 85d5c1263bbdcf95c2ce3fea03d0007ae413e234 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 10:59:55 +0200 Subject: [PATCH 23/42] unlink From c2ff09d9d3dbb7ba177a09afb7a0d0435abfc88b Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 11:03:40 +0200 Subject: [PATCH 24/42] ci trigger From fa299bfee7238d80b2bdeae433b7f84bfa6537c5 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 11:23:02 +0200 Subject: [PATCH 25/42] proper version From 79b6758560a4112740473bd6520d8d327c854f9e Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 11:28:33 +0200 Subject: [PATCH 26/42] remove if else From 75dc0904b21c9e7b63994c7c9867c9d5ed3403a0 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 11:35:18 +0200 Subject: [PATCH 27/42] ci trigger From cb243454ee90c012dec454b06cb0289c79c4f3c6 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 11:38:53 +0200 Subject: [PATCH 28/42] ci trigger From b1162186884cc38c41eb5e5bf0199777ec5beb26 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 12:51:20 +0200 Subject: [PATCH 29/42] from opt to usr From 7d57bff9b1bce35941b544b7cb8cd2184e94d0c7 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 13:02:27 +0200 Subject: [PATCH 30/42] already exists From 0168495e07a75d90b497c1aa29bad9177920ef9e Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 13:06:31 +0200 Subject: [PATCH 31/42] unlink From f8535a7bbd9f1ca22a4a358ca5151c2d30da5d1a Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 13:21:13 +0200 Subject: [PATCH 32/42] only path From 5a56a2a1a412d1162d425f9b7d8525ad9d8a8b48 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 13:36:08 +0200 Subject: [PATCH 33/42] libomp and path From 3f95a8421e3ca4d592eca2174d2a018dbc3cc9db Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 11 Jul 2024 13:40:03 +0200 Subject: [PATCH 34/42] libomp and homebrew From c2414134b7a4621979ae15d854cbb13d2577434d Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 17 Jul 2024 10:44:17 +0200 Subject: [PATCH 35/42] install libomp directly --- .github/workflows/main.yml | 2 +- benchmark_utils/__init__.py | 9 +++++ benchmark_utils/libomp_install.py | 57 +++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 benchmark_utils/__init__.py create mode 100644 benchmark_utils/libomp_install.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index afe7b9c..3c053e1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ on: jobs: benchopt_dev: - uses: wassimmazouz/template_benchmark/.github/workflows/test_benchmarks.yml@adding-libomp-install + uses: benchopt/template_benchmark/.github/workflows/test_benchmarks.yml@main with: benchopt_branch: benchopt@main benchopt_release: diff --git a/benchmark_utils/__init__.py b/benchmark_utils/__init__.py new file mode 100644 index 0000000..8270d80 --- /dev/null +++ b/benchmark_utils/__init__.py @@ -0,0 +1,9 @@ +from libomp_install import install_libomp_on_macos + +# libomp x86_64 is needed for snapML on macOS. Homebrew is needed for this install as well. + +# Homebrew is installed and added to path to install libomp x86_64. + +# Also, libomp needs some directories added to PATH to function correctly. + +install_libomp_on_macos() diff --git a/benchmark_utils/libomp_install.py b/benchmark_utils/libomp_install.py new file mode 100644 index 0000000..200712d --- /dev/null +++ b/benchmark_utils/libomp_install.py @@ -0,0 +1,57 @@ +import platform +import subprocess +import os + + +def install_libomp_on_macos(): + # Check if the OS is macOS + if platform.system() != 'Darwin': + return + + # Install and setup Homebrew + subprocess.run( + [ + 'arch', '-x86_64', '/bin/bash', '-c', + '"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' + ], + check=True, + shell=True + ) + + # Add Homebrew to the shell environment + homebrew_shellenv = subprocess.run( + [ + '/usr/local/bin/brew', 'shellenv' + ], + check=True, + capture_output=True, + text=True, + shell=True + ).stdout + with open(os.path.expanduser('~/.profile'), 'a') as profile_file: + profile_file.write(f'eval "$({homebrew_shellenv})"\n') + subprocess.run( + ['eval', f'"$({homebrew_shellenv})"'], + check=True, + shell=True + ) + + # Install libomp + subprocess.run( + ['arch', '-x86_64', '/usr/local/bin/brew', 'install', 'libomp'], + check=True, + shell=True + ) + + # Set environment variables + with open(os.path.expanduser('~/.profile'), 'a') as profile_file: + profile_file.write('export LDFLAGS="-L/usr/local/opt/libomp/lib"\n') + profile_file.write('export CPPFLAGS="-I/usr/local/opt/libomp/include"\n') + profile_file.write( + 'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/opt/libomp/lib\n') + + # Also export environment variables in the current session + os.environ['LDFLAGS'] = '-L/usr/local/opt/libomp/lib' + os.environ['CPPFLAGS'] = '-I/usr/local/opt/libomp/include' + os.environ['DYLD_LIBRARY_PATH'] = os.environ.get( + 'DYLD_LIBRARY_PATH', '') + ':/usr/local/opt/libomp/lib' From 0f2e8a466dbbc317c350e60d2cf43f1dd680640e Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 17 Jul 2024 10:48:42 +0200 Subject: [PATCH 36/42] all in one file --- benchmark_utils/__init__.py | 61 +++++++++++++++++++++++++++++-- benchmark_utils/libomp_install.py | 57 ----------------------------- 2 files changed, 58 insertions(+), 60 deletions(-) delete mode 100644 benchmark_utils/libomp_install.py diff --git a/benchmark_utils/__init__.py b/benchmark_utils/__init__.py index 8270d80..3c425b8 100644 --- a/benchmark_utils/__init__.py +++ b/benchmark_utils/__init__.py @@ -1,9 +1,64 @@ -from libomp_install import install_libomp_on_macos +import platform +import subprocess +import os -# libomp x86_64 is needed for snapML on macOS. Homebrew is needed for this install as well. +# libomp x86_64 is needed for snapML on macOS. Homebrew is needed for this +# install as well. # Homebrew is installed and added to path to install libomp x86_64. # Also, libomp needs some directories added to PATH to function correctly. -install_libomp_on_macos() + +# Check if the OS is macOS +if platform.system() == 'Darwin': + # Install and setup Homebrew + subprocess.run( + [ + 'arch', '-x86_64', '/bin/bash', '-c', + '"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install"' + '"/HEAD/install.sh)"' + ], + check=True, + shell=True + ) + + # Add Homebrew to the shell environment + homebrew_shellenv = subprocess.run( + [ + '/usr/local/bin/brew', 'shellenv' + ], + check=True, + capture_output=True, + text=True, + shell=True + ).stdout + with open(os.path.expanduser('~/.profile'), 'a') as profile_file: + profile_file.write(f'eval "$({homebrew_shellenv})"\n') + subprocess.run( + ['eval', f'"$({homebrew_shellenv})"'], + check=True, + shell=True + ) + + # Install libomp + subprocess.run( + ['arch', '-x86_64', '/usr/local/bin/brew', 'install', 'libomp'], + check=True, + shell=True + ) + + # Set environment variables + with open(os.path.expanduser('~/.profile'), 'a') as profile_file: + profile_file.write('export LDFLAGS="-L/usr/local/opt/libomp/lib"\n') + profile_file.write('export CPPFLAGS="-I/usr/local/opt/libomp/include"' + '\n') + profile_file.write( + 'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/opt/libomp' + '/lib\n') + + # Also export environment variables in the current session + os.environ['LDFLAGS'] = '-L/usr/local/opt/libomp/lib' + os.environ['CPPFLAGS'] = '-I/usr/local/opt/libomp/include' + os.environ['DYLD_LIBRARY_PATH'] = os.environ.get( + 'DYLD_LIBRARY_PATH', '') + ':/usr/local/opt/libomp/lib' diff --git a/benchmark_utils/libomp_install.py b/benchmark_utils/libomp_install.py deleted file mode 100644 index 200712d..0000000 --- a/benchmark_utils/libomp_install.py +++ /dev/null @@ -1,57 +0,0 @@ -import platform -import subprocess -import os - - -def install_libomp_on_macos(): - # Check if the OS is macOS - if platform.system() != 'Darwin': - return - - # Install and setup Homebrew - subprocess.run( - [ - 'arch', '-x86_64', '/bin/bash', '-c', - '"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' - ], - check=True, - shell=True - ) - - # Add Homebrew to the shell environment - homebrew_shellenv = subprocess.run( - [ - '/usr/local/bin/brew', 'shellenv' - ], - check=True, - capture_output=True, - text=True, - shell=True - ).stdout - with open(os.path.expanduser('~/.profile'), 'a') as profile_file: - profile_file.write(f'eval "$({homebrew_shellenv})"\n') - subprocess.run( - ['eval', f'"$({homebrew_shellenv})"'], - check=True, - shell=True - ) - - # Install libomp - subprocess.run( - ['arch', '-x86_64', '/usr/local/bin/brew', 'install', 'libomp'], - check=True, - shell=True - ) - - # Set environment variables - with open(os.path.expanduser('~/.profile'), 'a') as profile_file: - profile_file.write('export LDFLAGS="-L/usr/local/opt/libomp/lib"\n') - profile_file.write('export CPPFLAGS="-I/usr/local/opt/libomp/include"\n') - profile_file.write( - 'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/opt/libomp/lib\n') - - # Also export environment variables in the current session - os.environ['LDFLAGS'] = '-L/usr/local/opt/libomp/lib' - os.environ['CPPFLAGS'] = '-I/usr/local/opt/libomp/include' - os.environ['DYLD_LIBRARY_PATH'] = os.environ.get( - 'DYLD_LIBRARY_PATH', '') + ':/usr/local/opt/libomp/lib' From 7b65b26a1d981d7a3dc7a9ba25e2345c27d552c7 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 17 Jul 2024 10:59:34 +0200 Subject: [PATCH 37/42] unify str --- benchmark_utils/__init__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/benchmark_utils/__init__.py b/benchmark_utils/__init__.py index 3c425b8..e1adc55 100644 --- a/benchmark_utils/__init__.py +++ b/benchmark_utils/__init__.py @@ -16,8 +16,7 @@ subprocess.run( [ 'arch', '-x86_64', '/bin/bash', '-c', - '"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install"' - '"/HEAD/install.sh)"' + "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ], check=True, shell=True @@ -25,9 +24,7 @@ # Add Homebrew to the shell environment homebrew_shellenv = subprocess.run( - [ - '/usr/local/bin/brew', 'shellenv' - ], + '/usr/local/bin/brew shellenv', check=True, capture_output=True, text=True, @@ -36,14 +33,14 @@ with open(os.path.expanduser('~/.profile'), 'a') as profile_file: profile_file.write(f'eval "$({homebrew_shellenv})"\n') subprocess.run( - ['eval', f'"$({homebrew_shellenv})"'], + f'eval "$({homebrew_shellenv})"', check=True, shell=True ) # Install libomp subprocess.run( - ['arch', '-x86_64', '/usr/local/bin/brew', 'install', 'libomp'], + 'arch -x86_64 /usr/local/bin/brew install libomp', check=True, shell=True ) From cb830364f63b80081f7a9d9741ba763e948f4b16 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 17 Jul 2024 11:00:26 +0200 Subject: [PATCH 38/42] lint --- benchmark_utils/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/benchmark_utils/__init__.py b/benchmark_utils/__init__.py index e1adc55..2cf9c5b 100644 --- a/benchmark_utils/__init__.py +++ b/benchmark_utils/__init__.py @@ -16,7 +16,8 @@ subprocess.run( [ 'arch', '-x86_64', '/bin/bash', '-c', - "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/" + "HEAD/install.sh)" ], check=True, shell=True From a21301b287eecae797dc2003751c0a5b080a9ef7 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 17 Jul 2024 11:11:27 +0200 Subject: [PATCH 39/42] abort --- benchmark_utils/__init__.py | 62 ------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 benchmark_utils/__init__.py diff --git a/benchmark_utils/__init__.py b/benchmark_utils/__init__.py deleted file mode 100644 index 2cf9c5b..0000000 --- a/benchmark_utils/__init__.py +++ /dev/null @@ -1,62 +0,0 @@ -import platform -import subprocess -import os - -# libomp x86_64 is needed for snapML on macOS. Homebrew is needed for this -# install as well. - -# Homebrew is installed and added to path to install libomp x86_64. - -# Also, libomp needs some directories added to PATH to function correctly. - - -# Check if the OS is macOS -if platform.system() == 'Darwin': - # Install and setup Homebrew - subprocess.run( - [ - 'arch', '-x86_64', '/bin/bash', '-c', - "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/" - "HEAD/install.sh)" - ], - check=True, - shell=True - ) - - # Add Homebrew to the shell environment - homebrew_shellenv = subprocess.run( - '/usr/local/bin/brew shellenv', - check=True, - capture_output=True, - text=True, - shell=True - ).stdout - with open(os.path.expanduser('~/.profile'), 'a') as profile_file: - profile_file.write(f'eval "$({homebrew_shellenv})"\n') - subprocess.run( - f'eval "$({homebrew_shellenv})"', - check=True, - shell=True - ) - - # Install libomp - subprocess.run( - 'arch -x86_64 /usr/local/bin/brew install libomp', - check=True, - shell=True - ) - - # Set environment variables - with open(os.path.expanduser('~/.profile'), 'a') as profile_file: - profile_file.write('export LDFLAGS="-L/usr/local/opt/libomp/lib"\n') - profile_file.write('export CPPFLAGS="-I/usr/local/opt/libomp/include"' - '\n') - profile_file.write( - 'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/opt/libomp' - '/lib\n') - - # Also export environment variables in the current session - os.environ['LDFLAGS'] = '-L/usr/local/opt/libomp/lib' - os.environ['CPPFLAGS'] = '-I/usr/local/opt/libomp/include' - os.environ['DYLD_LIBRARY_PATH'] = os.environ.get( - 'DYLD_LIBRARY_PATH', '') + ':/usr/local/opt/libomp/lib' From a8c4b7cd81153976edf6482fac311101a61e93c2 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 18 Jul 2024 11:16:37 +0200 Subject: [PATCH 40/42] FIX snapML skip and tutorial --- test_config.py | 7 +++++ tutorials/snapml_macos.rst | 58 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tutorials/snapml_macos.rst diff --git a/test_config.py b/test_config.py index 0594d43..df7f674 100644 --- a/test_config.py +++ b/test_config.py @@ -13,3 +13,10 @@ def check_test_solver_install(solver_class): if "glmnet" in solver_class.name.lower(): pytest.xfail("glmnet produces discrepancies (see issue #2).") + +# libomp x86_64 and Homebrew are needed for snapML to work correctly on MacOS +# Please check this tutorial to install SnapML correctly +# https://github.com/benchopt/benchmark_ridge/blob/tutorials/snapml_macos.rst + + if 'snapml' in solver_class.name.lower() and sys.platform == 'darwin': + pytest.xfail('snapML is not easy to install on MacOS.') diff --git a/tutorials/snapml_macos.rst b/tutorials/snapml_macos.rst new file mode 100644 index 0000000..dd56ef8 --- /dev/null +++ b/tutorials/snapml_macos.rst @@ -0,0 +1,58 @@ +============================ +Installing SnapML on macOS +============================ + +This tutorial provides step-by-step instructions to install SnapML on a macOS machine. The process includes setting up Homebrew and installing the necessary dependencies. + +Steps to Install SnapML +======================== + +1. **Install and Setup Homebrew** + + Homebrew is a package manager for macOS that simplifies the installation of software. + + Open your terminal and run the following command to install Homebrew: + + .. code-block:: bash + + arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + + After installing Homebrew, you need to add it to your shell environment: + + .. code-block:: bash + + echo 'eval "$(/usr/local/bin/brew shellenv)"' >> $HOME/.profile + eval "$(/usr/local/bin/brew shellenv)" + +2. **Install libomp** + + `libomp` is an OpenMP library required by SnapML. Install it using Homebrew: + + .. code-block:: bash + + arch -x86_64 /usr/local/bin/brew install libomp + + Once installed, set up the environment variables needed for `libomp`: + + .. code-block:: bash + + echo 'export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"' >> $HOME/.profile + echo 'export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"' >> $HOME/.profile + echo 'export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/opt/homebrew/opt/libomp/lib' >> $HOME/.profile + + Apply the changes by running: + + .. code-block:: bash + + source $HOME/.profile + +3. **Install SnapML** + + With the dependencies installed, you can now proceed to install SnapML using pip: + + .. code-block:: bash + + pip install snapml + + +By following these steps, you should have SnapML installed and running correctly on your macOS machine. From 84ae02986b56a51e7784bbd284d1b84d55c407b0 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Thu, 18 Jul 2024 17:59:10 +0200 Subject: [PATCH 41/42] suggested changes --- solvers/snapml.py | 4 ++++ test_config.py | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/solvers/snapml.py b/solvers/snapml.py index 95dc03a..8a022c5 100644 --- a/solvers/snapml.py +++ b/solvers/snapml.py @@ -14,6 +14,10 @@ class Solver(BaseSolver): # Snap ML wheels are built with numpy 1.*, they are not compatible with # numpy>=2. TODO : upgrade numpy when compatible wheels are released. + + # libomp x86_64 and Homebrew are needed for snapML to work correctly on + # MacOS. Please check this tutorial to install SnapML correctly: + # https://github.com/benchopt/benchmark_ridge/blob/tutorials/snapml_macos.rst requirements = ["numpy'<2'", "pip:snapml"] parameters = {"gpu": [False, True]} diff --git a/test_config.py b/test_config.py index df7f674..fb42bca 100644 --- a/test_config.py +++ b/test_config.py @@ -14,9 +14,8 @@ def check_test_solver_install(solver_class): if "glmnet" in solver_class.name.lower(): pytest.xfail("glmnet produces discrepancies (see issue #2).") -# libomp x86_64 and Homebrew are needed for snapML to work correctly on MacOS -# Please check this tutorial to install SnapML correctly -# https://github.com/benchopt/benchmark_ridge/blob/tutorials/snapml_macos.rst - + # libomp x86_64 and Homebrew are needed for snapML to work correctly on + # MacOS. Please check this tutorial to install SnapML correctly: + # https://github.com/benchopt/benchmark_ridge/blob/tutorials/snapml_macos.rst if 'snapml' in solver_class.name.lower() and sys.platform == 'darwin': pytest.xfail('snapML is not easy to install on MacOS.') From 9280d625fafc0f84bf47f6c0bac94af98c5bbab2 Mon Sep 17 00:00:00 2001 From: wassimmazouz Date: Wed, 24 Jul 2024 13:40:29 +0200 Subject: [PATCH 42/42] : to :: --- solvers/lightning.py | 2 +- solvers/snapml.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/solvers/lightning.py b/solvers/lightning.py index b18d209..da392e5 100644 --- a/solvers/lightning.py +++ b/solvers/lightning.py @@ -14,7 +14,7 @@ class Solver(BaseSolver): install_cmd = 'conda' requirements = [ 'cython', - 'pip:git+https://github.com/scikit-learn-contrib/lightning.git' + 'pip::git+https://github.com/scikit-learn-contrib/lightning.git' ] references = [ diff --git a/solvers/snapml.py b/solvers/snapml.py index 8a022c5..545d234 100644 --- a/solvers/snapml.py +++ b/solvers/snapml.py @@ -18,7 +18,7 @@ class Solver(BaseSolver): # libomp x86_64 and Homebrew are needed for snapML to work correctly on # MacOS. Please check this tutorial to install SnapML correctly: # https://github.com/benchopt/benchmark_ridge/blob/tutorials/snapml_macos.rst - requirements = ["numpy'<2'", "pip:snapml"] + requirements = ["numpy'<2'", "pip::snapml"] parameters = {"gpu": [False, True]} references = [