Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version incompatibility with new Pymbolic release 2024.1 #435

Open
mlange05 opened this issue Nov 11, 2024 · 1 comment
Open

Version incompatibility with new Pymbolic release 2024.1 #435

mlange05 opened this issue Nov 11, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@mlange05
Copy link
Collaborator

What happened?

Following the upstream update to Pymbolic v2024.1 ecWAM regression triggers an issue in the Loki expression layer during the confirgure/plan stage.

What are the steps to reproduce the bug?

With latest Pymbolic run py.test -vs loki/transformations/ -k ecwam

Version

main

Platform (OS and architecture)

Linux, Python 3.11

Relevant log output

11-Nov-2024 06:37:39    File "/lus/h2resw01/scratch/rdci/CI/LOKI-H24RAPS-NV2211GPU-30/source/loki/loki/expression/operations.py", line 63, in <module>
11-Nov-2024 06:37:39      class StringConcat(pmbl._MultiChildExpression):
11-Nov-2024 06:37:39                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
11-Nov-2024 06:37:39  AttributeError: module 'pymbolic.primitives' has no attribute '_MultiChildExpression'

Accompanying data

No response

Organisation

No response

@mlange05 mlange05 added the bug Something isn't working label Nov 11, 2024
@mlange05 mlange05 self-assigned this Nov 11, 2024
@quepas
Copy link
Contributor

quepas commented Nov 20, 2024

I have solved this problem by adding manually the children field (in the spirit of what has been done in pymbolic):

diff --git a/loki/expression/operations.py b/loki/expression/operations.py                                                                                                    
index 03a67753..1cf4d7f6 100644
--- a/loki/expression/operations.py
+++ b/loki/expression/operations.py
@@ -13,6 +13,7 @@ nevertheless change code results.
  
 from sys import intern
 import pymbolic.primitives as pmbl
+from pymbolic.typing import ExpressionT
  
 from loki.expression.symbols import (
     StringLiteral, Sum, Product, Quotient, Power,
@@ -60,10 +61,11 @@ class ParenthesisedPow(Power):
     make_stringifier = loki_make_stringifier
  
  
-class StringConcat(pmbl._MultiChildExpression):
+class StringConcat(pmbl.Expression):
     """
     Implements string concatenation in a way similar to :class:`Sum`.
     """
+    children: tuple[ExpressionT, ...]
  
     def __add__(self, other):
         if isinstance(other, (StringConcat, StringLiteral, pmbl.Variable)):

However, this is only the beginning of problems! In pymbolic, all has started with this commit: inducer/pymbolic@1dcc9c5#diff-a27cda1a4fd5316514a9277c4733b3a23cc10fcef61c6b3f847c25085ee73863 where they removed _MultiChildExpression and converted every symbol class to a dataclass. Fields in pymbolic dataclasses are by default frozen (inducer/pymbolic@1dcc9c5#diff-768f1abbde39f5f7efff7c209a95315a87e28e0ba4f42e7a468903203aba8ffcR900), and thus, another errors are produced:

  File "/home/loki/loki/frontend/regex.py", line 873, in match                                                                                                                
    symbols += [sym.Variable(name=s[0], type=type_, scope=scope)]                                                                                                             
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                              
  File "/home/loki/loki/expression/symbols.py", line 883, in __new__                                                                                                          
    return DeferredTypeSymbol(**kwargs)                                                                                                                                       
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                       
  File "/home/loki/loki/expression/symbols.py", line 401, in __init__                                                                                                         
    super().__init__(name=name, scope=scope, **kwargs)
  File "/home/loki/loki/expression/symbols.py", line 130, in __init__
    self.name = kwargs['name']
    ^^^^^^^^^                              
  File "<string>", line 4, in __setattr__
dataclasses.FrozenInstanceError: cannot assign to field 'name'

I think this requires further analysis and probably some architectural changes. I might be of use in the future, but I would need to know the direction to take :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants