You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
id metadata
Traceback (most recent call last):
File "tmp.py", line 14, in <module>
ts.dump_text(populations=sys.stdout)
File "/home/jk/work/github/tskit/python/tskit/trees.py", line 3759, in dump_text
metadata = base64.b64encode(metadata).decode(encoding)
File "/usr/lib/python3.8/base64.py", line 58, in b64encode
encoded = binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'dict'
I guess the right behaviour here is to make the base64_metadata option default to None, and to output decoded metadata as JSON if a schema is present (by default) and base64 encode it otherwise. If base64_metadata is True, then we output the raw bytes always.
We should move the implementation of this function to text_formats.py while we're fixing it up too, to try and downsize trees.py a bit and keep all the text processing stuff in one place.
The text was updated successfully, but these errors were encountered:
Been working on this - at the tree sequence level we don't have easy access to the raw bytes metadata if there is a schema in place. I'm tempted to remove the base64 option and print the metadata as JSON by default, unless there is no schema in which case we print base64 encoded bytes.
I'm tempted to remove the base64 option and print the metadata as JSON by default, unless there is no schema in which case we print base64 encoded bytes.
What if we changed the definition slightly to "base64 encode the metadata if no schema is present". That'll still be compatible with old code. We can either ignore base64 if a schema is present or raise an error if it's True, depending on whether the default in the signature is None or True.
gives
I guess the right behaviour here is to make the
base64_metadata
option default to None, and to output decoded metadata as JSON if a schema is present (by default) and base64 encode it otherwise. If base64_metadata is True, then we output the raw bytes always.We should move the implementation of this function to
text_formats.py
while we're fixing it up too, to try and downsize trees.py a bit and keep all the text processing stuff in one place.The text was updated successfully, but these errors were encountered: