-
Couldn't load subscription status.
- Fork 179
Workflow
- All changes to the repository are made in branches on the developer's fork of this repository and submitted via a pull request (PR).
- Each PR should be labeled with a step label (e.g. a PR to refpix should have a label
refpix) and any other relevant labels. These are auto-assigned, but make sure they look correct! - Each PR should be assigned a milestone (a build number or a future release version number).
- Each PR should have a changelog entry (or the
no-changelog-entry-neededlabel as appropriate). - A PR is merged after someone other than the submitter has reviewed and approved it. Usually this is one of the maintainers familiar with a particular step or pipeline. Trivial changes can be merged by the submitter of the PR (use your best judgement). If the changes may affect another step, consider asking that step maintainer to review them.
- A CI workflow will run on the PR branch, which attempts to make a clean install of the repository, run all the unit tests in several architectures and Python versions, and check for compliance to our code style rules.
- There are additional details on the CONTRIBUTING.md page; please read that too!
-
(optional) Create a clean Conda environment (or similar, if you use a different environment manager).
-
Fork the main jwst repository.
-
Create a local copy ("clone") of the repository you just forked and let it know where the main repository is.
git clone https://github.com/<your-git-user-name>/jwst.git cd jwst git remote add upstream https://github.com/spacetelescope/jwst.gitNOTE: If you're cloning GitHub repositories using HTTPS, you can use a credential helper to tell Git to remember your GitHub username and password every time it talks to GitHub:
https://help.github.com/articles/caching-your-github-password-in-git/
If you clone GitHub repositories using SSH, then you authenticate using SSH keys instead of a username and password:
You should now be able to look at all remotes now and see something like
% git remote -v upstream https://github.com/spacetelescope/jwst.git (fetch) upstream https://github.com/spacetelescope/jwst.git (push) origin https://github.com/<your-git-user-name>/jwst.git (fetch) origin https://github.com/<your-git-user-name>/jwst.git (push)The above operations to fork and clone the repo are normally performed once (not necessary every time you want to create a new PR branch).
-
Before making changes, it's useful to install the jwst package in "editable" mode with the contributor (test, documentation, and code style) dependencies:
pip install -e .[contrib]This configuration allows calls to the pipeline to pick up any changes you've made to the pipeline without having to re-install jwst every time you make a change.
-
It's strongly recommended to add our pre-commit hook into the repository.
pre-commitshould have been installed as part of the[contrib]dependencies, so just runpre-commit installfrom the top level of the
jwstrepository. This step ensures that all of our code style checks will run every time you make a commit.
It's finally time to start work on a new feature/change by making a separate branch that tracks upstream/main.
-
First, always fetch the
upstreambranch to get the latest changes into your clone.git fetch upstream -
Make a new branch called
feature1off ofupstream/main.git checkout -b feature1 upstream/mainYou will see a message like the following:
Branch feature1 set to track upstream/main -
Work on this branch until the new feature is ready. Then commit the changes:
git add <file_names_to_commmit> git commit -m "JP-nnnn: Adding feature 1" file_names_to_commitNote that it's common (and encouraged) practice to include the Jira ticket number as a prefix in your commit message. This sets up an automatic link between the Jira ticket and the PR.
Sometimes development of a new feature takes a while, and perhaps
upstream/mainhas passed you by, or you need a bug fix in your feature branch that someone else committed toupstream/main. So to update your branch with the latest fromupstream:git fetch upstream git rebase upstream/mainIt is better to use
rebasethanmerge, because the commit log ofupstream/mainremains cleaner once your branch is merged back in. -
Run any relevant unit tests and regression tests to ensure the changes actually work. If there are no tests that cover the changes, write one!
-
When all changes are made, push to your forked repository (note: you are pushing the new branch to your own forked copy of the main repository):
git push origin feature1 -
Now go to your forked copy (
http://github.com/<your_github_username>/jwst.git) to find the branch you just pushed. (There's a link to your github account in the upper right corner of any github page. Clicking on it will take you to your github profile and you can find the repository under the tabrepositories.)If it's a new branch you will see
Compare and pulltab next to the branch name.You can look at the changes online. If everything looks good, create a PR against
upstream/mainby clicking on theCreate pull requestbutton. This will take you to the main JWST repository on github.- Add relevant descriptions, labels, milestones, and ask for a review.
- After the review and when CI and regression tests pass, merge using the web interface.
We use several tools to help us maintain PEP8-compliant code style and Numpy-style docstrings. These tools are all run as part of our pre-commit hook and as part of the CI workflow that runs on every pull request. There is additional information about these tools on our CONTRIBUTING.md page.
If you've set up pre-commit as described above, these should all be running automatically every time you make a commit,
and they should be picking up our repository's custom configurations from the pre-commit-config.yaml, pyproject.toml,
and .ruff.toml files.
At time of writing (January 2025), new code style rules and checks have been added, but not all of the submodules in the repository have been updated with the requisite changes. Updating a module to align with the style rules requires a slightly more involved workflow, as follows.
-
Hopefully you're already set up as described above. If you're not using
pre-commityet, this might be a good time to start. -
Check out a new branch off of main.
-
Remove the module you want to fix from the per-module ignore lists in three places:
- Inside the file
.pre-commit-config.yamlunder thenumpydoc-validationsection. - Inside the file
.ruff.tomlunder the header[format]. - Inside the file
.ruff.tomlunder the header[lint.per-file-ignores].
- Inside the file
-
From the top level of the JWST repository, run the command
pre-commit run --all-filesThis should show all the failing checks for the module you just removed from the ignore lists, and will fix some of them.
-
Fix the problems using a normal git workflow (make changes,
git add,git commit. Note that the pre-commit hook that runs every time yougit commitchecks ONLY any files that were modified, so it may not pick up every failing style check in the module the waypre-commit run --all-fileswill. Note also that if there were any failures, even if they were auto-fixed, the commit will fail and you'll need to stage and commit the changes again. -
Submit the PR! The
no-changelog-entry-neededtag can be applied, unless you found and fixed a bug while reviewing the code or something like that.
Use JP-4099 for reference and obtain the clang-format file, a configuration file, attached to this ticket and save it to a convenient location on your computer; typically it is saved as a . file in the home directory. A complete list of the configuration options for the configuration file is here.
Once you have saved the configuration file, format C code according to clang-format do the following:
- Create a conda environment.
- Activate the conda environment, then run
pip install clang-format.- To format a C file, run
clang-format --style='file:<configuration file>' -i <C file>
Sometimes the style checkers find issues that we would like to ignore for some reason. All of the checkers support ignoring specific lines using in-line comments, but these comments have different syntax for the different checkers. Here is a list for convenience:
-
Ruff Linter: Use
# noqa: RULEIDon the same line as the offending text, e.g.wcsinfo = datamodel.meta.wcsinfo._instance # noqa: SLF001 -
Ruff Formatter: For a single-line skip, use
#fmt: skipon the same line as the offending text. For a multi-line skip, surround a block of text with# fmt: offandfmt: on, each on their own lines. -
Numpydoc: Use
# numpydoc ignore=RULEIDon the same line as the offending text, e.g.def tikho_mat(self): # numpydoc ignore=RT01 -
Codespell: Use
# codespell:ignore varnameon the same line as the varname it complained about, e.g.(!(err = ensure_array(erro, &free_err))) || // codespell:ignore erro(note this example is C code). You can also consider whether the word should be added to the "skip" list under[tool.codespell]inpyproject.toml. -
Mypy: Use
type: ignore[rule-name]``on the same line as the offending text, e.g. ``from jwst.datamodels import ImageModel # type: ignore[attr-defined]
Notes on how to configure Emacs and Vim to conform to PEP8.
Notes on VSCode extensions for linting and formatting.