From 430c8d8557a82a7588e80ec1c93530683a597731 Mon Sep 17 00:00:00 2001
From: Matthias Diener <mdiener@illinois.edu>
Date: Mon, 28 Jun 2021 11:24:47 -0500
Subject: [PATCH] deprecate transform_loopy_program

---
 arraycontext/impl/pytato/__init__.py | 11 +++++++++++
 test/test_arraycontext.py            | 12 +++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/arraycontext/impl/pytato/__init__.py b/arraycontext/impl/pytato/__init__.py
index 4d987a4..3e3339f 100644
--- a/arraycontext/impl/pytato/__init__.py
+++ b/arraycontext/impl/pytato/__init__.py
@@ -133,6 +133,17 @@ class PytatoPyOpenCLArrayContext(ArrayContext):
         return LazilyCompilingFunctionCaller(self, f)
 
     def transform_loopy_program(self, prg):
+        from warnings import warn
+        warn(
+            "Using arraycontext.PytatoPyOpenCLArrayContext.transform_loopy_program "
+            "to transform a program. This is deprecated and will stop working "
+            "in 2022. Instead, subclass PytatoPyOpenCLArrayContext and implement "
+            "the specific logic required to transform the program for your "
+            "package or application. Check higher-level packages "
+            "(e.g. meshmode), which may already have subclasses you may want "
+            "to build on.",
+            DeprecationWarning, stacklevel=2)
+
         from loopy.translation_unit import for_each_kernel
 
         nwg = 48
diff --git a/test/test_arraycontext.py b/test/test_arraycontext.py
index 1bfaef4..5f34113 100644
--- a/test/test_arraycontext.py
+++ b/test/test_arraycontext.py
@@ -66,10 +66,20 @@ class _PyOpenCLArrayContextForTestsFactory(
     force_device_scalars = True
 
 
+class _PytatoPyOpenCLArrayContextForTestsFactory(
+        _PytestPytatoPyOpenCLArrayContextFactory):
+    """Like :class:`PytatoPyOpenCLArrayContext`, but applies no program transformations
+    whatsoever. Only to be used for testing internal to :mod:`arraycontext`.
+    """
+
+    def transform_loopy_program(self, t_unit):
+        return t_unit
+
+
 pytest_generate_tests = pytest_generate_tests_for_array_contexts([
     _PyOpenCLArrayContextForTestsFactory,
     _PyOpenCLArrayContextWithHostScalarsForTestsFactory,
-    _PytestPytatoPyOpenCLArrayContextFactory,
+    _PytatoPyOpenCLArrayContextForTestsFactory,
     ])
 
 # }}}
-- 
GitLab