serialization

how do you configure `celery` to use serializer 'pickle'?

how do you configure `celery` to use serializer 'pickle'? Question: on the tasks.py side i do: app = Celery( main=’tasks’, backend=’rpc://’, broker=’pyamqp://USERNAME:PASSWORD@localhost’, ) app.conf.task_serializer = ‘pickle’ app.conf.result_serializer = ‘pickle’ app.conf.event_serializer = ‘pickle’ app.conf.accept_content = [‘pickle’] app.conf.task_accept_content = [‘pickle’] app.conf.result_accept_content = [‘pickle’] app.conf.event_accept_content = [‘pickle’] when i start two workers manually i via: celery –app tasks …

Total answers: 1

Custom json serializer for JSON column in SQLAlchemy

Custom json serializer for JSON column in SQLAlchemy Question: I have following ORM object (simplified): import datetime as dt from sqlalchemy import create_engine, Integer, Column, DateTime from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.orm import Session, declarative_base Base = declarative_base() class Metrics(Base): __tablename__ = ‘metrics’ id = Column(Integer, primary_key=True) ts = Column(DateTime, default=dt.datetime.now()) computed_values = Column(JSONB) dates …

Total answers: 1

How to serialise and deserialise complex POCO data structures in Python to/from JSON

How to serialise and deserialise complex POCO data structures in Python to/from JSON Question: We have been researching this for hours now, with no luck, there are many ways to serialise and deserialise objects in Python, but we need a simple and standard one that respects typings, for example: from typings import List, NamedTuple class …

Total answers: 4

Pydantic enum field does not get converted to string

Pydantic enum field does not get converted to string Question: I am trying to restrict one field in a class to an enum. However, when I try to get a dictionary out of class, it doesn’t get converted to string. Instead it retains the enum. I checked pydantic documentation, but couldn’t find anything relevant to …

Total answers: 3

How do you save a Tensorflow dataset to a file?

How do you save a Tensorflow dataset to a file? Question: There are at least two more questions like this on SO but not a single one has been answered. I have a dataset of the form: <TensorSliceDataset shapes: ((512,), (512,), (512,), ()), types: (tf.int32, tf.int32, tf.int32, tf.int32)> and another of the form: <BatchDataset shapes: …

Total answers: 6

json serialization of a list of objects of a custom class

json serialization of a list of objects of a custom class Question: I have a song class, which holds the attributes to a song, and it is a custom class. I also have a list of songs in a list called track list. When I try to json.dump the list, I get an error that …

Total answers: 1

How I can serialize the json in Python?

How I can serialize the json in Python? Question: Here is the code and the error follows: import numpy as np import json X=np.arange(20) t=dict(x=list(X)) print(json.dumps(t)) The error is: Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “C:Python35libjson__init__.py”, line 230, in dumps return _default_encoder.encode(obj) File “C:Python35libjsonencoder.py”, line 199, in encode chunks …

Total answers: 4

What is the difference between .pt, .pth and .pwf extentions in PyTorch?

What is the difference between .pt, .pth and .pwf extentions in PyTorch? Question: I have seen in some code examples, that people use .pwf as model file saving format. But in PyTorch documentation .pt and .pth are recommended. I used .pwf and worked fine for small 1->16->16 convolutional network. My question is what is the …

Total answers: 3