Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Streaming]Add streaming key features introduction #8

Merged
merged 9 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions README.md

This file was deleted.

120 changes: 120 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
.. image:: streaming/assets/infinite.svg
:target: streaming/assets/infinite.svg
:alt: mobius

Mobius : Online Machine Learning.
============
`Mobius <https://tech.antfin.com/products/ARCMOBIUS>`_ is an AI infra platform including realtime computing and training.

Ray Streaming
=============

Ray Streaming is a streaming data processing framework built on ray. It will be helpful for you to build machine learning jobs dealing with real-time data.

Key Features
------------


#.
**Cross Language**. Based on Ray's multi-language actor, Ray Streaming can also run in multiple
languages(only Python and Java is supported currently) with high efficiency. You can implement your
operator in different languages and run them in one job.

#.
**Single Node Failover**. We designed a special failover mechanism that only needs to rollback the
failed node it's own, in most cases, to recover the job. This will be a huge benefit if your job is
sensitive about failure recovery time. In other frameworks like Flink, instead, the entire job should
be restarted once a node has failure.

#.
**AutoScaling**. (Moved from internal in the future). Generate a new graph with different configurations in runtime without stopping job.

#.
**Fusion Training**. (Moved from internal in the future). Combine TensorFlow/Pytorch and streaming, then buiding an e2e online machine
learning pipeline.

Examples
--------

Python
^^^^^^

.. code-block:: Python

import ray
from ray.streaming import StreamingContext

ctx = StreamingContext.Builder() \
.build()
ctx.read_text_file(__file__) \
.set_parallelism(1) \
.flat_map(lambda x: x.split()) \
.map(lambda x: (x, 1)) \
.key_by(lambda x: x[0]) \
.reduce(lambda old_value, new_value:
(old_value[0], old_value[1] + new_value[1])) \
.filter(lambda x: "ray" not in x) \
.sink(lambda x: print("result", x))
ctx.submit("word_count")

Java
^^^^

.. code-block:: Java

StreamingContext context = StreamingContext.buildContext();
List<String> text = Collections.singletonList("hello world");
DataStreamSource.fromCollection(context, text)
.flatMap((FlatMapFunction<String, WordAndCount>) (value, collector) -> {
String[] records = value.split(" ");
for (String record : records) {
collector.collect(new WordAndCount(record, 1));
}
})
.filter(pair -> !pair.word.contains("world"))
.keyBy(pair -> pair.word)
.reduce((oldValue, newValue) ->
new WordAndCount(oldValue.word, oldValue.count + newValue.count))
.sink(result -> System.out.println("sink result=" + result));
context.execute("testWordCount");

Use Java Operators in Python
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: Python

import ray
from ray.streaming import StreamingContext

ctx = StreamingContext.Builder().build()
ctx.from_values("a", "b", "c") \
.as_java_stream() \
.map("io.ray.streaming.runtime.demo.HybridStreamTest$Mapper1") \
.filter("io.ray.streaming.runtime.demo.HybridStreamTest$Filter1") \
.as_python_stream() \
.sink(lambda x: print("result", x))
ctx.submit("HybridStreamTest")

Use Python Operators in Java
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code-block:: Java

StreamingContext context = StreamingContext.buildContext();
DataStreamSource<String> streamSource =
DataStreamSource.fromCollection(context, Arrays.asList("a", "b", "c"));
streamSource
.map(x -> x + x)
.asPythonStream()
.map("ray.streaming.tests.test_hybrid_stream", "map_func1")
.filter("ray.streaming.tests.test_hybrid_stream", "filter_func1")
.asJavaStream()
.sink(value -> System.out.println("HybridStream sink=" + value));
context.execute("HybridStreamTestJob");



Training
-----------

To be published
1 change: 1 addition & 0 deletions streaming/assets/infinite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.