From 00b0910adb36d1f6448aad6bfba9d71e33931817 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:19:43 -0400 Subject: [PATCH 01/24] check bug is only happening on mac --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8e1e7a4..aacd298 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: From f87f8fe886e92765dbbae70ae5f57539facd9f85 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:23:37 -0400 Subject: [PATCH 02/24] add numpy to fix windows issue --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index aacd298..7093ddc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -21,6 +21,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install numpy==2.0.0 pip install -r requirements.txt - name: Test with pytest run: | From 9f88f91e1343dc0976f4a8777d480996bc8bd017 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:24:32 -0400 Subject: [PATCH 03/24] multiple numpy versions in tests --- .github/workflows/test.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7093ddc..bcc2555 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,6 +11,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + numpy-version: ["1.3.5", "2.0.0"] steps: - uses: actions/checkout@v3 @@ -21,7 +22,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install numpy==2.0.0 + pip install numpy==${{ matrix.numpy-version }} pip install -r requirements.txt - name: Test with pytest run: | From 72010a0c88bad830576db0161d9a07e208b69b04 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:27:08 -0400 Subject: [PATCH 04/24] exclude --- .github/workflows/test.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index bcc2555..9f3e76b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -13,6 +13,11 @@ jobs: python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] numpy-version: ["1.3.5", "2.0.0"] + exclude: + - python-version: "3.8" + numpy-version: "2.0.0" + + steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 812aa1289137d5ad26905ab19a0279f2e635d7b0 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:27:52 -0400 Subject: [PATCH 05/24] update --- .github/workflows/test.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9f3e76b..355bbe3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,7 +12,6 @@ jobs: os: [ubuntu-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] numpy-version: ["1.3.5", "2.0.0"] - exclude: - python-version: "3.8" numpy-version: "2.0.0" From 7f66e6fc119ee22b1525cdc1cda75de8909b4dfe Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:30:06 -0400 Subject: [PATCH 06/24] update --- .github/workflows/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 355bbe3..46a3788 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,9 +12,9 @@ jobs: os: [ubuntu-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] numpy-version: ["1.3.5", "2.0.0"] - exclude: - - python-version: "3.8" - numpy-version: "2.0.0" + exclude: + - python-version: "3.8" + numpy-version: "2.0.0" steps: From 61ed892c40e8b55905dda0618b7baf671e6b1ad9 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:30:57 -0400 Subject: [PATCH 07/24] fix --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 46a3788..8f6fdc8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - numpy-version: ["1.3.5", "2.0.0"] + numpy-version: ["1.25.2", "2.0.0"] exclude: - python-version: "3.8" numpy-version: "2.0.0" From 9ab1406ab76bb96c8d8a9909361c0b689763bb2b Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:32:18 -0400 Subject: [PATCH 08/24] fix --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8f6fdc8..7ec00a1 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - numpy-version: ["1.25.2", "2.0.0"] + numpy-version: ["1.18.1", "2.0.0"] exclude: - python-version: "3.8" numpy-version: "2.0.0" From 652d2bdcffff9ab5278c236cf9f1f277704de44d Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:33:13 -0400 Subject: [PATCH 09/24] fix --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7ec00a1..a64bf0a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - numpy-version: ["1.18.1", "2.0.0"] + numpy-version: ["1.24.2", "2.0.0"] exclude: - python-version: "3.8" numpy-version: "2.0.0" From 3b563f701705be5b1fbbfac48b4f68487e25acea Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:34:17 -0400 Subject: [PATCH 10/24] fix --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a64bf0a..8faf50f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,6 +15,8 @@ jobs: exclude: - python-version: "3.8" numpy-version: "2.0.0" + - python-version: "3.12" + numpy-version: "1.24.2" steps: From bc75bc19328c7ea3a154bc9d22d9e92a891e01b3 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:45:51 -0400 Subject: [PATCH 11/24] fix --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 8faf50f..ca9487b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -17,6 +17,8 @@ jobs: numpy-version: "2.0.0" - python-version: "3.12" numpy-version: "1.24.2" + - os: windows-latest + numpy-version: "2.0.0" steps: From 5bac2b174a7282ae6e77f8f9fd24960c2a3a6e2f Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:50:03 -0400 Subject: [PATCH 12/24] add macos back but not with numpy 2 --- .github/workflows/test.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ca9487b..3ac140b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] numpy-version: ["1.24.2", "2.0.0"] exclude: @@ -19,6 +19,8 @@ jobs: numpy-version: "1.24.2" - os: windows-latest numpy-version: "2.0.0" + - os: macos-latest + numpy-version: "2.0.0" steps: From 9bca6f4fa5fe7a2c2062b7b8a7a9e84bd41d7e69 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 19:52:36 -0400 Subject: [PATCH 13/24] update --- .github/workflows/test.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3ac140b..3eb4abb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,8 +19,6 @@ jobs: numpy-version: "1.24.2" - os: windows-latest numpy-version: "2.0.0" - - os: macos-latest - numpy-version: "2.0.0" steps: From 054b979e08cb09ae4fe7603b8b9e1c57c5e67202 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:02:12 -0400 Subject: [PATCH 14/24] print data bytes --- tests/stringify_test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/stringify_test.py b/tests/stringify_test.py index 273a5d0..06f477c 100644 --- a/tests/stringify_test.py +++ b/tests/stringify_test.py @@ -39,6 +39,7 @@ class X: ) def test_stringify_numpy(self): + print(self.data.tobytes()) self.assertEqual( self.slow_hash, stable_hash(self.data, fast_bytes=False), From ac64baa4dc1da61208340fe9368378b47f81f828 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:05:41 -0400 Subject: [PATCH 15/24] update --- .github/workflows/test.yaml | 2 ++ tests/stringify_test.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3eb4abb..3ac140b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,6 +19,8 @@ jobs: numpy-version: "1.24.2" - os: windows-latest numpy-version: "2.0.0" + - os: macos-latest + numpy-version: "2.0.0" steps: diff --git a/tests/stringify_test.py b/tests/stringify_test.py index 06f477c..59eac0f 100644 --- a/tests/stringify_test.py +++ b/tests/stringify_test.py @@ -14,12 +14,12 @@ class StringifyTest(unittest.TestCase): slow_hash = { "linux": "16469cff96525e3e190758d793e61f9d798cb87617787bc1312cf7a8b59aa4b2", "win32": "faaa45dfa377870db4d547ca91187566b6b74983adaf16241a80ef96af592285", - "darwin": "97d8947421010821dd8f3f7046ef0eccd5c27602c7505a5749c1090a0fe7435b", + "darwin": "", }[sys.platform] fast_hash = { "linux": "c97fda7d817a32aad65ce77f5043a51410c5893e6bab8e746a23f68c8e483774", "win32": "387b1ef12b70d4df0984846b753fbcceb1b7d079256e75479810b6a15d668b70", - "darwin": "76ce19673caf9532d68730c7f83bfe8e6f521cc001c2d43373f9c4f33c925037", + "darwin": "", }[sys.platform] def test_stringify_json(self): From b1ee77b843fa83cd65f91357f676ae0594d86ee0 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:13:37 -0400 Subject: [PATCH 16/24] fix; give up on making stuff deterministic on mac --- .github/workflows/test.yaml | 2 -- tests/stringify_test.py | 12 ++++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3ac140b..3eb4abb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -19,8 +19,6 @@ jobs: numpy-version: "1.24.2" - os: windows-latest numpy-version: "2.0.0" - - os: macos-latest - numpy-version: "2.0.0" steps: diff --git a/tests/stringify_test.py b/tests/stringify_test.py index 59eac0f..22fbaa7 100644 --- a/tests/stringify_test.py +++ b/tests/stringify_test.py @@ -8,18 +8,26 @@ from permacache import stable_hash, stringify +NUMPY_VERSION = np.version.version.split(".")[0] + class StringifyTest(unittest.TestCase): data = np.random.RandomState(0).randn(1000) slow_hash = { "linux": "16469cff96525e3e190758d793e61f9d798cb87617787bc1312cf7a8b59aa4b2", "win32": "faaa45dfa377870db4d547ca91187566b6b74983adaf16241a80ef96af592285", - "darwin": "", + "darwin": { + "1": "97d8947421010821dd8f3f7046ef0eccd5c27602c7505a5749c1090a0fe7435b", + "2": "f80b352d29bedc2147f6d5a3623226c7f350bbab1f743ffe0a257132c5a60597", + }[NUMPY_VERSION], }[sys.platform] fast_hash = { "linux": "c97fda7d817a32aad65ce77f5043a51410c5893e6bab8e746a23f68c8e483774", "win32": "387b1ef12b70d4df0984846b753fbcceb1b7d079256e75479810b6a15d668b70", - "darwin": "", + "darwin": { + "1": "76ce19673caf9532d68730c7f83bfe8e6f521cc001c2d43373f9c4f33c925037", + "2": "a0128e05b5d5ceab4d1b5716c5ce3339b25f3ef6a1208383e6c99afdc2b519c1", + }[NUMPY_VERSION], }[sys.platform] def test_stringify_json(self): From f47ae4558f31279b874e97715655c9564309fc80 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:16:26 -0400 Subject: [PATCH 17/24] update --- tests/stringify_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stringify_test.py b/tests/stringify_test.py index 22fbaa7..3d90371 100644 --- a/tests/stringify_test.py +++ b/tests/stringify_test.py @@ -8,7 +8,7 @@ from permacache import stable_hash, stringify -NUMPY_VERSION = np.version.version.split(".")[0] +NUMPY_VERSION = np.version.version.split(".", maxsplit=1)[0] class StringifyTest(unittest.TestCase): From 175591ef37f9c291134deb14d9f50d3104608509 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:20:57 -0400 Subject: [PATCH 18/24] update --- .github/workflows/test.yaml | 4 +++- README.md | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3eb4abb..b8d47b7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,10 +11,12 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - numpy-version: ["1.24.2", "2.0.0"] + numpy-version: ["1.20.0", "1.24.2", "2.0.0"] exclude: - python-version: "3.8" numpy-version: "2.0.0" + - python-version: "3.12" + numpy-version: "1.20.0" - python-version: "3.12" numpy-version: "1.24.2" - os: windows-latest diff --git a/README.md b/README.md index 9e9e8b1..b8dcd43 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ def f(large_argument, not_json_argument, transient_flag): The dictionary has keys that correspond to each of the arguments, and the values are applied to them before placing them in the key. Here, `stable_hash` can be used to hash the json stringification of the value, saving disk space but making recovering the value impossible if you want to do that later. Additionally, `str` can be used to stringify objects that you are convinced have stable `str` representations but cannot be represented in json. Finally, the flag argument is ignored in the JSON representation, this is useful for verbosity flags, etc., that don't affect the output. +**Extremely important note**: If you use `stable_hash`, it is only guaranteed to be stable for the same major version of `numpy` (numpy `1.*.*` vs `2.*.*`) and the same operating system. On Ubuntu it does appear to be stable across versions of `numpy`, but this is not true on Mac OS. + ## Aliasing Permacache uses the underlying function signature to construct the key. For example, for the function From 431ec20d7248a9fd3cf8465fdca7ae6d498aea77 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:25:04 -0400 Subject: [PATCH 19/24] update --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index b8d47b7..5151b8d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9"] numpy-version: ["1.20.0", "1.24.2", "2.0.0"] exclude: - python-version: "3.8" From 30ffd1ce5f445e12587ccb06e930217151b21d54 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:27:33 -0400 Subject: [PATCH 20/24] update --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5151b8d..faceb29 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.8", "3.9"] - numpy-version: ["1.20.0", "1.24.2", "2.0.0"] + numpy-version: ["1.20.3"] exclude: - python-version: "3.8" numpy-version: "2.0.0" From 35cf2cd0bdd8e1a7fc964a4e3bffba1f42d3b6b1 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:27:52 -0400 Subject: [PATCH 21/24] update --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index faceb29..7813b76 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,7 +10,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.8", "3.9"] + python-version: ["3.8"] numpy-version: ["1.20.3"] exclude: - python-version: "3.8" From 347fdb5d6a01b7ac3ca91c1ef6e3ee59672b06b9 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:33:44 -0400 Subject: [PATCH 22/24] update --- .github/workflows/test.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7813b76..26b0b39 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,12 +11,10 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.8"] - numpy-version: ["1.20.3"] + numpy-version: ["1.26.4"] exclude: - python-version: "3.8" numpy-version: "2.0.0" - - python-version: "3.12" - numpy-version: "1.20.0" - python-version: "3.12" numpy-version: "1.24.2" - os: windows-latest From 57dd38b56f8e23d35cc70843d5284ee6cd0f5c6b Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:35:55 -0400 Subject: [PATCH 23/24] update --- .github/workflows/test.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 26b0b39..bed634f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,11 +10,13 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.8"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] numpy-version: ["1.26.4"] exclude: - python-version: "3.8" numpy-version: "2.0.0" + - python-version: "3.8" + numpy-version: "1.26.4" - python-version: "3.12" numpy-version: "1.24.2" - os: windows-latest From 40ce653c36694771481d4192c6b194258cccca90 Mon Sep 17 00:00:00 2001 From: Kavi Gupta Date: Fri, 12 Jul 2024 20:39:01 -0400 Subject: [PATCH 24/24] update --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index bed634f..907cd3d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,7 +11,7 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - numpy-version: ["1.26.4"] + numpy-version: ["1.24.2", "1.26.4", "2.0.0"] exclude: - python-version: "3.8" numpy-version: "2.0.0"