From 74ccd665c579019a34c2ddbcc6a30bdd890d7311 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Wed, 11 Sep 2024 12:09:03 -0400 Subject: [PATCH 1/6] chore: use sliding v0.1 tag for ccbr_tools version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2f94435..73d6cbb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ classifiers = [ requires-python = ">=3.11" dependencies = [ "argparse", - "ccbr_tools@git+https://github.com/CCBR/Tools@v0.1.0", + "ccbr_tools@git+https://github.com/CCBR/Tools@v0.1", "Click >= 8.1.3", "PySimpleGui < 5", "snakemake >= 7.32, < 8", From 482635ce68d0f87f204f54a9da83ae892d16d729 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 17 Sep 2024 10:45:18 -0400 Subject: [PATCH 2/6] docs: add contrib guide --- .github/CONTRIBUTING.md | 262 ++++++++++++++++++++++++++++++++++++++++ CHANGELOG.md | 2 + docs/contributing.md | 3 + mkdocs.yml | 1 + 4 files changed, 268 insertions(+) create mode 100644 .github/CONTRIBUTING.md create mode 100644 docs/contributing.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..f6d89a0 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,262 @@ +# Contributing to RENEE + +## Proposing changes with issues + +If you want to make a change, it's a good idea to first +[open an issue](https://code-review.tidyverse.org/issues/) +and make sure someone from the team agrees that it’s needed. + +If you've decided to work on an issue, +[assign yourself to the issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/assigning-issues-and-pull-requests-to-other-github-users#assigning-an-individual-issue-or-pull-request) +so others will know you're working on it. + +## Pull request process + +We use [GitHub Flow](https://docs.github.com/en/get-started/using-github/github-flow) +as our collaboration process. +Follow the steps below for detailed instructions on contributing changes to +RENEE. + +![GitHub Flow diagram](https://raw.githubusercontent.com/CCBR/CCBR_NextflowTemplate/main/.github/img/GitHub-Flow_bg-white.png) + +### Clone the repo + +If you are a member of [CCBR](https://github.com/CCBR), +you can clone this repository to your computer or development environment. +Otherwise, you will first need to +[fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo) +the repo and clone your fork. You only need to do this step once. + +```sh +git clone https://github.com/CCBR/RENEE +``` + +> Cloning into 'RENEE'...
+> remote: Enumerating objects: 1136, done.
+> remote: Counting objects: 100% (463/463), done.
+> remote: Compressing objects: 100% (357/357), done.
+> remote: Total 1136 (delta 149), reused 332 (delta 103), pack-reused 673
+> Receiving objects: 100% (1136/1136), 11.01 MiB | 9.76 MiB/s, done.
+> Resolving deltas: 100% (530/530), done.
+ +```sh +cd RENEE +``` + +### If this is your first time cloning the repo, you may need to install dependencies + +- Install snakemake and singularity or docker if needed (biowulf already has these available as modules). + +- Install the python dependencies with pip + + ```sh + pip install . + ``` + + If you're developing on biowulf, you can use our shared conda environment which already has these dependencies installed + + ```sh + . "/data/CCBR_Pipeliner/db/PipeDB/Conda/etc/profile.d/conda.sh" + conda activate py311 + ``` + +- Install [`pre-commit`](https://pre-commit.com/#install) if you don't already + have it. Then from the repo's root directory, run + + ```sh + pre-commit install + ``` + + This will install the repo's pre-commit hooks. + You'll only need to do this step the first time you clone the repo. + +### Create a branch + +Create a Git branch for your pull request (PR). Give the branch a descriptive +name for the changes you will make, such as `iss-10` if it is for a specific +issue. + +```sh +# create a new branch and switch to it +git branch iss-10 +git switch iss-10 +``` + +> Switched to a new branch 'iss-10' + +### Make your changes + +Edit the code, write and run tests, and update the documentation as needed. + +#### test + +Changes to the **python package** code will also need unit tests to demonstrate +that the changes work as intended. +We write unit tests with pytest and store them in the `tests/` subdirectory. +Run the tests with `python -m pytest`. + +If you change the **workflow**, please run the workflow with the test profile +and make sure your new feature or bug fix works as intended. + +#### document + +If you have added a new feature or changed the API of an existing feature, +you will likely need to update the documentation in `docs/`. + +### Commit and push your changes + +If you're not sure how often you should commit or what your commits should +consist of, we recommend following the "atomic commits" principle where each +commit contains one new feature, fix, or task. +Learn more about atomic commits here: + + +First, add the files that you changed to the staging area: + +```sh +git add path/to/changed/files/ +``` + +Then make the commit. +Your commit message should follow the +[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) +specification. +Briefly, each commit should start with one of the approved types such as +`feat`, `fix`, `docs`, etc. followed by a description of the commit. +Take a look at the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/#summary) +for more detailed information about how to write commit messages. + +```sh +git commit -m 'feat: create function for awesome feature' +``` + +pre-commit will enforce that your commit message and the code changes are +styled correctly and will attempt to make corrections if needed. + +> Check for added large files..............................................Passed
+> Fix End of Files.........................................................Passed
+> Trim Trailing Whitespace.................................................Failed
+> +> - hook id: trailing-whitespace
+> - exit code: 1
+> - files were modified by this hook
>
+> Fixing path/to/changed/files/file.txt
>
+> codespell................................................................Passed
+> style-files..........................................(no files to check)Skipped
+> readme-rmd-rendered..................................(no files to check)Skipped
+> use-tidy-description.................................(no files to check)Skipped
+ +In the example above, one of the hooks modified a file in the proposed commit, +so the pre-commit check failed. You can run `git diff` to see the changes that +pre-commit made and `git status` to see which files were modified. To proceed +with the commit, re-add the modified file(s) and re-run the commit command: + +```sh +git add path/to/changed/files/file.txt +git commit -m 'feat: create function for awesome feature' +``` + +This time, all the hooks either passed or were skipped +(e.g. hooks that only run on R code will not run if no R files were +committed). +When the pre-commit check is successful, the usual commit success message +will appear after the pre-commit messages showing that the commit was created. + +> Check for added large files..............................................Passed
+> Fix End of Files.........................................................Passed
+> Trim Trailing Whitespace.................................................Passed
+> codespell................................................................Passed
+> style-files..........................................(no files to check)Skipped
+> readme-rmd-rendered..................................(no files to check)Skipped
+> use-tidy-description.................................(no files to check)Skipped
+> Conventional Commit......................................................Passed
> [iss-10 9ff256e] feat: create function for awesome feature
+> 1 file changed, 22 insertions(+), 3 deletions(-)
+ +Finally, push your changes to GitHub: + +```sh +git push +``` + +If this is the first time you are pushing this branch, you may have to +explicitly set the upstream branch: + +```sh +git push --set-upstream origin iss-10 +``` + +> Enumerating objects: 7, done.
+> Counting objects: 100% (7/7), done.
+> Delta compression using up to 10 threads
+> Compressing objects: 100% (4/4), done.
+> Writing objects: 100% (4/4), 648 bytes | 648.00 KiB/s, done.
+> Total 4 (delta 3), reused 0 (delta 0), pack-reused 0
+> remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
+> remote:
+> remote: Create a pull request for 'iss-10' on GitHub by visiting:
+> remote: https://github.com/CCBR/RENEE/pull/new/iss-10
+> remote:
+> To https://github.com/CCBR/RENEE
>
> [new branch] iss-10 -> iss-10
+> branch 'iss-10' set up to track 'origin/iss-10'.
+ +We recommend pushing your commits often so they will be backed up on GitHub. +You can view the files in your branch on GitHub at +`https://github.com/CCBR/RENEE/tree/` +(replace `` with the actual name of your branch). + +### Create the PR + +Once your branch is ready, create a PR on GitHub: + + +Select the branch you just pushed: + +![Create a new PR from your branch](https://raw.githubusercontent.com/CCBR/CCBR_NextflowTemplate/main/.github/img/new-PR.png) + +Edit the PR title and description. +The title should briefly describe the change. +Follow the comments in the template to fill out the body of the PR, and +you can delete the comments (everything between ``) as you go. +Be sure to fill out the checklist, checking off items as you complete them or +striking through any irrelevant items. +When you're ready, click 'Create pull request' to open it. + +![Open the PR after editing the title and description](https://raw.githubusercontent.com/CCBR/CCBR_NextflowTemplate/main/.github/img/create-PR.png) + +Optionally, you can mark the PR as a draft if you're not yet ready for it to +be reviewed, then change it later when you're ready. + +### Wait for a maintainer to review your PR + +We will do our best to follow the tidyverse code review principles: +. +The reviewer may suggest that you make changes before accepting your PR in +order to improve the code quality or style. +If that's the case, continue to make changes in your branch and push them to +GitHub, and they will appear in the PR. + +Once the PR is approved, the maintainer will merge it and the issue(s) the PR +links will close automatically. +Congratulations and thank you for your contribution! + +### After your PR has been merged + +After your PR has been merged, update your local clone of the repo by +switching to the main branch and pulling the latest changes: + +```sh +git checkout main +git pull +``` + +It's a good idea to run `git pull` before creating a new branch so it will +start from the most recent commits in main. + +## Helpful links for more information + +- [GitHub Flow](https://docs.github.com/en/get-started/using-github/github-flow) +- [semantic versioning guidelines](https://semver.org/) +- [changelog guidelines](https://keepachangelog.com/en/1.1.0/) +- [tidyverse code review principles](https://code-review.tidyverse.org) +- [reproducible examples](https://www.tidyverse.org/help/#reprex) +- [nf-core extensions for VS Code](https://marketplace.visualstudio.com/items?itemName=nf-core.nf-core-extensionpack) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67133be..f51a04b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## RENEE development version +- minor documentation improvements + ## RENEE 2.6.0 ### New features diff --git a/docs/contributing.md b/docs/contributing.md new file mode 100644 index 0000000..773a7e5 --- /dev/null +++ b/docs/contributing.md @@ -0,0 +1,3 @@ +--8<-- ".github/CONTRIBUTING.md" + + diff --git a/mkdocs.yml b/mkdocs.yml index 28236d7..19c1ee0 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -109,4 +109,5 @@ nav: - FAQ: - General Questions: general-questions.md - Troubleshooting: troubleshooting.md + - How to contribute: contributing.md - License: license.md From 16b3c50f74983d2bcce1e80e573eb7b74b87ebe9 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 17 Sep 2024 10:55:31 -0400 Subject: [PATCH 3/6] fix: add debug command to print the base dir --- src/renee/__main__.py | 13 ++++++++++++- src/renee/util.py | 7 +++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/renee/__main__.py b/src/renee/__main__.py index e770b1f..95f625a 100755 --- a/src/renee/__main__.py +++ b/src/renee/__main__.py @@ -546,7 +546,6 @@ def parsed_arguments(name, description): parser.add_argument( "--version", action="version", version="renee {}".format(__version__) ) - # Create sub-command parser subparsers = parser.add_subparsers(help="List of available sub-commands") @@ -1462,8 +1461,15 @@ def parsed_arguments(name, description): # Add custom help message subparser_cache.add_argument("-h", "--help", action="help", help=argparse.SUPPRESS) + subparser_debug = subparsers.add_parser( + "debug", + help="Debug the RENEE pipeline base directory.", + usage=argparse.SUPPRESS, + ) + # Define handlers for each sub-parser subparser_run.set_defaults(func=run) + subparser_debug.set_defaults(func=debug) subparser_unlock.set_defaults(func=unlock) subparser_build.set_defaults(func=build) subparser_cache.set_defaults(func=cache) @@ -1474,6 +1480,11 @@ def parsed_arguments(name, description): return args +def debug(args): + print("RENEE BASE:", renee_base()) + print(get_version(debug=True)) + + def main(): # Sanity check for usage if len(sys.argv) == 1: diff --git a/src/renee/util.py b/src/renee/util.py index 4a6e273..dcdd022 100644 --- a/src/renee/util.py +++ b/src/renee/util.py @@ -10,11 +10,14 @@ def renee_base(*paths): return str(basedir.joinpath(*paths)) -def get_version(): +def get_version(debug=False): """Get the current RENEE version @return version """ - with open(renee_base("VERSION"), "r") as vfile: + version_file = renee_base("VERSION") + if debug: + print("VERSION FILE:", version_file) + with open(version_file, "r") as vfile: version = f"v{vfile.read().strip()}" return version From cfd9d4debd34ab8b69acfeaee79eb1fa07337ed7 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 17 Sep 2024 15:19:24 -0400 Subject: [PATCH 4/6] refactor: attempt to diagnose path problem --- VERSION | 2 +- src/renee/__main__.py | 2 +- src/renee/util.py | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 8f87ff7..221ee21 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6.0-dev +2.6.0-print-base diff --git a/src/renee/__main__.py b/src/renee/__main__.py index 95f625a..285951b 100755 --- a/src/renee/__main__.py +++ b/src/renee/__main__.py @@ -1481,7 +1481,7 @@ def parsed_arguments(name, description): def debug(args): - print("RENEE BASE:", renee_base()) + print("RENEE BASE:", renee_base(debug=True)) print(get_version(debug=True)) diff --git a/src/renee/util.py b/src/renee/util.py index dcdd022..0b2385a 100644 --- a/src/renee/util.py +++ b/src/renee/util.py @@ -2,11 +2,14 @@ from ccbr_tools.pipeline.util import get_hpcname -def renee_base(*paths): +def renee_base(*paths, debug=False): """Get the absolute path to a file in the repository @return abs_path """ - basedir = pathlib.Path(__file__).absolute().parent.parent.parent + src_file = pathlib.Path(__file__).absolute() + if debug: + print("SRC FILE:", src_file) + basedir = src_file.parent.parent.parent return str(basedir.joinpath(*paths)) From 69a9c8af8859fd191130f63eee25f1596b5134c8 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 17 Sep 2024 15:32:10 -0400 Subject: [PATCH 5/6] chore: remove unneeded snaketools pkg --- VERSION | 2 +- pyproject.toml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 221ee21..8f87ff7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6.0-print-base +2.6.0-dev diff --git a/pyproject.toml b/pyproject.toml index 73d6cbb..ba84f40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,8 +39,7 @@ dependencies = [ "ccbr_tools@git+https://github.com/CCBR/Tools@v0.1", "Click >= 8.1.3", "PySimpleGui < 5", - "snakemake >= 7.32, < 8", - "snaketool-utils >= 0.0.5", + "snakemake >= 7.32, < 8" ] [project.optional-dependencies] From dd14d13c0a73bdbefc5b9e4a9527a916e3e6de92 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Thu, 19 Sep 2024 13:48:29 -0400 Subject: [PATCH 6/6] chore: update CHANGELOG.md --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f51a04b..d2c024d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## RENEE development version -- minor documentation improvements +- New contributing guide available on GitHub and the documentation website. (#159, @kelly-sovacool) +- New `renee debug` subcommand to determine the base directory for debugging purposes. (#159, @kelly-sovacool) ## RENEE 2.6.0