Json dump not working?


Error message: ‘Pipeline varaiables do not support __str__operation’

You’re passing a Pipeline object instead of a parsable object (like a dictionary), which is required by json.dumps() method. Try to print(type(preprocessing_step))) and print(preprocessing_step) to figure out what’s wrong

thanks but in the screenshot i was dumping a dictionary ‘preprocessing_step.properties.dict’…

Now I see what’s your problem.
It seems that the dictionary is not seen as a parsable entity by json.dumps even after using the __dict__ methods.
I solved by importing pprint at the beginning:

from pprint import pprint

And then I replaced the indented json.dumps print with pprint:

# print out the list of the processing job properties
#print(json.dumps(props_dict, indent=4, sort_keys=True))
pprint(processing_step.properties.__dict__)

and

# print(json.dumps(processing_step.properties.ProcessingOutputConfig.Outputs['sentiment-train'].__dict__, indent=4, sort_keys=True, default=str))
pprint(processing_step.properties.ProcessingOutputConfig.Outputs['sentiment-train'].__dict__)

Weirdly enough the S3Uri object is parsable by json.dumps:

print(json.dumps(
    processing_step.properties.ProcessingOutputConfig.Outputs['sentiment-train'].S3Output.S3Uri.__dict__,
    indent=4, sort_keys=True, default=str
))

I hope this can help :slightly_smiling_face: