File: getting-started.rst

package info (click to toggle)
khmer 2.1.2%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 59,064 kB
  • sloc: cpp: 102,051; python: 19,654; ansic: 677; makefile: 578; sh: 167; xml: 19; javascript: 16
file content (325 lines) | stat: -rw-r--r-- 12,559 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
..
   This file is part of khmer, https://github.com/dib-lab/khmer/, and is
   Copyright (C) 2014-2015 Michigan State University
   Copyright (C) 2015-2016 The Regents of the University of California.
   It is licensed under the three-clause BSD license; see LICENSE.
   Contact: khmer-project@idyll.org

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are
   met:

    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

    * Redistributions in binary form must reproduce the above
      copyright notice, this list of conditions and the following
      disclaimer in the documentation and/or other materials provided
      with the distribution.

    * Neither the name of the Michigan State University nor the names
      of its contributors may be used to endorse or promote products
      derived from this software without specific prior written
      permission.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
   HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

   Contact: khmer-project@idyll.org

Getting started with khmer development
======================================

.. contents::

This document is for people who would like to contribute to khmer.  It
walks first-time contributors through making their own copy of khmer,
building it, and submitting changes for review and merge into the master
copy of khmer.

----

Start by making your own copy of khmer and setting yourself up for
development; then, build khmer and run the tests; and finally, claim
an issue and start developing! If you're unfamiliar with git and branching in
particular, check out the
`git-scm book <http://git-scm.com/book/en/Git-Branching>`__. We've also provided
a quick guide to the khmer code base here: :doc:`codebase-guide`.

One-time Preparation
--------------------

#. Install the dependencies.

   i. Mac users

      a.  Install Xcode with::

             xcode-select --install

      #.  Install `Homebrew <http://brew.sh/>`__ with::

             /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

      #.  Install the python development environment and some additional development packages::

             brew install python astyle gcovr cppcheck enchant
             sudo pip install --upgrade pip virtualenv

   ii. Linux users

       Install the python development environment and some additional
       development packages. On recent versions of Debian or Ubuntu this can
       be done with::

          sudo apt-get install python2.7-dev python-virtualenv python-pip \
          gcc g++ git astyle gcovr cppcheck enchant

       For Red Hat, Fedora, and CentOS::

          sudo yum install -y python-devel python-pip git gcc gcc-c++ make enchant
          sudo pip install virtualenv

#. Create a `GitHub <http://github.com>`__ account.

   We use GitHub to manage khmer contributions.

#. Fork `github.com/dib-lab/khmer <https://github.com/dib-lab/khmer>`__.

   Visit that page, and then click on the 'fork' button (upper right). This
   makes a copy of the khmer source code in your own GitHub account.

#. Clone your copy of khmer to your local development environment.

   Your shell command should look something like::

       git clone https://github.com/your-github-username/khmer.git

   This makes a local copy of khmer on your development machine.

#. Add a git reference to the khmer dib-lab repository::

       cd khmer
       git remote add dib https://github.com/dib-lab/khmer.git

   This makes it easy for you to pull down the latest changes in the
   main repository.

#. Optional: create a virtual Python environment for khmer development

   See the **Virtual Environments** heading in :doc:`guidelines-continued-dev`
   for more details on creating and using a virtual environment for development.
   This is not strictly required but highly recommended, especially if you plan
   to make continued contributions.

#. Install Python dependencies

   From within the khmer directory, invoke the ``make install-dep`` command. If
   you are not using a virtual environment, you may need to invoke ``sudo make
   install-dep`` instead. This will install several packages used in khmer
   testing and development.


Building khmer and running the tests
------------------------------------

#. Build khmer::

      make

   This compiles the C++ source code into something that Python can run. If the
   command fails, we apologize—please `go create a new issue
   <https://github.com/dib-lab/khmer/issues?direction=desc&sort=created&state=open>`__,
   paste in the failure message, and we'll try to help you work through it!

#. Run the tests::

      make test

   This will run all of the Python tests in the ``tests/`` directory. You should
   see lots of output, with something like::

      ====== 1289 passed, 1 skipped, 25 deselected, 1 xpassed in 50.98 seconds =======

   at the end.

Congratulations! You're ready to develop!


Claiming an issue and starting to develop
-----------------------------------------

