How do i get around issues with pickling in pulumi...
# general
s
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
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
yeah its a pickle err, that i cannot fix, as the python package (Flyte) has recursive references and pickling fails
h
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
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
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