ray.data.datasource.MongoDatasource#

class ray.data.datasource.MongoDatasource(*args, **kwds)[source]#

Datasource for reading from and writing to MongoDB.

Examples

>>> import ray
>>> from ray.data.datasource import MongoDatasource
>>> from pymongoarrow.api import Schema 
>>> ds = ray.data.read_datasource( 
...     MongoDatasource(), 
...     uri="mongodb://username:password@mongodb0.example.com:27017/?authSource=admin", # noqa: E501 
...     database="my_db", 
...     collection="my_collection", 
...     schema=Schema({"col1": pa.string(), "col2": pa.int64()}), 
... ) 

PublicAPI (alpha): This API is in alpha and may change before becoming stable.

__init__()#

Methods

__init__()

create_reader(**kwargs)

Return a Reader for the given read arguments.

do_write(blocks, metadata, ray_remote_args, ...)

Launch Ray tasks for writing blocks out to the datasource.

on_write_complete(write_results, **kwargs)

Callback for when a write job completes.

on_write_failed(write_results, error, **kwargs)

Callback for when a write job fails.

prepare_read(parallelism, **read_args)

Deprecated: Please implement create_reader() instead.