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

ClassDef with bases results in RuntimeError #162

Open
JoshuaGlaZ opened this issue Jun 28, 2024 · 0 comments
Open

ClassDef with bases results in RuntimeError #162

JoshuaGlaZ opened this issue Jun 28, 2024 · 0 comments

Comments

@JoshuaGlaZ
Copy link
Contributor

When processing a class with inheritance in noworkflow, the bases and keywords are not correctly captured, resulting in a RuntimeError for super(). ClassDef (class_def) without base classes are working, as do the name, body, and decorator lists of the class. However, the bases and keyword arguments are not captured correctly.

class BaseClass:
    def __init__(self, base_value):
        self.base_value = base_value

    def base_method(self):
        return "This is a method in the base class"

def class_decorator(cls):
    cls.decorated = True
    return cls

def method_decorator(func):
    def wrapper(*args, **kwargs):
        print("Method is being called")
        return func(*args, **kwargs)
    return wrapper

@class_decorator
class DerivedClass(BaseClass):
    class_variable = "I am a class variable"

    def __init__(self, base_value, derived_value):
        super().__init__(base_value)
        self.derived_value = derived_value

    @method_decorator
    def decorated_method(self):
        return "This method is decorated"

derived_instance = DerivedClass(10, 20)

Error Output:

[now] RuntimeError('super(): class cell not found')
the execution finished with an uncaught exception. Traceback (most recent call last):
File "...\noworkflow\capture\noworkflow\now\collection\prov_execution\execution.py", line 64, in collect_provenance
exec(compiled, metascript.namespace) # pylint: disable=exec-used
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...\noworkflow\demo_1\class.py", line 35, in
derived_instance = DerivedClass(10, 20)
^^^^^^^^^^^^^^^^^^^^
File "...\noworkflow\capture\noworkflow\now\collection\prov_execution\collector.py", line 1207, in _call
result = future.func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...\noworkflow\capture\noworkflow\now\collection\prov_execution\collector.py", line 1351, in new_function_def
result = _call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^
File "...\noworkflow\capture\noworkflow\now\collection\prov_execution\collector.py", line 1207, in _call
result = future.func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...\noworkflow\capture\noworkflow\now\collection\prov_execution\collector.py", line 1370, in new_function_def
result = function_def(
^^^^^^^^^^^^^
File "...\noworkflow\demo_1\class.py", line 27, in init
super().init(base_value)
^^^^^^^
File "...\noworkflow\capture\noworkflow\now\collection\prov_execution\collector.py", line 1207, in _call
result = future.func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: super(): class cell not found

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants