Skip to content

Commit 6ecbf14

Browse files
author
Remi Kazeroni
committed
cleanup section 4
1 parent 826bd20 commit 6ecbf14

File tree

1 file changed

+40
-21
lines changed

1 file changed

+40
-21
lines changed

_episodes/07-development-setup.md

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ If the installation is successful, ESMValTool prints a help message to the conso
186186
>> esmvaltool 2.10.0.dev3+g2dbc2cfcc pypi_0 pypi
187187
>>~~~
188188
>>
189-
>> As can be seen, it is mentioned ``pypi`` under the ``Channel`` for ``develop`` mode.
190189
> {: .solution}
191190
{: .challenge}
192191
@@ -201,10 +200,8 @@ with changes from the ``main`` branch.
201200
## Contribution
202201
203202
We have seen how to install ESMValTool in a ``develop`` mode.
204-
Now, we try to contribute to its development. Let's see how we can achieve this.
205-
206-
### Review process
207-
203+
Now, we try to contribute to its development.
204+
Let's see how we this can be achieved.
208205
We first discuss our ideas in an
209206
**[issue](https://github.com/ESMValGroup/ESMValTool/issues)** in ESMValTool repository.
210207
This can avoid disappointment at a later stage, for example,
@@ -213,21 +210,32 @@ It also gives other people an early opportunity to provide input and suggestions
213210
which results in more valuable contributions.
214211
215212
Then, we create a new ``branch`` locally and start developing new codes.
213+
To create a new branch:
214+
~~~bash
215+
git checkout -b your_branch_name
216+
~~~
217+
216218
Once our development is finished, we can initiate a ``pull request``.
217-
For a full description of the GitHub workflow, please see ESMValTool documentation on
218-
[GitHub Workflow](https://docs.esmvaltool.org/en/latest/community/repository.html#github-workflow).
219+
To this end, we encourage you to join the ESMValTool development team.
219220
220-
The pull request will be tested, discussed and merged. This is called "**review process**".
221+
For more extensive documentation on contributing code,
222+
including a section on the
223+
[GitHubWorkflow](https://docs.esmvaltool.org/en/latest/community/repository.html#github-workflow),
224+
please see the [Contributing code and documentation](https://docs.esmvaltool.org/en/latest/community/code_documentation.html) section in the ESMValtool documentation.
225+
226+
### Review process
227+
228+
The pull request will be tested, discussed and merged as part of the "**review process**".
221229
The process will take some effort and time to learn.
222230
However, a few (command line) tools can get you a long way,
223231
and we’ll cover those essentials in the next sections.
224232
225233
**Tip**: we encourage you to keep the pull requests small.
226234
Reviewing small incremental changes are more efficient.
227235
228-
### Background
236+
### Working example
229237
230-
We saw 'warming stripes' in lesson
238+
We saw the 'warming stripes' diagnostic in lesson
231239
[Writing your own recipe]({{ page.root }}{% link _episodes/06-preprocessor.md %}).
232240
Imagine the following task: you want to contribute warming stripes recipe and diagnostics
233241
to ESMValTool. You have to add the diagnostics
@@ -237,7 +245,9 @@ to their locations in ESMValTool directory.
237245
After these changes, you should also check if everthing works fine.
238246
This is where we take advantage of the tools that are introduced later.
239247
240-
Let’s get started.
248+
Let’s get started. Note that since this is an exercise to get familiar with the
249+
development and contribution process, we will not create a GitHub issue at this time
250+
but proceed as though it has been done.
241251
242252
### Check code quality
243253
@@ -266,7 +276,7 @@ To explore other tools, have a look at ESMValTool documentation on
266276
>
267277
> ~~~bash
268278
> cd ESMValTool
269-
> git checkout your_branch_name
279+
> git checkout -b your_branch_name
270280
> cp path_of_warming_stripes.py esmvaltool/diag_scripts/
271281
> ~~~
272282
>
@@ -282,7 +292,7 @@ To explore other tools, have a look at ESMValTool documentation on
282292
>
283293
>> ## Solution
284294
>>
285-
>> The output of ``pre-commit``:
295+
>> The tail of the output of ``pre-commit``:
286296
>>
287297
>> ~~~ bash
288298
>> Check for added large files..............................................Passed
@@ -314,17 +324,25 @@ To explore other tools, have a look at ESMValTool documentation on
314324
>>
315325
>> 1. ``docformatter``: it is mentioned that "files were modified by this hook".
316326
>> We run ``git diff`` to see the modifications.
317-
>> The syntax ``"""`` at the end of docstring is moved by one line.
327+
>> The output includes the following:
328+
>> ~~~bash
329+
>> +in the form of the popular warming stripes figure by Ed Hawkins."""
330+
>> ~~~
331+
>>
332+
>> The syntax ``"""`` at the end of docstring is moved by one line.
333+
Shifting it to the next line should fix this error.
318334
>> 2. ``flake8``: the error message is about an unused local variable ``nx``.
319335
>> We should check our codes regarding the usage of ``nx``.
320336
>> For now, let's assume that it is added by mistake and remove it.
337+
>> Note that you have to run `git add` again to re-stage the file.
338+
>> Then rerun pre-commit and check that it passes.
321339
> {: .solution}
322340
{: .challenge}
323341
324342
### Run unit tests
325343
326344
Previous section introduced some tools to check code style and quality.
327-
What it hasn’t done is show us how to tell whether our code is getting the right answer.
345+
What it has not done is show us how to tell whether our code is getting the right answer.
328346
To achieve that, we need to write and run tests for widely-used functions.
329347
ESMValTool comes with a lot of tests that are in the folder ``tests``.
330348
@@ -340,15 +358,16 @@ when you submit a pull request.
340358
341359
> ## Running tests
342360
>
343-
> Let's checkout our local branch and add the recipe
361+
> Make sure our local branch is checked out and add the recipe
344362
> [recipe_warming_stripes.yml](../files/recipe_warming_stripes.yml)
345363
> to the the ``esmvaltool/recipes`` directory:
346364
>
347365
> ~~~bash
348366
> cp path_of_recipe_warming_stripes.yml esmvaltool/recipes/
349367
> ~~~
350368
>
351-
> Run ``pytest`` and inspect the results. If a test is failed, try to fix it.
369+
> Run ``pytest`` and inspect the results, this might take a few minutes.
370+
> If a test is failed, try to fix it.
352371
>
353372
>> ## Solution
354373
>>
@@ -403,7 +422,7 @@ To build documentation locally, first we make sure that the working directory is
403422
and our local branch is checked out. Then, we run:
404423
405424
~~~bash
406-
python setup.py build_sphinx -Ea
425+
sphinx-build -Ea doc/sphinx/source/ doc/sphinx/build/
407426
~~~
408427
409428
Similar to code, documentation should be well written and adhere to standards.
@@ -412,12 +431,12 @@ If the documentation is built properly, the previous command prints a message to
412431
~~~
413432
build succeeded.
414433
415-
The HTML pages are in doc/sphinx/build/html.
434+
The HTML pages are in doc/sphinx/build.
416435
~~~
417436
{: .output}
418437
419438
The main page of the documentation has been built into ``index.html``
420-
in ``doc/sphinx/build/html`` directory.
439+
in ``doc/sphinx/build/`` directory.
421440
To preview this page locally, we open the file in a web browser:
422441
423442
~~~bash
@@ -474,7 +493,7 @@ xdg-open doc/sphinx/build/html/index.html
474493
>> Then, we build and preview the documentation page:
475494
>>
476495
>> ~~~bash
477-
>> python setup.py build_sphinx -Ea
496+
>> sphinx-build -Ea doc/sphinx/source/ doc/sphinx/build/
478497
>> xdg-open doc/sphinx/build/html/recipes/recipe_warming_stripes.html
479498
>> ~~~
480499
>>

0 commit comments

Comments
 (0)