I am attempting to load a model that I trained locally to QC Cloud, but am having some difficulties deserializing it. Following the instructions in the docs here, I am doing something like::

  1. import pickle
  2. import base64
  3. # Stuff to be saved
  4. MyClass:
  5. def __init__(self):
  6. pass
  7. def foo(self):
  8. return 1
  9. myObj = MyClass()
  10. myDat = {'a' : 1}
  11. stuff = {'myObj' : myObj, 'myDat' : myDat }
  12. # Serialize as string
  13. stuff_serialized = pickle.dumps( stuff )
  14. stuff_serialized = base64.b64encode( stuff_serialized ).decode('utf-8')
  15. # Save to local ObjectStore
  16. self.ObjectStore.Save('Stuff', stuff_serialized)
  17. ## Upload the file to Dropbox, then on QC Cloud:
  18. # Download the file
  19. stuff_serialized = self.Download('PATH_TO_FILE')
  20. # Deserialize
  21. stuff_serialized = base64.b64decode(stuff_serialized.encode('utf-8'))
  22. stuff = pickle.loads(stuff_serialized)
+ Expand

But I am receiving the error in the pickle.loads step:

  1. could not find MARK

Note that I'm using utf-8 instead of ascii as in the docs due to some invalid character errors. 

Any suggestions?

Author

Adam W

June 2023