-
Notifications
You must be signed in to change notification settings - Fork 40
Tips for Developers (1)
If you are interested in contributing to the the development of the PMP please contact the core team ([email protected]) so that you can be registered as a contributor. Since this package has many users, it is critical that the master code repository remains as clean as possible. For this reason, a few rules are being adhered to:
- "master" contains the latest end-user-ready code version
- Official releases will be tagged
- A "devel" branch is also associated with this repo. This branch contains fixes and improvements that any developer sees "fit-for-master" but has not been extensively tested by others. This can be considered a "pre-release" branch.
In order to ensure that "master" stays clean, only a few "advanced" developers have repo write access. The procedure to fix/enhance the code is as follows:
- Fork "master" to your favorite git server (we recommend github)
- Clone your forked repo to your local machine
- Create a new branch from the cloned master (Branch names should be descriptive, we recommend the following format: issueNumber_author_shortDescription)
- Edit/fix/enhance at will
- Send a pull request (PR) to the PCMDI metrics repo administrator so changes are pulled back into the PCMDI metrics repo as a separate branch (issueNumber_author_shortDescription) and your code can be tested by others
- Once your changes have been tested and confirmed to work, the PR/branch is approved and your changes are merged back into master
-
Go to github.com/PCMDI/pcmdi_metrics and "fork" the repo to your github account
-
Clone your forked repo to your local machine (do this once only)
$ git clone [email protected]:durack1/pcmdi_metrics.git $ git remote add PCMDI git://github.com/PCMDI/pcmdi_metrics.git $ git fetch --all $ git checkout -b pcmdi_master PCMDI/master ; # create local branch name (pcmdi_master) following source branch
-
Bring PCMDI changes back to your repo - make sure you have the most up-to-date copy of the remote repo
$ git checkout pcmdi_master ; # Pull changes for master repo $ git pull $ git checkout master $ git merge pcmdi_master
-
Create a new branch (using issueNumber_author_shortDescription format)
$ git checkout master $ git checkout -b issueNumber_author_shortDescription ; # Create a new branch based on master
-
Make the metrics package cooler - edit away..
-
Commit your changes to your local repo, with an appropriate comment describing your changes
$ git commit -am 'A much cooler metrics package'
-
Push your local changes back to your remote branch (which you named following issueNumber_author_shortDescription format in step 3 above) first time:
$ git push -u origin HEAD:issueNumber_author_shortDescription
Subsequent pushes:
$ git push
-
From github (user account webpage) request changes to be pulled back into PCMDI/pcmdi_metrics or if you're not using github send the PCMDI repo administrator the fork and branch information you would like to merge.
IF THERE ARE ANY CONFLICTS DURING THE MERGE, YOUR PULL REQUEST WILL BE REJECTED - IT IS YOUR RESPONSIBILITY TO MERGE CONFLICTS PRIOR TO ISSUING A PULL REQUEST - see step 7 above
-
Branch names should be descriptive; we recommend the following format: issueNumber_author_shortDescription
-
Multiple bug fixes/enhancements should be split into multiple branches
-
Once your merge back into the master repo is complete, we suggest purging your local branch
$ git branch -D issueNumber_author_shortDescription [deletes local branch] $ git push origin :issueNumber_author_shortDescription [deletes remote branch]
-
And then synchronize your repos with the remotes
$ git remote show [show remotes] $ git remote show PCMDI [show specific remote detail] $ git checkout pcmdi_master $ git pull $ git checkout master $ git pull $ git merge --no-ff pcmdi_master [merge pcmdi_master into master branch] $ git checkout -b issueNumber_author_shortDescription [create new branch] < Make edits > $ git commit -am 'issueNumber_author_shortDescription' < test code for bugs and fix > $ git push -u origin HEAD:issueNumber_author_shortDescription [-u ensures changes are tracked across repos] < further testing before merging into pcmdi_master > < EXTRAS > $ git push remote -u HEAD:issueNumber_author_shortDescription [push changes to remote branch and track [-u]]
-
If you haven't been at it for a while, here's how you blast your repo and update it to ensure that you're working with the latest source
$ git clone https://github.com/PCMDI/pcmdi_metrics.git [creates a pcmdi_metrics directory in CWD] $ cd pcmdi_metrics $ git remote add durack1 https://github.com/durack1/pcmdi_metrics $ git fetch --all -p [--all is equivalent to --force and -p purges/deletes branches that no longer exist remotely] $ git checkout master [switch to master branch - there is only one the UV-CDAT master] $ git branch -vv [validate that there is only one master branch] $ git status [check to see if everything is up to date] $ git checkout -b issue601_durack1_python278 [create new branch before making changes - update to python 2.7.8] # Do some other stuff, download new *.tgz and get an md5 checksum $ git diff [check to see that only what you wanted to change has changed] $ git status [confirm which branch you're on before committing] $ git commit -am 'fix #601 - update python to latest 2p7p8' [commit changes to new branch issue601_durack1_python278 as created above] $ git push -u durack1 HEAD:issue601_durack1_python278 [push changes into remote branch] $ git push -u origin HEAD:issue601_durack1_python278 [push changes into local branch]
-
Create a conda development env for use in local development:
conda env create -f conda-env/dev.yml
orconda env create -f conda-env/dev.yml -n my_pmp_conda_env
-
Clone the repo to the local
-
Switch to the working branch
-
Activate the local development conda env and install from the source code:
conda activate pcmdi_metrics_dev
(if env name was not given above) orconda activate my_pmp_conda_env
python setup.py install
(atpcmdi_metrics
directory)
Adds the conda development env for use in local development and in the GH Actions CI/CD workflow(s).
-
conda env create -f conda-env/dev.yml
orconda env create -f conda-env/dev.yml -n my_pmp_conda_env
- PMP uses Github Action for its CI process.
-
pre-commit
checks were included for the CI process - To run
pre-commit
in your local branch:pre-commit run --all-files
Basic instructions are provided here for maintaining the conda-forge feedstock. For more help, please consult the official documentation.
- Fork the pcmdi_metrics feedstock at https://github.com/conda-forge/pcmdi_metrics-feedstock.
- Clone your fork locally to work (optional. You can also use the Github UI).
When a new, tagged version of the PMP has been released, follow these steps. Note that it is important to work in a fork and not in the pcmdi_metrics-feedstock directly. It is also important to work in a new branch, and not in the "master" branch.
-
Generate sha256 hash for the new version
a. Download the tar file.
b. Open a terminal and runopenssl sha256 tar_file_name
. -
In your fork of the pcmdi_metrics-feedstock, check out a new branch. Use a descriptive name, for example "v2.2.1".
-
Open the file recipe/meta.yaml in your preferred text editor.
-
In recipe/meta.yaml, update two lines:
L2: update the version number in quotes (e.g. {% set version = "2.2.1" %}, but with your version in place of 2.2.1)
L10: Update the sha256 field with the hash generated in step 1.
Save these changes. -
Add and commit recipe/meta.yaml in your new branch
-
Push the new branch to "origin" if working locally.
-
Go to your pcmdi_metrics-feedstock fork on Github.com. Create a PR to the PMP feedstock from your new branch. You can use the default PR template. Once it is created, follow the check boxes in the comment.
-
Wait for the feedstock tests to finish. Once you are satisfied with the PR, it can be merged.
-
After a couple of hours, the new version should be available on conda-forge at https://anaconda.org/conda-forge/pcmdi_metrics.
The release process for a dev version is the same as the "Release" process outlined above, with two additional steps. We want to use a different label for the dev version so that users who want the latest stable release from the pcmdi_metrics channel do not download this version by default.
This example uses the label name 'pcmdi_metrics_dev'. Consult PCMDI metrics anaconda page to see what labels are in use.
These are the additional steps (following steps 4 and 5 in the "Release" process):
4a. Create recipe/conda_build_config.yaml. This file will contain two lines of text:
channel_targets:
- conda-forge pcmdi_metrics_dev
5a. Add and commit recipe/conda_build_config.yaml.
The file "recipe/conda_build_config.yaml" should be deleted the next time a non-dev release is done.
To create an environment with the dev version (use your label if different from pcmdi_metrics_dev):
conda create -y -n pcmdi_metrics_test -c conda-forge/label/pcmdi_metrics_dev python=3.9 pcmdi_metrics