-
Notifications
You must be signed in to change notification settings - Fork 229
Add instructions for wrapping new module #1687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
maxrjones
wants to merge
12
commits into
main
Choose a base branch
from
wrap-module-instructions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2aee14d
Update pull request template
2ace7e9
Start on the instructions for adding new module
031460a
Merge branch 'main' into wrap-module-instructions
293035a
Expand guide for wrapping modules
ae143d0
Add section for adding aliases
a05a8a7
Consolidate list
49538ef
Fix grammar
aea5d95
Merge branch 'main' into wrap-module-instructions
62b8cae
Apply suggestions from code review
0c170b3
Update doc/contributing.md
7d26742
Apply suggestions from code review
seisman 2edf308
Merge branch 'main' into wrap-module-instructions
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,6 +166,8 @@ To increase the chances of getting your pull request accepted quickly, try to: | |
- Include an example of new features in the gallery or tutorials. | ||
Please refer to [Gallery plots](contributing.md#contributing-gallery-plots) | ||
or [Tutorials](contributing.md#contributing-tutorials). | ||
If adding a new method/function/class, the gallery example or tutorial should | ||
be submitted in a separate pull request. | ||
* Have a good coding style | ||
- Use readable code, as it is better than clever code (even with comments). | ||
- Follow the [PEP8](https://pep8.org) style guide for code and the | ||
|
@@ -467,8 +469,9 @@ function/class/module/method. | |
### PyGMT Code Overview | ||
|
||
The source code for PyGMT is located in the `pygmt/` directory. When contributing | ||
code, be sure to follow the general guidelines in the | ||
[pull request workflow](contributing.md#pull-request-workflow) section. | ||
code, please open an issue first to discuss the feature and its implementation | ||
and be sure to follow the general guidelines in the | ||
[pull request workflow](#pull-request-workflow) section. | ||
|
||
### Code Style | ||
|
||
|
@@ -511,6 +514,74 @@ contains rules for running the linter checks: | |
make check # Runs ruff in check mode | ||
``` | ||
|
||
### Wrapping a new GMT module | ||
|
||
Wrapping a new GMT module in PyGMT is usually a big task, which will progress | ||
quicker and smoother if done in **small, manageable chunks**. This section | ||
gives an overview of the specific tasks involved in wrapping a new module. | ||
|
||
1. Create a ['Wrapper for `<module-name>`' feature request issue](#request-wrapper-for-gmt-module). | ||
2. Open a ['Wrap `<module-name>`' initial feature implementation PR](#initial-feature-implementation). | ||
3. Open an ['Add missing aliases to `<module-name>`' documentation PR](#add-missing-aliases). | ||
4. Open a 'support additional functionality in module' PR (optional). | ||
5. Add ['Gallery example for module' documentation PR](#contributing-gallery-plots). | ||
6. Add ['Tutorial for module' documentation PR](#contributing-tutorials) (optional). | ||
|
||
These steps will be tracked in the 'Wrapper for `<module-name>`' issue and the | ||
['wrapping GMT modules'](https://github.com/GenericMappingTools/pygmt/projects/9) | ||
project board. The pull requests can be split between multiple contributors and | ||
there is no obligation for a single contributor to complete all steps. Please | ||
comment on the initial 'Wrapper for `<module-name>`' if you would like to open | ||
a pull request for any of these tasks to avoid redundant efforts. | ||
|
||
#### Request wrapper for GMT module | ||
|
||
* Find the [*Issues*](https://github.com/GenericMappingTools/pygmt/issues) tab on the | ||
top of the GitHub repository and click *New Issue*. | ||
* Click on *Get started* next to *Feature request - Wrap new GMT module*. | ||
* Follow the prompts for filling out the issue template. | ||
|
||
#### Initial feature implementation | ||
|
||
First, comment on the 'Wrapper for `<module-name>`' issue that you will be | ||
working on the initial feature implementation. This first pull request should | ||
be as minimal as possible - only adding the required functionality (i.e., | ||
wrapping the required GMT arguments and supporting the primary input/output | ||
types). | ||
|
||
The following steps are common to all initial implementation pull requests that | ||
wrap a new GMT module (e.g., [initial grdfill implementation](https://github.com/GenericMappingTools/pygmt/pull/1276/files)): | ||
|
||
* Create a new module `<module-name>.py` in `pygmt/src`. The module docstring | ||
should include the module name and a short description of the functionality | ||
(e.g., `grdfill - Fill blank areas from a grid.`). | ||
* Add a function `<module-name>` to the module. When writing the new function, | ||
it is generally easiest to reference the source code for other functions that | ||
input/output similar object types. | ||
* Add a detailed docstring following the [numpy style guide](https://numpydoc.readthedocs.io/en/latest/format.html). | ||
* Add the function to the import statements in `pygmt/src/__init__.py`. | ||
* Add the function to the import statements in `pygmt/__init__.py`. | ||
* Add the function to appropriate section of the API documentation in `doc/api/index.rst`. | ||
* Add a testing module `test_<module-name>.py` in `pygmt/tests`, following | ||
the guidelines in the [testing your code](#testing-your-code) section. | ||
|
||
#### Add missing aliases | ||
|
||
After the initial implementation, the missing aliases can be added in a | ||
separate PR (e.g., [add missing aliases to grd2xyz](https://github.com/GenericMappingTools/pygmt/pull/1537/files)). | ||
Comment on lines
+568
to
+571
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might need to get a newer example once we go with the long option standard in #1932. |
||
|
||
* Select a suitable alias for each GMT option, following the guidelines in the | ||
[code style](#code-style) section. Before creating a new alias, check if the | ||
parameter is listed in the `COMMON_DOCSTRINGS` dictionary in | ||
`pygmt/helpers/decorators.py`, if other wrapped GMT modules have a similar | ||
parameter, and if [GMT.jl](https://www.generic-mapping-tools.org/GMT.jl/dev/) | ||
has defined an alias. | ||
* Update the `use_alias` decorator for the `<module-name>` function using the | ||
GMT option as the parameter and the alias as the argument. | ||
* Add the alias and description to the parameters section of the docstring, | ||
using the `fmt_docstring` decorator to add descriptions for parameters | ||
included in the `COMMON_DOCSTRINGS` dictionary. | ||
|
||
### Testing your Code | ||
|
||
Automated testing helps ensure that our code is as free of bugs as it can be. | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should either track the module updates in a project board (my preference) or an issue, but not both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think we should abandon the 'Wrapper for
<module-name>
' issues entirely or keep the issues/issue-template and just move the checklist to the project board? I think the main benefit of the issues is that from my understanding any GitHub user can open/comment on an issue whereas writing on the project board requires special permissions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the project board works better for tracking the progress of wrapping a module, and that having a separate issue for wrapping the function is a bit redundant. I see what you mean about the benefits of issues being open to everyone, but my thought is that wrapping modules is a pretty routine process and doesn't need to first be raised as an issue (unlike a bug or a feature request). We can add some/all of the GMT modules to the project board to track their process. Users who don't have write permission are still free to open up an issue requesting a module/feature (or a pull request! 🤞) as a way to let us know that a certain feature would be useful to them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, issues are also more visible than project boards, so that we may have more potential contributors helping wrap new modules and add more aliases.