Open pschwede opened 11 years ago
InvalidDocument Traceback (most recent call last) Cell In[47], line 1 ----> 1 collection.insert_many(c360_list)
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\collection.py:770, in Collection.insert_many(self, documents, ordered, bypass_document_validation, session) 768 blk = _Bulk(self, ordered, bypass_document_validation) 769 blk.ops = [doc for doc in gen()] --> 770 blk.execute(write_concern, session=session) 771 return InsertManyResult(inserted_ids, write_concern.acknowledged)
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\bulk.py:529, in _Bulk.execute(self, write_concern, session) 527 self.execute_no_results(sock_info, generator) 528 else: --> 529 return self.execute_command(generator, write_concern, session)
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\bulk.py:360, in _Bulk.execute_command(self, generator, write_concern, session) 358 client = self.collection.database.client 359 with client._tmp_session(session) as s: --> 360 client._retry_with_session( 361 self.is_retryable, retryable_bulk, s, self) 363 if full_result["writeErrors"] or full_result["writeConcernErrors"]: 364 _raise_bulk_write_error(full_result)
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\mongo_client.py:1438, in MongoClient._retry_with_session(self, retryable, func, session, bulk) 1429 """Execute an operation with at most one consecutive retries 1430 1431 Returns func()'s return value on success. On error retries the same (...) 1434 Re-raises any exception thrown by func(). 1435 """ 1436 retryable = (retryable and self.retry_writes 1437 and session and not session.in_transaction) -> 1438 return self._retry_internal(retryable, func, session, bulk)
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\mongo_client.py:1470, in MongoClient._retry_internal(self, retryable, func, session, bulk) 1468 raise last_error 1469 retryable = False -> 1470 return func(session, sock_info, retryable) 1471 except ServerSelectionTimeoutError: 1472 if is_retrying(): 1473 # The application may think the write was never attempted 1474 # if we raise ServerSelectionTimeoutError on the retry 1475 # attempt. Raise the original exception instead.
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\bulk.py:354, in _Bulk.execute_command.
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\bulk.py:310, in _Bulk._execute_command(self, generator, write_concern, session, sock_info, op_id, retryable, full_result) 308 ops = islice(run.ops, run.idx_offset, None) 309 # Run as many ops as possible in one command. --> 310 result, to_send = bwc.execute(ops, client) 312 # Retryable writeConcernErrors halt the execution of this run. 313 wce = result.get('writeConcernError', {})
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\message.py:949, in _BulkWriteContext.execute(self, docs, client) 948 def execute(self, docs, client): --> 949 request_id, msg, to_send = self._batch_command(docs) 950 result = self.write_command(request_id, msg, to_send) 951 client._process_response(result, self.session)
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\message.py:941, in _BulkWriteContext._batch_command(self, docs) 939 def _batch_command(self, docs): 940 namespace = self.db_name + '.$cmd' --> 941 request_id, msg, to_send = _do_bulk_write_command( 942 namespace, self.op_type, self.command, docs, self.check_keys, 943 self.codec, self) 944 if not to_send: 945 raise InvalidOperation("cannot do an empty bulk write")
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\message.py:1443, in _do_bulk_write_command(namespace, operation, command, docs, check_keys, opts, ctx) 1441 """Bulk write commands entry point.""" 1442 if ctx.sock_info.max_wire_version > 5: -> 1443 return _do_batched_op_msg( 1444 namespace, operation, command, docs, check_keys, opts, ctx) 1445 return _do_batched_write_command( 1446 namespace, operation, command, docs, check_keys, opts, ctx)
File C:\ProgramData\Anaconda3\lib\site-packages\pymongo\message.py:1368, in _do_batched_op_msg(namespace, operation, command, docs, check_keys, opts, ctx) 1365 if ctx.sock_info.compression_context: 1366 return _batched_op_msg_compressed( 1367 operation, command, docs, check_keys, ack, opts, ctx) -> 1368 return _batched_op_msg( 1369 operation, command, docs, check_keys, ack, opts, ctx)
InvalidDocument: cannot encode object: datetime.date(2021, 1, 1), of type: <class 'datetime.date'>
I call
src/main.py data data/tasks/test_task.json
and sometimes get this: