Skip to content

Commit

Permalink
convert to cookiecutter template
Browse files Browse the repository at this point in the history
  • Loading branch information
glass-ships committed Jun 20, 2024
1 parent 5342183 commit 3160c3a
Show file tree
Hide file tree
Showing 31 changed files with 5,095 additions and 93 deletions.
25 changes: 25 additions & 0 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"template": "https://github.com/monarch-initiative/cookiecutter-monarch-ingest.git",
"commit": "bd969c818d9380b12a43d0cc4a20765ea6aa12c8",
"checkout": null,
"context": {
"cookiecutter": {
"github_org_name": "monarch-initiative",
"project_name": "NCBI Gene",
"project_description": "Ingest of genes from NCBI",
"__repo_name": "NCBI-Gene",
"__project_slug": "ncbi_gene",
"__project_url": "https://github.com/monarch-initiative/NCBI-Gene",
"ingest_source": "ncbi",
"ingest_type": "gene",
"__ingest_name": "ncbi_gene",
"min_python_version": "3.10",
"full_name": "Kevin Schaper",
"email": "[email protected]",
"__author": "Kevin Schaper <[email protected]>",
"license": "BSD-3",
"_template": "https://github.com/monarch-initiative/cookiecutter-monarch-ingest.git"
}
},
"directory": null
}
10 changes: 10 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Set update schedule for GitHub Actions

version: 2
updates:

- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
53 changes: 53 additions & 0 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
### This workflow can be run manually from Actions tab in your repository by selecting the "Create Release" workflow.
### When your project is ready for releases, you should:
### - Uncomment the `schedule` section to run this workflow automatically on a schedule.
### - As written, this workflow will run every Sunday at midnight UTC.
### - Remove the `draft: true` line from the `Create Release` step to publish the release immediately.
# TODO: QC/Validation (ex. 0 rows)

name: Create Release

on:
workflow_dispatch:
# schedule:
# - cron: '0 0 * * 0'

jobs:
create-release:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install Dependencies
run: poetry install --no-interaction

- name: Run Transform
run: |
make run
poetry run python scripts/generate-rdf.py
- name: Get Date for Release Tag
run: echo "DATE=$(date +%Y-%m-%d)" >> $GITHUB_ENV

# Further customization for this action is available. See:
# https://github.com/softprops/action-gh-release/?tab=readme-ov-file#-customizing
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.DATE }}
files: |
output/*
generate_release_notes: true
draft: true
38 changes: 38 additions & 0 deletions .github/workflows/deploy-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Auto-Deploy Documentation

on:
push:
branches: [main]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install Dependencies
run: poetry install --with dev --no-interaction

- name: Build Documentation
run: make docs

- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site
target-folder: docs
clean: true
42 changes: 42 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test

on:
push:
branches: [main]
pull_request:
workflow_dispatch:

jobs:
test-backend:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
os: [ubuntu-latest]
#os: [ ubuntu-latest, windows-latest ]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1

#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction

#----------------------------------------------
# run pytest
#----------------------------------------------
- name: Run tests
run: poetry run pytest tests

42 changes: 42 additions & 0 deletions .github/workflows/update-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This GitHub Action updates the documentation with information about the latest KG build/release.

name: Update Documentation

on:
workflow_run:
workflows: ["Create Release"]
types:
- completed

jobs:
update-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install Poetry
uses: snok/install-poetry@v1

- name: Install Dependencies
run: |
poetry install --with dev --no-interaction
- name: Build Documentation
run: |
poetry run python scripts/get-latest-report.py
make docs
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site
target-folder: docs
clean: true
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
31 changes: 31 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Contribution Guidelines

When contributing to this repository, please first discuss the changes you wish to make via an issue, email, or any other method, with the owners of this repository before issuing a pull request.

## How to contribute

### Reporting bugs or making feature requests

To report a bug or suggest a new feature, please go to the [monarch-initiative/NCBI-Gene issue tracker](https://github.com/monarch-initiative/NCBI-Gene/issues), as we consolidate issues there.

Please supply enough details to the developers to enable them to verify and troubleshoot your issue:

* Provide a clear and descriptive title as well as a concise summary of the issue to identify the problem.
* Describe the exact steps which reproduce the problem in as many details as possible.
* Describe the behavior you observed after following the steps and point out what exactly is the problem with that behavior.
* Explain which behavior you expected to see instead and why.
* Provide screenshots of the expected or actual behaviour where applicable.


### The development lifecycle

1. Create a bug fix or feature development branch, based off the `main` branch of the upstream repo, and not your fork. Name the branch appropriately, briefly summarizing the bug fix or feature request. If none come to mind, you can include the issue number in the branch name. Some examples of branch names are, `bugfix/breaking-pipfile-error` or `feature/add-click-cli-layer`, or `bugfix/issue-414`
2. Make sure your development branch has all the latest commits from the `main` branch.
3. After completing work and testing locally, push the code to the appropriate branch on your fork or origin repository.
4. Create a pull request from the bug/feature branch of your fork to the `main` branch of the upstream repository.

**NOTE**: All the development must be done on a separate branch, either in your fork or in the origin repository. The `main` branch of the upstream repository should never be used for development.

**ALSO NOTE**: github.com lets you create a pull request from the main branch, automating the steps above.

> A code review (which happens with both the contributor and the reviewer present) is required for contributing.
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Copyright (c) 2024, Monarch Initiative
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of pytest-NCBI Gene nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103 changes: 96 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,101 @@
ROOTDIR = $(shell pwd)
RUN = poetry run
VERSION = $(shell poetry -C src/ncbi_gene version -s)

### Help ###

define HELP
╭───────────────────────────────────────────────────────────╮
Makefile for ncbi_gene
│ ───────────────────────────────────────────────────────── │
│ Usage: │
│ make <target> │
│ │
│ Targets: │
│ help Print this help message │
│ │
│ all Install everything and test │
│ fresh Clean and install everything │
│ clean Clean up build artifacts │
│ clobber Clean up generated files │
│ │
│ install Poetry install package │
│ download Download data │
│ run Run the transform │
│ │
│ docs Generate documentation │
│ │
│ test Run all tests │
│ │
│ lint Lint all code │
│ format Format all code │
╰───────────────────────────────────────────────────────────╯
endef
export HELP

.PHONY: help
help:
@printf "$${HELP}"


### Installation and Setup ###

.PHONY: fresh
fresh: clean clobber all

.PHONY: all
all: install test

.PHONY: install
install:
poetry install --with dev


### Documentation ###

.PHONY: docs
docs:
$(RUN) mkdocs build


### Testing ###

.PHONY: test
test: download
$(RUN) pytest tests


### Running ###

.PHONY: download
download:
downloader
$(RUN) ingest download

.PHONY: run
run: download
$(RUN) ingest transform
$(RUN) python scripts/generate-report.py


### Linting, Formatting, and Cleaning ###

.PHONY: clean
clean:
rm -f `find . -type f -name '*.py[co]' `
rm -rf `find . -name __pycache__` \
.venv .ruff_cache .pytest_cache **/.ipynb_checkpoints

.PHONY: clobber
clobber:
# Add any files to remove here
@echo "Nothing to remove. Add files to remove to clobber target."

.PHONY: transform
transform:
koza transform --source ncbi_gene.yaml --target ncbi_gene.json
.PHONY: lint
lint:
$(RUN) ruff check --diff --exit-zero
$(RUN) black -l 120 --check --diff src tests

.PHONY: rdf
rdf:
kgx transform -i tsv -f nt -d gz -o output/ncbi_gene_nodes.nt.gz output/ncbi_gene_nodes.tsv
.PHONY: format
format:
$(RUN) ruff check --fix --exit-zero
$(RUN) black -l 120 src tests
Loading

0 comments on commit 3160c3a

Please sign in to comment.