|
| 1 | +.. _contributing_new_code: |
| 2 | + |
| 3 | +How to contribute new code |
| 4 | +========================== |
| 5 | + |
| 6 | +The basics |
| 7 | +~~~~~~~~~~ |
| 8 | + |
| 9 | +Contributors to pvlib-python use GitHub's pull requests to add/modify |
| 10 | +its source code. The GitHub pull request process can be intimidating for |
| 11 | +new users, but you'll find that it becomes straightforward once you use |
| 12 | +it a few times. Please let us know if you get stuck at any point in the |
| 13 | +process. Here's an outline of the process: |
| 14 | + |
| 15 | +#. Create a GitHub issue and get initial feedback from users and |
| 16 | + maintainers. If the issue is a bug report, please include the |
| 17 | + code needed to reproduce the problem. |
| 18 | +#. Obtain the latest version of pvlib-python: Fork the pvlib-python |
| 19 | + project to your GitHub account, ``git clone`` your fork to your computer. |
| 20 | +#. Make some or all of your changes/additions and ``git commit`` them to |
| 21 | + your local repository. |
| 22 | +#. Share your changes with us via a pull request: ``git push`` your |
| 23 | + local changes to your GitHub fork, then go to GitHub make a pull |
| 24 | + request. |
| 25 | + |
| 26 | +The Pandas project maintains an excellent `contributing page |
| 27 | +<http://pandas.pydata.org/pandas-docs/stable/contributing.html>`_ that goes |
| 28 | +into detail on each of these steps. Also see GitHub's `Set Up Git |
| 29 | +<https://help.github.com/articles/set-up-git/>`_ and `Using Pull |
| 30 | +Requests <https://help.github.com/articles/using-pull-requests/>`_. |
| 31 | + |
| 32 | +You must include documentation and unit tests for any new or improved |
| 33 | +code. We can provide help and advice on this after you start the pull |
| 34 | +request. See the :ref:`documentation` and :ref:`testing` sections for more |
| 35 | +information on these aspects. |
| 36 | + |
| 37 | + |
| 38 | +.. _pull-requests: |
| 39 | + |
| 40 | +Pull requests (PRs) |
| 41 | +~~~~~~~~~~~~~~~~~~~ |
| 42 | + |
| 43 | +.. _pull-request-scope: |
| 44 | + |
| 45 | +Scope |
| 46 | +----- |
| 47 | + |
| 48 | +This section can be summed up as "less is more". |
| 49 | + |
| 50 | +A pull request can quickly become unmanageable if too many lines are |
| 51 | +added or changed. "Too many" is hard to define, but as a rule of thumb, |
| 52 | +we encourage contributions that contain less than 50 lines of primary code. |
| 53 | +50 lines of primary code will typically need at least 250 lines |
| 54 | +of documentation and testing. This is about the limit of what the |
| 55 | +maintainers can review on a regular basis. |
| 56 | + |
| 57 | +A pull request can also quickly become unmanageable if it proposes |
| 58 | +changes to the API in order to implement another feature. Consider |
| 59 | +clearly and concisely documenting all proposed API changes before |
| 60 | +implementing any code. Modifying |
| 61 | +`api.rst <https://github.com/pvlib/pvlib-python/tree/main/docs/sphinx/source/reference>`_ |
| 62 | +and/or the latest `whatsnew file <https://github.com/pvlib/pvlib-python/tree/main/docs/sphinx/source/whatsnew>`_ |
| 63 | +can help formalize this process. |
| 64 | + |
| 65 | +Questions about related issues frequently come up in the process of |
| 66 | +addressing implementing code for a pull request. Please try to avoid |
| 67 | +expanding the scope of your pull request (this also applies to |
| 68 | +reviewers!). We'd rather see small, well-documented additions to the |
| 69 | +project's technical debt than see a pull request languish because its |
| 70 | +scope expanded beyond what the reviewer community is capable of |
| 71 | +processing. |
| 72 | + |
| 73 | +Of course, sometimes it is necessary to make a large pull request. We |
| 74 | +only ask that you take a few minutes to consider how to break it into |
| 75 | +smaller chunks before proceeding. |
| 76 | + |
| 77 | +pvlib-python contains :ref:`3 "layers" of code <modeling-paradigms>`: |
| 78 | +functions, PVSystem/Location, and ModelChain. We recommend that |
| 79 | +contributors focus their work on only one or two of those layers in a |
| 80 | +single pull request. New models are *not* required to be available to |
| 81 | +the higher-level API! |
| 82 | + |
| 83 | + |
| 84 | +When should I submit a pull request? |
| 85 | +------------------------------------ |
| 86 | + |
| 87 | +The short answer: anytime. |
| 88 | + |
| 89 | +The long answer: it depends. If in doubt, go ahead and submit. You do |
| 90 | +not need to make all of your changes before creating a pull request. |
| 91 | +Your pull requests will automatically be updated when you commit new |
| 92 | +changes and push them to GitHub. |
| 93 | + |
| 94 | +There are pros and cons to submitting incomplete pull-requests. On the |
| 95 | +plus side, it gives everybody an easy way to comment on the code and can |
| 96 | +make the process more efficient. On the minus side, it's easy for an |
| 97 | +incomplete pull request to grow into a multi-month saga that leaves |
| 98 | +everyone unhappy. If you submit an incomplete pull request, please be |
| 99 | +very clear about what you would like feedback on and what we should |
| 100 | +ignore. Alternatives to incomplete pull requests include creating a |
| 101 | +`gist <https://gist.github.com>`_ or experimental branch and linking to |
| 102 | +it in the corresponding issue. |
| 103 | + |
| 104 | +The best way to ensure that a pull request will be reviewed and merged in |
| 105 | +a timely manner is to: |
| 106 | + |
| 107 | +#. Start by creating an issue. The issue should be well-defined and |
| 108 | + actionable. |
| 109 | +#. Ask the `maintainers <https://github.com/orgs/pvlib/people>`_ to tag |
| 110 | + the issue with the appropriate milestone. |
| 111 | +#. Make a limited-scope pull request. It can be a lot of work to check all of |
| 112 | + the boxes in `pull request guidelines |
| 113 | + <https://github.com/pvlib/pvlib-python/blob/main/.github/PULL_REQUEST_TEMPLATE.md>`_, |
| 114 | + especially for pull requests with a lot of new primary code. |
| 115 | + See :ref:`pull-request-scope`. |
| 116 | +#. Tag pvlib community members or ``@pvlib`` when the pull |
| 117 | + request is ready for review. (see :ref:`pull-request-reviews`) |
| 118 | + |
| 119 | + |
| 120 | +.. _pull-request-reviews: |
| 121 | + |
| 122 | +Pull request reviews |
| 123 | +-------------------- |
| 124 | + |
| 125 | +The pvlib community and maintainers will review your pull request in a |
| 126 | +timely fashion. Please "ping" ``@pvlib`` if it seems that |
| 127 | +your pull request has been forgotten at any point in the pull request |
| 128 | +process. |
| 129 | + |
| 130 | +Keep in mind that the PV modeling community is diverse and each pvlib |
| 131 | +community member brings a different perspective when reviewing code. |
| 132 | +Some reviewers bring years of expertise in the sub-field that your code |
| 133 | +contributes to and will focus on the details of the algorithm. Other |
| 134 | +reviewers will be more focused on integrating your code with the rest of |
| 135 | +pvlib, ensuring that it is feasible to maintain, that it meets the |
| 136 | +:ref:`code style <code-style>` guidelines, and that it is |
| 137 | +:ref:`comprehensively tested <testing>`. Limiting the scope of the pull |
| 138 | +request makes it much more likely that all of these reviews can be |
| 139 | +conducted and any issues can be resolved in a timely fashion. |
| 140 | + |
| 141 | +Sometimes it's hard for reviewers to be immediately available, so the |
| 142 | +right amount of patience is to be expected. That said, interested |
| 143 | +reviewers should do their best to not wait until the last minute to put |
| 144 | +in their two cents. |
| 145 | + |
| 146 | + |
| 147 | +.. _virtual-environments: |
| 148 | + |
| 149 | +Virtual environments |
| 150 | +~~~~~~~~~~~~~~~~~~~~ |
| 151 | + |
| 152 | +We strongly recommend using virtual environments for development. |
| 153 | +Virtual environments make it easier to switch between different |
| 154 | +versions of software. This `scientific-python.org guide |
| 155 | +<https://learn.scientific-python.org/development/tutorials/dev-environment/>`_ |
| 156 | +is a good reference for virtual environments. The pvlib-python `installation |
| 157 | +user guide <https://pvlib-python.readthedocs.io/en/stable/user_guide/ |
| 158 | +installation.html#set-up-a-virtual-environment>`_ also provides instructions on |
| 159 | +setting up a virtual environment. If this is your first pull request, don't |
| 160 | +worry about using a virtual environment. |
0 commit comments