Debian Codegraph @

docs/source/contributing.rst

raw ◀ ▶
1 Debian patch touch this file
1 .. _contributing:
2
3 ************************
4 Contributing to kerchunk
5 ************************
6
7 .. note::
8
9 Large parts of this document are based on the
10 `Xarray Contributing Guide <http://docs.xarray.dev/en/stable/contributing.html>`_
11 , the `Pandas Contributing Guide <http://pandas.pydata.org/pandas-docs/stable/contributing.html>`_
12 and the `xbatcher Contributing Guide <https://xbatcher.readthedocs.io/en/latest/contributing.html>`_.
13
14 .. warning::
15 kerchunk is actively in development and breaking changes may be introduced at any point.
16 In its current state, it is possible for experienced users to build kerchunk indices of datasets,
17 which work today and will continue to work. End users of these reference sets will not be exposed
18 to changes in kerchunk's code and usually don't even need to install kerchunk.
19
20
21 Bug reports and feature requests
22 ================================
23
24 Bug reports or feature requests to the kerchunk project can be submitted by opening up an `Issue in the repository <https://github.com/fsspec/kerchunk/issues>`_.
25
26
27 Contributing code
28 ==================
29
30 This project uses git for version control and github for issue tracking. If you need instructions on how to setup git, they can be found on `GitHub <https://help.github.com/set-up-git-redirect>`_.
31
32
33 .. _contributing.forking:
34
35 Creating a Fork
36 ---------------
37
38 Once you have your git credentials setup, the next step is to create a fork of the project to work off of.
39 To fork the repo, navigate to the `kerchunk repository on github <https://github.com/fsspec/kerchunk>`_ and click the *Fork* button in the top right of the page.
40 This will create a fork of the kerchunk project in your own repository.
41
42 Next, you will want to clone this forked version of the repository onto the machine you are working on.
43 In your terminal/command prompt run:
44
45 .. code-block:: sh
46
47
48 git clone [email protected]:<yourusername>/kerchunk.git
49 cd kerchunk
50 git remote add upstream [email protected]:fsspec/kerchunk.git
51
52
53 This will create a directory from your fork of the repository on your local machine and connect it to the main repository.
54
55
56 .. _contributing.dev_env:
57
58 Creating a development environment
59 ----------------------------------
60
61 To test your code changes, you will need to build *kerchunk* from source, which
62 requires a Python environment.
63
64 .. _contributiong.dev_python:
65
66 Creating a Python Environment
67 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
68
69 To ensure that the python environment that you are using is the same one that everyone else is using,
70 it is necessary to create a virtual environment.
71 This will create an isolated development environment where you can install the kerchunk python dependencies.
72
73 - Install either `Anaconda <https://www.anaconda.com/download/>`_ or `miniconda
74 <https://conda.io/miniconda.html>`_
75 - Make sure your conda is up to date (``conda update conda``)
76 - Make sure that you have :ref:`cloned the repository <contributing.forking>`
77 - ``cd`` to the *kerchunk* source directory
78
79
80 .. tip::
81 If your conda build solving times are taking a long time, you can try `mamba <https://mamba.readthedocs.io/en/latest/installation.html#installation>`_,
82 which is a mirror of conda written in c++`.
83
84 First we'll create and activate the build environment:
85
86 .. code-block:: sh
87
88 conda env create --name kerchunk --file ci/environment-py3<*>.yml
89 conda activate kerchunk
90
91
92 Now that you have the correct dependencies installed in your environment,
93 you should be able to install your development version of kerchunk locally.
94 In the project's home directory run:
95
96 .. code-block:: sh
97
98 pip install -e .
99
100 To install with optional development dependencies run:
101
102 .. code-block:: sh
103
104 pip install -e '.[dev]'
105
106 To test that the installation was successful run:
107
108 .. code-block:: sh
109
110 $ python # start an interpreter
111 >>> import kerchunk
112 >>> kerchunk.__version__
113
114
115 To view your environments
116
117 .. code-block:: sh
118
119 conda info --envs
120
121 To return to your base environment
122
123 .. code-block:: sh
124
125 conda deactivate
126
127 See the full conda docs `here <http://conda.pydata.org/docs>`_.
128
129 Setting up pre-commit
130 ~~~~~~~~~~~~~~~~~~~~~
131
132 We use `pre-commit <https://pre-commit.com/>`_ to manage code linting and style.
133 To set up pre-commit after activating your conda environment, run:
134
135 .. code-block:: sh
136
137 pre-commit install
138
139 Now pre-commit will run whenever you create a git commit in the repository.
140 You may need to edit files that pre-commit has issues with and re-add them to the commit.
141
142 Creating a branch
143 -----------------
144
145
146 You want your ``main`` branch to reflect only production-ready code, so create a
147 feature branch before making your changes. For example
148
149 .. code-block:: sh
150
151 git branch shiny-new-feature
152 git checkout shiny-new-feature
153
154 The above can be simplified to
155
156 .. code-block:: sh
157
158 git checkout -b shiny-new-feature
159
160 This changes your working directory to the ``shiny-new-feature`` branch. Keep any
161 changes in this branch specific to one bug or feature so it is clear
162 what the branch brings to *kerchunk*. You can have many "shiny-new-features"
163 and switch in between them using the ``git checkout`` command.
164
165 To update this branch, you need to retrieve the changes from the ``main`` branch
166
167 .. code-block:: sh
168
169 git fetch upstream
170 git merge upstream/main
171
172 This will combine your commits with the latest *kerchunk* git ``main``. If this
173 leads to merge conflicts, you must resolve these before submitting your pull
174 request. If you have uncommitted changes, you will need to ``git stash`` them
175 prior to updating. This will effectively store your changes, which can be
176 reapplied after updating.
177
178 Running the test suite
179 ----------------------
180
181 *kerchunk* uses the `pytest <https://docs.pytest.org/en/latest/contents.html>`_
182 framework for testing. You can run the test suite using:
183
184 .. code-block:: sh
185
186 pytest kerchunk
187
188 Ideally any new feature added should have test coverage.
189
190
191 Contributing documentation
192 ==========================
193
194 Documentation improvements are appreciated. The documentation is contained within the ``docs`` directory of the project.
195 It is written in ``ReStructured Text (.rst)``, which is similar to markdown, but features more functionality.
196 These ReStructured text files are built into ``html`` using the python `sphinx <https://www.sphinx-doc.org/en/master/>`_ package.
197
198 You can create a virtual environment by running:
199
200 .. code-block:: sh
201
202 conda create --name kerchunk-docs python=3.8
203 conda activate kerchunk-docs
204 python -m pip install -r docs/requirements.txt
205
206 Once you make changes to the docs, you can build them with:
207
208 .. code-block:: sh
209
210 cd docs
211 make html
212
213 Contributing changes
214 ====================
215
216 Once you feel good about your changes you can see them by typing:
217
218 .. code-block:: sh
219
220 git status
221
222 If you have created a new file, it is not being tracked by git. Add it by typing:
223
224 .. code-block:: sh
225
226 git add path/to/file-to-be-added.py
227
228
229
230 Now you can commit your changes in your local repository.
231
232 .. code-block:: sh
233
234 git commit -m "<commit message>"
235
236 When you want your changes to appear publicly on your GitHub page, push your
237 commits to a branch off your fork.
238
239 .. code-block:: sh
240
241 git push origin shiny-new-feature
242
243 Here ``origin`` is the default name given to your remote repository on GitHub.
244 You can see the remote repositories.
245
246 .. code-block:: sh
247
248 git remote -v
249
250 If you navigate to your branch on GitHub, you should see a banner to submit a pull
251 request to the *kerchunk* repository.