Skip to content

Commit

Permalink
add zh documents
Browse files Browse the repository at this point in the history
  • Loading branch information
chaokunyang committed Nov 17, 2021
1 parent 25adec4 commit 6d83fcc
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 35 deletions.
34 changes: 25 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,37 @@ Starting a new Mars on Ray runtime locally via:

.. code-block:: python
>>> import ray
>>> ray.init()
>>> import mars
>>> mars.new_ray_session(worker_num=2)
>>> import mars.tensor as mt
>>> mt.random.RandomState(0).rand(1000_0000, 5).sum().execute()
import ray
ray.init()
import mars
mars.new_ray_session(worker_num=2)
import mars.tensor as mt
mt.random.RandomState(0).rand(1000_0000, 5).sum().execute()
Or connecting to a Mars on Ray cluster which is already initialized.

.. code-block:: python
>>> import mars
>>> mars.new_ray_session('http://<web_ip>:<ui_port>')
>>> # perform computation
import mars
mars.new_ray_session('http://<web_ip>:<ui_port>')
# perform computation
Interact with Ray Dataset:

.. code-block:: python
import mars.tensor as mt
import mars.dataframe as md
df = md.DataFrame(
mt.random.rand(1000_0000, 4),
columns=list('abcd'))
# Convert mars dataframe to ray dataset
ds = md.to_ray_dataset(df)
print(ds.schema(), ds.count())
ds.filter(lambda row: row["a"] > 0.5).show(5)
# Convert ray dataset to mars dataframe
df2 = md.read_ray_dataset(ds)
print(df2.head(5).execute())
Refer to `Mars on Ray`_ for more information.

Expand Down
6 changes: 6 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ DASK on Mars

Refer to :ref:`DASK on Mars <integrate_dask>`.

Mars on Ray
------------

Refer to :ref:`Mars on Ray <ray>`.

Easy to scale in and scale out
------------------------------

Expand All @@ -180,6 +185,7 @@ Mars can run in a few ways:

- :ref:`Local scheduling <local>`
- :ref:`Run on cluster <deploy>`
- :ref:`Run on Ray <ray>`
- :ref:`Run on Kubernetes <k8s>`
- :ref:`Run on Yarn <mars_yarn>`

Expand Down
45 changes: 27 additions & 18 deletions docs/source/installation/ray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Run on Ray
=================

Mars also has deep integration with Ray and can run on `Ray <https://docs.ray.io/en/latest/>` efficiently and natively.
Running mars on ray is simple.
Mars also has deep integration with Ray and can run on `Ray <https://docs.ray.io/en/latest/>`_ efficiently and natively.
Running Mars on Ray is simple.

Basic steps
-----------
Expand All @@ -18,40 +18,49 @@ Start a Ray cluster:

.. code-block:: python
>> import ray
>> ray.init()
import ray
ray.init()
Or connecting to a existing Ray cluster using `Ray client <https://docs.ray.io/en/latest/cluster/ray-client.html>`:
Or connecting to a existing Ray cluster using `Ray client <https://docs.ray.io/en/latest/cluster/ray-client.html>`_:

.. code-block:: python
>> import ray
>> ray.init(address="ray://<head_node_host>:10001")
import ray
ray.init(address="ray://<head_node_host>:10001")
Creating Mars on Ray runtime in the Ray cluster and do the computing:

