From cf875ebbf06bcc967359b5a3a650b434b7a61c44 Mon Sep 17 00:00:00 2001 From: Sam Armstrong <88863522+Sam-Armstrong@users.noreply.github.com> Date: Thu, 20 Feb 2025 17:36:15 +0000 Subject: [PATCH 1/5] fix: define type_params on gast.ClassDef instantiation to support compatibility with python>=3.12 --- .../transformers/inject_transformer/base_transformer.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ivy/transpiler/transformations/transformers/inject_transformer/base_transformer.py b/ivy/transpiler/transformations/transformers/inject_transformer/base_transformer.py index f5ee4192d7961..bc266fa9cbb23 100644 --- a/ivy/transpiler/transformations/transformers/inject_transformer/base_transformer.py +++ b/ivy/transpiler/transformations/transformers/inject_transformer/base_transformer.py @@ -1,5 +1,4 @@ # global -from ast import FunctionDef import gast import inspect import textwrap @@ -10,7 +9,6 @@ ) from ...transformer import Transformer from ....utils import pickling_utils -from ....utils.api_utils import is_frontend_stateful_api from ....utils.ast_utils import ( ast_to_source_code, is_super_call_node, @@ -161,6 +159,7 @@ def visit_Module(self, node): keywords=cls_node.keywords, body=[*cls_node.body, *method_nodes_to_add], decorator_list=cls_node.decorator_list, + type_params=cls_node.type_params if hasattr(cls_node, "type_params") else [], ) new_node = gast.copy_location(new_node, cls_node) # attach origin info to the new node From 9afdd6f624036c4bf7b01a06fc73e5ba21c2d2d9 Mon Sep 17 00:00:00 2001 From: Sam Armstrong <88863522+Sam-Armstrong@users.noreply.github.com> Date: Thu, 20 Feb 2025 17:36:47 +0000 Subject: [PATCH 2/5] fix: unpin gast now we have a fix --- requirements/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 8a9e63186aff6..7431c36e8ae8d 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -2,7 +2,7 @@ astor cryptography>=40.0.0 dill einops -gast<=0.5.4 +gast networkx numpy packaging From df6c75e81ec0d6893b0bd5b93437cebba04d6f58 Mon Sep 17 00:00:00 2001 From: Sam Armstrong <88863522+Sam-Armstrong@users.noreply.github.com> Date: Thu, 20 Feb 2025 17:37:28 +0000 Subject: [PATCH 3/5] test: extend kornia testing workflow to use both python 3.10 and 3.12 --- .github/workflows/test-transpiler.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-transpiler.yml b/.github/workflows/test-transpiler.yml index 9245012345b1f..8a24e0b801b5d 100644 --- a/.github/workflows/test-transpiler.yml +++ b/.github/workflows/test-transpiler.yml @@ -91,6 +91,9 @@ jobs: docker run --rm -v "$(pwd)":/ivy ivyllc/ivy:latest scripts/shell/run_transpiler_tests.sh hf kornia: + strategy: + matrix: + python-version: ["3.10", "3.12"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -99,7 +102,7 @@ jobs: persist-credentials: false - uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Run Kornia Tests id: tests run: | From 3fd88fd350e5047875d14431483251f4dd74e6dd Mon Sep 17 00:00:00 2001 From: Sam Armstrong <88863522+Sam-Armstrong@users.noreply.github.com> Date: Thu, 20 Feb 2025 18:06:10 +0000 Subject: [PATCH 4/5] fix: define type_params in gast.FunctionDef instantiation --- .../transformers/inject_transformer/base_transformer.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ivy/transpiler/transformations/transformers/inject_transformer/base_transformer.py b/ivy/transpiler/transformations/transformers/inject_transformer/base_transformer.py index bc266fa9cbb23..188a3fb696d37 100644 --- a/ivy/transpiler/transformations/transformers/inject_transformer/base_transformer.py +++ b/ivy/transpiler/transformations/transformers/inject_transformer/base_transformer.py @@ -113,6 +113,7 @@ def visit_ClassDef(self, node): decorator_list=method_node.decorator_list, returns=method_node.returns, type_comment=method_node.type_comment, + type_params=method_node.type_params if hasattr(method_node, "type_params") else [], ) new_method_node = gast.copy_location(new_method_node, method_node) BaseRenameTransformer(new_method_node).rename( @@ -223,6 +224,7 @@ def remove_explicit_self_from_super_init(node): decorator_list=method_node.decorator_list, returns=method_node.returns, type_comment=method_node.type_comment, + type_params=method_node.type_params if hasattr(method_node, "type_params") else [], ) new_method_node = gast.copy_location(new_method_node, method_node) self._method_nodes_to_add.append(new_method_node) From a2b096af9c6ac6b5ac295260aa4e8a88e413884d Mon Sep 17 00:00:00 2001 From: Sam Armstrong <88863522+Sam-Armstrong@users.noreply.github.com> Date: Thu, 20 Feb 2025 18:08:27 +0000 Subject: [PATCH 5/5] test: update all transpiler tests to run on both python 3.10 and 3.12 --- .github/workflows/test-transpiler.yml | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-transpiler.yml b/.github/workflows/test-transpiler.yml index 8a24e0b801b5d..e8b82e2d5b4fb 100644 --- a/.github/workflows/test-transpiler.yml +++ b/.github/workflows/test-transpiler.yml @@ -10,6 +10,9 @@ on: jobs: transformations: + strategy: + matrix: + python-version: ["3.10", "3.12"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -18,7 +21,7 @@ jobs: persist-credentials: false - uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Run Transformations Tests id: tests run: | @@ -26,6 +29,9 @@ jobs: docker run --rm -v "$(pwd)":/ivy ivyllc/ivy:latest scripts/shell/run_transpiler_tests.sh transformations translations: + strategy: + matrix: + python-version: ["3.10", "3.12"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -34,7 +40,7 @@ jobs: persist-credentials: false - uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Run Translations Tests id: tests run: | @@ -42,6 +48,9 @@ jobs: docker run --rm -v "$(pwd)":/ivy ivyllc/ivy:latest scripts/shell/run_transpiler_tests.sh translations module: + strategy: + matrix: + python-version: ["3.10", "3.12"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -50,8 +59,7 @@ jobs: persist-credentials: false - uses: actions/setup-python@v3 with: - python-version: "3.10" - + python-version: ${{ matrix.python-version }} - name: Run Module Tests id: tests run: | @@ -59,6 +67,9 @@ jobs: docker run --rm -v "$(pwd)":/ivy ivyllc/ivy:latest scripts/shell/run_transpiler_tests.sh module sourcegen: + strategy: + matrix: + python-version: ["3.10", "3.12"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -67,7 +78,7 @@ jobs: persist-credentials: false - uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Run SourceGen Tests id: tests run: | @@ -75,6 +86,9 @@ jobs: docker run --rm -v "$(pwd)":/ivy ivyllc/ivy:latest scripts/shell/run_transpiler_tests.sh sourcegen hf: + strategy: + matrix: + python-version: ["3.10", "3.12"] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -83,7 +97,7 @@ jobs: persist-credentials: false - uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Run HuggingFace Tests id: tests run: |