Comments (4)
Awesome guys! I was running into the same problem, and your solution works for me, too. Thanks!
from singer-tap-template.
Since it seems Singer Slack channel is free (thus has message limits and will make history not accessible), I'm copy-pasting the message with the workaround solution:
Author: Steven Ram
Hi.
Just starting out with Singer, and currently building a tap on the cookiecutter Python template (https://github.com/singer-io/singer-tap-template).I keep running into a TypeError: Schema(...) is not JSON serializable in
singer.write_schema( stream_name=stream.tap_stream_id, schema=stream.schema, key_properties=stream.key_properties )unless I convert Schema to dict first
singer.write_schema( stream_name=stream.tap_stream_id, schema=stream.schema.to_dict(), key_properties=stream.key_properties )Is there a better, recommended way than in the cookiecutter template to build the Schema, so as to avoid this?
Thanks also to Rebecca Sanjabi for linking to Steven's original message.
I tested and the solution works.
from singer-tap-template.
I had the same problem that I managed to trace back further upstream.
It seems like the catalog command line argument isn't getting passed so that sync mode is falling back to calling discover instead of reading the catalog.
if args.catalog: catalog = args.catalog else: catalog = discover() sync(args.config, args.state, catalog)
It seems discover() is returning the Schema class which is not JSON Serializable.
Here's the traceback I get when running the following command: ~/.virtualenvs/tap-woocommerce/bin/tap-woocommerce --config tap-woocommerce/config.json --catalog tap-woocommerce/catalog.json | ~/.virtualenvs/target-csv/bin/target-csv
File "/home/user/.virtualenvs/tap-woocommerce/bin/tap-woocommerce", line 11, in <module> load_entry_point('tap-woocommerce', 'console_scripts', 'tap-woocommerce')() File "/home/user/.virtualenvs/tap-woocommerce/lib/python3.6/site-packages/singer/utils.py", line 229, in wrapped return fnc(*args, **kwargs) File "/c/Users/user/dev/singer/tap-woocommerce/tap_woocommerce/__init__.py", line 106, in main sync(args.config, args.state, catalog) File "/c/Users/user/dev/singer/tap-woocommerce/tap_woocommerce/__init__.py", line 67, in sync key_properties=stream.key_properties, File "/home/user/.virtualenvs/tap-woocommerce/lib/python3.6/site-packages/singer/messages.py", line 269, in write_schema bookmark_properties=bookmark_properties)) File "/home/user/.virtualenvs/tap-woocommerce/lib/python3.6/site-packages/singer/messages.py", line 226, in write_message sys.stdout.write(format_message(message) + '\n') File "/home/user/.virtualenvs/tap-woocommerce/lib/python3.6/site-packages/singer/messages.py", line 222, in format_message return json.dumps(message.asdict(), use_decimal=True) File "/home/user/.virtualenvs/tap-woocommerce/lib/python3.6/site-packages/simplejson/__init__.py", line 380, in dumps return _default_encoder.encode(obj) File "/home/user/.virtualenvs/tap-woocommerce/lib/python3.6/site-packages/simplejson/encoder.py", line 291, in encode chunks = self.iterencode(o, _one_shot=True) File "/home/user/.virtualenvs/tap-woocommerce/lib/python3.6/site-packages/simplejson/encoder.py", line 373, in iterencode return _iterencode(o, 0) File "/home/user/.virtualenvs/tap-woocommerce/lib/python3.6/site-packages/simplejson/encoder.py", line 268, in default raise TypeError(repr(o) + " is not JSON serializable") TypeError: Schema(type='object', properties={'order_id': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'order_key': Schema(type=['null', 'string'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'status': Schema(type=['null', 'string'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'date_created': Schema(type=['null', 'string'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format='date-time', additionalProperties=None, patternProperties=None), 'date_modified': Schema(type=['null', 'string'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format='date-time', additionalProperties=None, patternProperties=None), 'discount_total': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'shipping_total': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'total': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'line_items': Schema(type=['null', 'array'], properties=None, items=Schema(type=['null', 'object'], properties={'id': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'name': Schema(type=['null', 'string'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'product_id': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'variation_id': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'quantity': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'subtotal': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'subtotal_tax': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'total': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'sku': Schema(type=['null', 'string'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'price': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None)}, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'shipping_lines': Schema(type=['null', 'array'], properties=None, items=Schema(type=['null', 'object'], properties={'id': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'method_title': Schema(type=['null', 'string'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'method_id': Schema(type=['null', 'string'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'total': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None)}, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'coupon_lines': Schema(type=['null', 'array'], properties=None, items=Schema(type=['null', 'object'], properties={'id': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'code': Schema(type=['null', 'string'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), 'discount': Schema(type=['null', 'number'], properties=None, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None)}, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None), selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None)}, items=None, selected=None, inclusion=None, description=None, minimum=None, maximum=None, exclusiveMinimum=None, exclusiveMaximum=None, multipleOf=None, maxLength=None, minLength=None, anyOf=None, format=None, additionalProperties=None, patternProperties=None) is not JSON serializable
The fixes proposed earlier work, but hopefully this helps solve the root problem.
from singer-tap-template.
#17 fixes the issue
from singer-tap-template.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from singer-tap-template.