.. code-block:: python
>>> import mars
>>> import mars.tensor as mt
>>> session = mars.new_ray_session(worker_num=2, worker_mem=2 * 1024 ** 3)
>>> mt.random.RandomState(0).rand(1000_0000, 5).sum().execute()
>>> session.execute(mt.random.RandomState(0).rand(100, 5).sum())
>>> df = md.DataFrame(
>>> mt.random.rand(1000_0000, 4, chunk_size=500_0000),
>>> columns=list('abcd'))
>>> print(df.sum().execute())
>>> print(df.describe().execute())
import mars
import mars.tensor as mt
import mars.dataframe as md
session = mars.new_ray_session(worker_num=2, worker_mem=2 * 1024 ** 3)
mt.random.RandomState(0).rand(1000_0000, 5).sum().execute()
df = md.DataFrame(
mt.random.rand(1000_0000, 4, chunk_size=500_0000),
columns=list('abcd'))
print(df.sum().execute())
print(df.describe().execute())
# Convert mars dataframe to ray dataset
ds = md.to_ray_dataset(df)
print(ds.schema(), ds.count())
ds.filter(lambda row: row["a"] > 0.5).show(5)
# Convert ray dataset to mars dataframe
df2 = md.read_ray_dataset(ds)
print(df2.head(5).execute())
Create a Mars on Ray runtime in the Ray cluster:

.. code-block:: python
import mars
import mars.tensor as mt
cluster = mars.new_cluster_in_ray(worker_num=2, worker_mem=2 * 1024 ** 3)
Connect to the created Mars on Ray runtime and do the computing:

.. code-block:: python
import mars
Expand All @@ -76,7 +85,7 @@ Arguments for supervisors:
+----------------------+-----------------------------------------------------------+
| Argument | Description |
+======================+===========================================================+
| supervisor_mem | Memory size for supervisors in the cluster, in bytes |
| supervisor_mem | Memory size for supervisor in the cluster, in bytes |
| | or size units like ``1g`` |
+----------------------+-----------------------------------------------------------+

Expand Down
30 changes: 22 additions & 8 deletions docs/source/locale/zh_CN/LC_MESSAGES/index.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ msgid ""
msgstr ""
"Project-Id-Version: mars \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-29 00:57+0800\n"
"POT-Creation-Date: 2021-11-17 17:55+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.8.0\n"
"Generated-By: Babel 2.9.1\n"

#: ../../source/index.rst:5
msgid "Mars Documentation"
Expand Down Expand Up @@ -160,10 +160,19 @@ msgid "Refer to :ref:`DASK on Mars <integrate_dask>`."
msgstr "参考 :ref:`DASK on Mars <integrate_dask>`。"

#: ../../source/index.rst:172
msgid "Mars on Ray"
msgstr ""

#: ../../source/index.rst:174
#, fuzzy
msgid "Refer to :ref:`Mars on Ray <ray>`."
msgstr "参考 :ref:`Mars on Ray <ray>`。"

#: ../../source/index.rst:177
msgid "Easy to scale in and scale out"
msgstr "适应各种数据规模"

#: ../../source/index.rst:174
#: ../../source/index.rst:179
msgid ""
"Mars can scale in to a single machine, and scale out to a cluster with "
"hundreds of machines. Both the local and distributed version share the "
Expand All @@ -174,23 +183,28 @@ msgstr ""
"两种环境下可使用相同的代码。因此,Mars 可以方便地从单台机器迁移到集群,以"
"处理更多数据或者获得更好的性能。"

#: ../../source/index.rst:179
#: ../../source/index.rst:184
msgid "Mars can run in a few ways:"
msgstr "Mars 能以若干种方式运行:"

#: ../../source/index.rst:181
#: ../../source/index.rst:186
msgid ":ref:`Local scheduling <local>`"
msgstr ":ref:`本地执行 <local>`"

#: ../../source/index.rst:182
#: ../../source/index.rst:187
msgid ":ref:`Run on cluster <deploy>`"
msgstr ":ref:`在集群中运行 <deploy>`"

#: ../../source/index.rst:183
#: ../../source/index.rst:188
#, fuzzy
msgid ":ref:`Run on Ray <ray>`"
msgstr ":ref:`在 Ray 中运行 Mars <ray>`"

#: ../../source/index.rst:189
msgid ":ref:`Run on Kubernetes <k8s>`"
msgstr ":ref:`在 Kubernetes 中部署 <k8s>`"

#: ../../source/index.rst:184
#: ../../source/index.rst:190
msgid ":ref:`Run on Yarn <mars_yarn>`"
msgstr ":ref:`在 Yarn 中部署 <k8s>`"

