getting-involved.rst 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. .. _getting-involved:
  2. Getting Involved / Contributing
  3. ===============================
  4. Ray is more than a framework for distributed applications but also an active community of developers,
  5. researchers, and folks that love machine learning.
  6. .. tip:: Ask questions on `our forum <https://discuss.ray.io/>`_! The
  7. community is extremely active in helping people succeed in building their
  8. Ray applications.
  9. You can join (and Star!) us on `on GitHub`_.
  10. .. _`on GitHub`: https://github.com/ray-project/ray
  11. Contributing to Ray
  12. -------------------
  13. We welcome (and encourage!) all forms of contributions to Ray, including and not limited to:
  14. - Code reviewing of patches and PRs.
  15. - Pushing patches.
  16. - Documentation and examples.
  17. - Community participation in forums and issues.
  18. - Code readability and code comments to improve readability.
  19. - Test cases to make the codebase more robust.
  20. - Tutorials, blog posts, talks that promote the project.
  21. What can I work on?
  22. -------------------
  23. We use Github to track issues, feature requests, and bugs. Take a look at the
  24. ones labeled `"good first issue" <https://github.com/ray-project/ray/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22>`__ and `"help wanted" <https://github.com/ray-project/ray/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22>`__ for a place to start.
  25. Setting up your development environment
  26. ---------------------------------------
  27. To edit the Ray source code, you'll want to checkout the repository and also build Ray from source. Follow :ref:`these instructions for building <building-ray>` a local copy of Ray to easily make changes.
  28. Submitting and Merging a Contribution
  29. -------------------------------------
  30. There are a couple steps to merge a contribution.
  31. 1. First merge the most recent version of master into your development branch.
  32. .. code:: bash
  33. git remote add upstream https://github.com/ray-project/ray.git
  34. git pull upstream master
  35. 2. Make sure all existing tests `pass <getting-involved.html#testing>`__.
  36. 3. If introducing a new feature or patching a bug, be sure to add new test cases
  37. in the relevant file in `ray/python/ray/tests/`.
  38. 4. Document the code. Public functions need to be documented, and remember to provide an usage
  39. example if applicable.
  40. 5. Request code reviews from other contributors and address their comments. One fast way to get reviews is
  41. to help review others' code so that they return the favor. You should aim to improve the code as much as
  42. possible before the review. We highly value patches that can get in without extensive reviews.
  43. 6. Reviewers will merge and approve the pull request; be sure to ping them if
  44. the pull request is getting stale.
  45. Testing
  46. -------
  47. Even though we have hooks to run unit tests automatically for each pull request,
  48. we recommend you to run unit tests locally beforehand to reduce reviewers’
  49. burden and speedup review process.
  50. .. code-block:: shell
  51. pytest ray/python/ray/tests/
  52. Documentation should be documented in `Google style <https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html>`__ format.
  53. Testing for Python development
  54. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. Suppose that one of the tests in a file of tests, e.g.,
  56. ``python/ray/tests/test_basic.py``, is failing. You can run just that
  57. test file locally as follows:
  58. .. code-block:: shell
  59. python -m pytest -v python/ray/tests/test_basic.py
  60. However, this will run all of the tests in the file, which can take some
  61. time. To run a specific test that is failing, you can do the following
  62. instead:
  63. .. code-block:: shell
  64. pytest test_file.py -v -k [test substring]
  65. When running tests, usually only the first test failure matters. A single
  66. test failure often triggers the failure of subsequent tests in the same
  67. file.
  68. .. code-block:: shell
  69. # Stop after first failure.
  70. pytest test_file.py -x
  71. Testing for C++ development
  72. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73. To compile and run all C++ tests, you can run:
  74. .. code-block:: shell
  75. bazel test $(bazel query 'kind(cc_test, ...)')
  76. Alternatively, you can also run one specific C++ test. You can use:
  77. .. code-block:: shell
  78. bazel test $(bazel query 'kind(cc_test, ...)') --test_filter=ClientConnectionTest --test_output=streamed
  79. Lint and Formatting
  80. ~~~~~~~~~~~~~~~~~~~
  81. .. note:: Python 3.7 is recommended. You will run into flake8 `issues <https://github.com/ray-project/ray/pull/11588>`_ with Python 3.8.
  82. We also have tests for code formatting and linting that need to pass before merge.
  83. Install ``yapf==0.23, flake8, flake8-quotes``.
  84. * `yapf <https://github.com/google/yapf>`_ version ``0.23.0`` (``pip install yapf==0.23.0``)
  85. * `flake8 <https://flake8.pycqa.org/en/latest/>`_ version ``3.7.7`` (``pip install flake8==3.7.7``)
  86. * `flake8-quotes <https://github.com/zheller/flake8-quotes>`_ (``pip install flake8-quotes``)
  87. * If developing for C++, you will need `clang-format <https://www.kernel.org/doc/html/latest/process/clang-format.html>`_ version ``7.0.0`` (download this version of Clang from `here <http://releases.llvm.org/download.html>`_)
  88. .. note:: On MacOS X, don't use HomeBrew to install ``clang-format``, as the only version available is too new.
  89. You can run the following locally:
  90. .. code-block:: shell
  91. ./ci/travis/format.sh
  92. An output like the following indicates failure:
  93. .. code-block:: shell
  94. WARNING: clang-format is not installed! # This is harmless
  95. From https://github.com/ray-project/ray
  96. * branch master -> FETCH_HEAD
  97. python/ray/util/sgd/tf/tf_runner.py:4:1: F401 'numpy as np' imported but unused # Below is the failure
  98. In addition, there are other formatting checkers for components like the following:
  99. * Python README format:
  100. .. code-block:: shell
  101. cd python
  102. python setup.py check --restructuredtext --strict --metadata
  103. * Bazel format:
  104. .. code-block:: shell
  105. ./ci/travis/bazel-format.sh
  106. Understanding CI test jobs
  107. --------------------------
  108. The Ray project automatically runs continuous integration (CI) tests once a PR
  109. is opened using `Travis-CI <https://travis-ci.com/ray-project/ray/>`_ with
  110. multiple CI test jobs.
  111. The `Travis CI`_ test folder contains all integration test scripts and they
  112. invoke other test scripts via ``pytest``, ``bazel``-based test or other bash
  113. scripts. Some of the examples include:
  114. * Raylet integration tests commands:
  115. * ``bazel test //:core_worker_test``
  116. * Bazel test command:
  117. * ``bazel test --build_tests_only //:all``
  118. * Ray serving test commands:
  119. * ``pytest python/ray/serve/tests``
  120. * ``python python/ray/serve/examples/echo_full.py``
  121. If a Travis-CI build exception doesn't appear to be related to your change,
  122. please visit `this link <https://ray-travis-tracker.herokuapp.com/>`_ to
  123. check recent tests known to be flaky.
  124. .. _`Travis CI`: https://github.com/ray-project/ray/tree/master/ci/travis
  125. Becoming a Reviewer
  126. -------------------
  127. We identify reviewers from active contributors. Reviewers are individuals who
  128. not only actively contribute to the project and are also willing
  129. to participate in the code review of new contributions.
  130. A pull request to the project has to be reviewed by at least one reviewer in order to be merged.
  131. There is currently no formal process, but active contributors to Ray will be
  132. solicited by current reviewers.
  133. More Resources for Getting Involved
  134. -----------------------------------
  135. .. include:: ray-overview/involvement.rst
  136. .. note::
  137. These tips are based off of the TVM `contributor guide <https://github.com/dmlc/tvm>`__.