#. Find an open issue and claim it.

   Go to `the list of open khmer issues
   <https://github.com/dib-lab/khmer/issues?direction=desc&sort=created&state=open>`__
   and find one you like; we suggest starting with `the low-hanging fruit issues <https://github.com/dib-lab/khmer/issues?direction=desc&labels=low-hanging-fruit&page=1&sort=created&state=open>`__).

   Once you've found an issue you like, make sure that no one has been
   assigned to it (see "assignee", bottom right near "notifications").
   Then, add a comment "I am working on this issue." You've staked
   your claim!

   (We're trying to avoid having multiple people working on the same issue.)

#. In your local copy of the source code, update your master branch
   from the main khmer master branch::

      git checkout master
      git pull dib master

   (This pulls in all of the latest changes from whatever we've been
   doing on dib-lab.)

   If git complains about a "merge conflict" when you execute ``git pull``,
   refer to the **Resolving merge conflicts** section of
   :doc:`guidelines-continued-dev`.

#. Create a new branch and link it to your fork on GitHub::

      git checkout -b fix/brief_issue_description
      git push -u origin fix/brief_issue_description

   where you replace "fix/brief_issue_description" with 2-3 words, separated
   by underscores, describing the issue.

   (This is the set of changes you're going to ask to be merged into khmer.)

#. Make some changes and commit them.

   Though this will largely be issue-dependent the basics of committing are
   simple. After you've made a cohesive set of changes, run the command `git
   status`. This will display a list of all the files git has noticed you
   changed. A file in the 'untracked' section are files that haven't existed
   previously in the repository but git has noticed.

   To commit changes you have to 'stage' them—this is done by issuing the
   following command::

      git add path/to/file

   Once you have staged your changes, it's time to make a commit::

      git commit -m 'Here you provide a brief description of your changes'

   Please make your commit message informative but concise - these messages
   become part of the 'official' history of the project.

   Once your changes have been committed, push them up to the remote branch::

      git push origin

   again.

#. Periodically update your branch from the main khmer master branch::

      git pull dib master

   (This pulls in all of the latest changes from whatever we've been
   doing on dib-lab - important especially during periods of fast change
   or for long-running pull requests.)

#. Run the tests and/or build the docs *before* pushing to GitHub::

      make doc test pep8 diff-cover

   Make sure they all pass!

#. Push your branch to your own GitHub fork::

      git push origin

   (This pushes all of your changes to your own fork.)

#. Repeat until you're ready to merge your changes into "official" khmer.

#. Set up a Pull Request asking to merge your changes into the main khmer
   repository.

   In a Web browser, go to your GitHub fork of khmer, e.g.::

      https://github.com/your-github-username/khmer

   and you will see a list of "recently pushed branches" just above the
   source code listing.  On the right side of that should be a
   "Compare & pull request" green button.  Click on it. This will open up a
   submission form with a pull request checklist. In this form:

     * add a descriptive title (e.g. "updated tests for XXX")
     * include any relevant comments about your submission in the main body of
       the pull request text, above the checklist
     * make sure to include any relevant issue numbers in the comments (e.g.
       "fixes issue #532")

   then click "Create pull request."

   (This creates a new issue where we can all discuss your proposed
   changes; the khmer team will be automatically notified and you will
   receive e-mail notifications as we add comments.  See `GitHub flow
   <http://scottchacon.com/2011/08/31/github-flow.html>`__ for more
   info.)

#. Review the pull request checklist and make any necessary additional changes.

   Check off as many of the boxes as you can from the checklist that is
   automatically added to the first comment of the Pull Request
   discussion. If you have an `ORCID ID<https://orcid.org/>` post that
   as well. This will make it much easier for the khmer team to include
   you in khmer publications.

   As you add new commits to address bugs or formatting issues, you can keep
   pushing your changes to the pull request by doing::

      git push origin

#. When you are ready to have the pull request reviewed, please mention
   @luizirber, @camillescott, @standage, @betatim, and/or @ctb with the comment
   'Ready for review!'

#. The khmer team will now review your pull request and communicate
   with you through the pull request page.  Please feel free to add
   'ping!' and an @ in the comments if you are looking for feedback—this
   will alert us that you are still on the line.

   If this is your first issue, please *don't* take another issue until
   we've merged your first one. Thanks!

#. If we request changes, return to the step "Make some changes and
   commit them" and go from there.  Any additional commits you make and
   push to your branch will automatically be added to the pull request.

After your submission passes peer review and the test suite (``make test`` is
run on continuous integration server automatically for each pull request), your
contribution will be merged into the main codebase. Congratulations on making
your first contribution to the khmer library! You're now an experienced GitHub
user and an official khmer contributor!

After your first issue is successfully merged...
------------------------------------------------

Before getting started with your second (or third, or fourth, or nth)
contribution, there are a couple of steps you need to take to clean up your
local copy of the code::

    git checkout master
    git pull dib master
    git branch -d fix/brief_issue_description     # delete the branch locally
    git push origin :fix/brief_issue_description  # delete the branch on your GitHub fork

This will syncronize your local main (master) branch with the central khmer
repository—including your newly integrated contribution—and delete the branch
you used to make your submission.

Now your local copy of the code is queued up for another contribution. If you
find another issue that interests you, go back to the beginning of these
instructions and repeat! You will also want to take a look at
:doc:`guidelines-continued-dev`.