107 changes: 107 additions & 0 deletions docs/source/locale/zh_CN/LC_MESSAGES/installation/ray.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) 1999-2020, The Alibaba Group Holding Ltd.
# This file is distributed under the same license as the mars package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2021.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: mars 0.8.0rc1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-05 11:41+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.9.1\n"

#: ../../source/installation/ray.rst:4
msgid "Run on Ray"
msgstr "在 Ray 中运行 Mars"

#: ../../source/installation/ray.rst:6
msgid ""
"Mars also has deep integration with Ray and can run on `Ray "
"<https://docs.ray.io/en/latest/>`_ efficiently and natively. Running Mars "
"on Ray is simple."
msgstr "Mars 与 `Ray <https://docs.ray.io/en/latest/>`_ 进行了深度集成,并可以高效原生地运行在 Ray 上,"
"在 Ray 上运行 Mars 很简单。"

#: ../../source/installation/ray.rst:10
msgid "Basic steps"
msgstr "基本步骤"

#: ../../source/installation/ray.rst:11
msgid "Install Ray locally:"
msgstr "在本地安装 Ray :"

#: ../../source/installation/ray.rst:17
msgid "Start a Ray cluster:"
msgstr "启动 Ray 集群:"

#: ../../source/installation/ray.rst:24
msgid ""
"Or connecting to a existing Ray cluster using `Ray client "
"<https://docs.ray.io/en/latest/cluster/ray-client.html>`:"
msgstr "或者使用 `Ray Client <https://docs.ray.io/en/latest/cluster/ray-client.html>`_ 连接到一个已有的集群:"

#: ../../source/installation/ray.rst:31
msgid "Creating Mars on Ray runtime in the Ray cluster and do the computing:"
msgstr "创建 Mars on Ray 运行时并执行计算:"

#: ../../source/installation/ray.rst:54
msgid "Create a Mars on Ray runtime in the Ray cluster:"
msgstr "在 Ray 集群里面创建 Mars on Ray运行时:"

#: ../../source/installation/ray.rst:62
msgid "Connect to the created Mars on Ray runtime and do the computing:"
msgstr "连接到创建的 Mars on Ray 运行时并执行计算:"

#: ../../source/installation/ray.rst:71
msgid "Stop the created Mars on Ray runtime:"
msgstr "停止 Mars on Ray 运行时:"

#: ../../source/installation/ray.rst:79
msgid "Customizing cluster"
msgstr "自定义集群"

#: ../../source/installation/ray.rst:80
msgid ""
"``new_ray_session``/``new_cluster_in_ray`` function provides several "
"keyword arguments for users to define the cluster."
msgstr "``new_ray_session``/``new_cluster_in_ray`` 函数提供了几个用于自定义集群的关键字参数。"

#: ../../source/installation/ray.rst:83
msgid "Arguments for supervisors:"
msgstr "Supervisor 相关参数:"

#: ../../source/installation/ray.rst:86
msgid "Argument"
msgstr "参数"

#: ../../source/installation/ray.rst:86
msgid "Description"
msgstr "描述"

#: ../../source/installation/ray.rst:88
msgid "supervisor_mem"
msgstr ""

#: ../../source/installation/ray.rst:88
msgid ""
"Memory size for supervisor in the cluster, in bytes or size units like "
"``1g``"
msgstr "Supervisor 的内存大小,可使用字节数或带单位的大小,例如 1g"

#: ../../source/installation/ray.rst:92
msgid "Arguments for workers:"
msgstr "Worker 相关参数:"

#: ../../source/installation/ray.rst:104
msgid ""
"For instance, if you want to create a Mars cluster with 100 workers, each"
" worker has 4 cores and 16GB memory, you can use the code below:"
msgstr "比如你想创建一个100个 Worker 的 Mars 集群,每个 Worker 拥有 4 核 16GB 内存,你可以使用下面的代码:"

0 comments on commit 6d83fcc

Please sign in to comment.