From 6d83fcc65906ffcc03ec769ac020469bea2e5985 Mon Sep 17 00:00:00 2001 From: mubai Date: Wed, 17 Nov 2021 19:31:07 +0800 Subject: [PATCH] add zh documents --- README.rst | 34 ++++-- docs/source/index.rst | 6 + docs/source/installation/ray.rst | 45 +++++--- docs/source/locale/zh_CN/LC_MESSAGES/index.po | 30 +++-- .../zh_CN/LC_MESSAGES/installation/ray.po | 107 ++++++++++++++++++ 5 files changed, 187 insertions(+), 35 deletions(-) create mode 100644 docs/source/locale/zh_CN/LC_MESSAGES/installation/ray.po diff --git a/README.rst b/README.rst index 631bd52649..114a403723 100644 --- a/README.rst +++ b/README.rst @@ -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://:') - >>> # perform computation + import mars + mars.new_ray_session('http://:') + # 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. diff --git a/docs/source/index.rst b/docs/source/index.rst index cf8af211e9..9325657cb4 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -168,6 +168,11 @@ DASK on Mars Refer to :ref:`DASK on Mars `. +Mars on Ray +------------ + +Refer to :ref:`Mars on Ray `. + Easy to scale in and scale out ------------------------------ @@ -180,6 +185,7 @@ Mars can run in a few ways: - :ref:`Local scheduling ` - :ref:`Run on cluster ` +- :ref:`Run on Ray ` - :ref:`Run on Kubernetes ` - :ref:`Run on Yarn ` diff --git a/docs/source/installation/ray.rst b/docs/source/installation/ray.rst index 34cc16df9e..3f3d1816d7 100644 --- a/docs/source/installation/ray.rst +++ b/docs/source/installation/ray.rst @@ -3,8 +3,8 @@ Run on Ray ================= -Mars also has deep integration with Ray and can run on `Ray ` efficiently and natively. -Running mars on ray is simple. +Mars also has deep integration with Ray and can run on `Ray `_ efficiently and natively. +Running Mars on Ray is simple. Basic steps ----------- @@ -18,33 +18,41 @@ 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 `: +Or connecting to a existing Ray cluster using `Ray client `_: .. code-block:: python - >> import ray - >> ray.init(address="ray://:10001") + import ray + ray.init(address="ray://: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 @@ -52,6 +60,7 @@ Create a Mars on Ray runtime in the Ray cluster: 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 @@ -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`` | +----------------------+-----------------------------------------------------------+ diff --git a/docs/source/locale/zh_CN/LC_MESSAGES/index.po b/docs/source/locale/zh_CN/LC_MESSAGES/index.po index d449f20050..860ea3f39a 100644 --- a/docs/source/locale/zh_CN/LC_MESSAGES/index.po +++ b/docs/source/locale/zh_CN/LC_MESSAGES/index.po @@ -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 \n" "Language-Team: LANGUAGE \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" @@ -160,10 +160,19 @@ msgid "Refer to :ref:`DASK on Mars `." msgstr "参考 :ref:`DASK on Mars `。" #: ../../source/index.rst:172 +msgid "Mars on Ray" +msgstr "" + +#: ../../source/index.rst:174 +#, fuzzy +msgid "Refer to :ref:`Mars on Ray `." +msgstr "参考 :ref:`Mars on 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 " @@ -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 `" msgstr ":ref:`本地执行 `" -#: ../../source/index.rst:182 +#: ../../source/index.rst:187 msgid ":ref:`Run on cluster `" msgstr ":ref:`在集群中运行 `" -#: ../../source/index.rst:183 +#: ../../source/index.rst:188 +#, fuzzy +msgid ":ref:`Run on Ray `" +msgstr ":ref:`在 Ray 中运行 Mars `" + +#: ../../source/index.rst:189 msgid ":ref:`Run on Kubernetes `" msgstr ":ref:`在 Kubernetes 中部署 `" -#: ../../source/index.rst:184 +#: ../../source/index.rst:190 msgid ":ref:`Run on Yarn `" msgstr ":ref:`在 Yarn 中部署 `" diff --git a/docs/source/locale/zh_CN/LC_MESSAGES/installation/ray.po b/docs/source/locale/zh_CN/LC_MESSAGES/installation/ray.po new file mode 100644 index 0000000000..4852faa57f --- /dev/null +++ b/docs/source/locale/zh_CN/LC_MESSAGES/installation/ray.po @@ -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 , 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 \n" +"Language-Team: LANGUAGE \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 " +"`_ efficiently and natively. Running Mars " +"on Ray is simple." +msgstr "Mars 与 `Ray `_ 进行了深度集成,并可以高效原生地运行在 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 " +"`:" +msgstr "或者使用 `Ray Client `_ 连接到一个已有的集群:" + +#: ../../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 内存,你可以使用下面的代码:" +