https://pulumi.com logo
#general
Title
# general
s

silly-helicopter-28430

03/13/2024, 5:37 PM
How do i get around issues with pickling in pulumi? I am trying to write a python Dynamic Provider but i can't use the python package i need to create resources: getstate is not set on the object that i need to use in my pulumi 'create' function
Copy code
raise AssertionError(f"{attr_name} not available as a parameter in Flyte context - are you in right task-type?")
    AssertionError: __GETSTATE__ not available as a parameter in Flyte context - are you in right task-type?
h

hundreds-gpu-71155

03/13/2024, 5:45 PM
that reads like the pickle tooling is looking for special method
__get_state__
and Pulumi is raising an assertion error instead of raising an Attribute Error?
s

silly-helicopter-28430

03/13/2024, 5:46 PM
yeah its a pickle err, that i cannot fix, as the python package (Flyte) has recursive references and pickling fails
h

hundreds-gpu-71155

03/13/2024, 5:46 PM
oh, the recursive reference are fine, pickle will do those great
but something has a
__getattr__
/
__getattribute__
and is handling missing attributes wrong
so it sounds like a bug in Flyte
s

silly-helicopter-28430

03/13/2024, 6:30 PM
issue is that Flyte uses this pattern but this cannot be pickled, and sadly havent' figure out a fix
Copy code
import pickle

def get_bar(foo=None):
    class Bar(object):
        def __init__(self):
            self.foo = foo
    return Bar

class Foo(object):
    def __init__(self):
        self.bar = get_bar(foo=self)

my_object = Foo()
my_pickled_object = pickle.dumps(my_object)  # Pickling the object
print(f"This is my pickled object:\n{my_pickled_object}\n")
h

hundreds-gpu-71155

03/13/2024, 6:31 PM
ahhh, yeah, inner classes like that are going to present serialization issues.
My suggestion would be to add special methods on the accessible classes so that pickle doesn't need to recurse to the hidden ones. but that's assuming the representative sample is your code
you could also do add specific special methods on the hidden classes to override the constructor