Skip to content

Commit

Permalink
feat: setup Lintes for repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Bento007 authored Feb 13, 2024
2 parents 49237a7 + 6a1a5c4 commit 4a70384
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 8 deletions.
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug report
about: Create a report to help us improve
title: "bug( ):"
labels: bug
assignees: ""
---

## Describe the bug

A clear and concise description of what the bug is.

## To Reproduce

Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

## Expected behavior

A clear and concise description of what you expected to happen.

## Environment

**Desktop (please complete the following information):**

- OS: [e.g. iOS]
- Version [e.g. 22]

**Python Version (please complete the following information):**

- Version [e.g. 22]

## Additional context

Add any other context about the problem here.
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Feature request
about: Suggest an idea for this project
title: "feat( ):"
labels: ""
assignees: ""
---

## Need

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

## Approach

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.

## Definition of Done

• This is what I will demo
• This is what it will do.
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/tech-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Tech Issue
about:
Engineering-specific technical work that is not product-specific. Engineering
team "owns" these issues.
title: ""
labels: tech
assignees: ""
---

## Motivation

Why is this work important to engineers?

## Definition of Done

What should the end result look like? What will have been changed?

## Tasks

Detail the specific tasks that can be used to accomplish the desired changes.
If detailed steps cannot be provided at this time, please file a [Tech Proposal](https://docs.google.com/document/d/1o2vuvl-kXwRJN1nBoPzJS_MAQgDGYnjmPZWa4qRDi-I/edit#heading=h.7dvzhm7gqc3v) instead.

- [ ]
- [ ]
2 changes: 1 addition & 1 deletion .github/workflows/generate_all_ontology.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Updates to Ontology Files
on:
push:
paths:
- '**/tools/ontology-builder/ontology-references/owl_info.yml'
- "**/tools/ontology-builder/ontology-references/owl_info.yml"
branches-ignore:
- main

Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/push-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Push Tests

on:
pull_request:
branches:
- "*"
push:
branches:
- "main"

env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

permissions:
id-token: write
contents: read

jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-python@v5
- name: lint checks
uses: pre-commit/action@v3.0.0
Empty file added .gitignore
Empty file.
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repos:
- repo: https://github.com/psf/black
rev: 24.2.0 # Must be kept in sync with black version in requirements.txt
hooks:
- id: black
stages: [commit]
files: ^(api/python|tools)/
args: ["--config", "pyproject.toml"]
exclude_types: ["json"]

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: ruff
args: ["--config=pyproject.toml", "--fix"]
stages: [commit]
files: ^(api/python|tools)/
exclude_types: ["json"]

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
args: [--write]
stages: [commit]
exclude_types: ["json"]
additional_dependencies:
- prettier@3.0.2
- prettier-plugin-organize-imports@2.3.3
- typescript@4.9.5
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.8.0"
hooks:
- id: mypy
args: [--strict, --ignore-missing-imports]
additional_dependencies: [types-PyYAML]
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lint:
pre-commit run --all-files

17 changes: 17 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Reason for Change

- #TICKET_NUMBER
- If the reason for this PR's code changes are not clear in the issue, state value/impact

## Changes

- add
- remove
- modify

## Testing steps

- Either list QA steps or reasoning you feel QA is unnecessary
- Describe how you made sure to know that your changes worked. Should allow someone else to go verify your code without in depth knowledge.

## Notes for Reviewer
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# cellxgene-ontology

starter template for CZI open source projects

## Code of Conduct
Expand Down
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[tool.black]
line-length = 120
target_version = ['py38']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| venv
| virtualenv
| _build
| buck-out
| build
| dist
| vendor
| vendor.in
| node_modules
)/
)
'''

[tool.ruff]
select = ["E", "F", "B", "SIM", "C4", "I"]
ignore = ["E501", "E402", "C408", ]
line-length = 120
target-version = "py38"
14 changes: 7 additions & 7 deletions tools/ontology-builder/all_ontology_generator.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import env
import gzip
import json
import os
import re
import urllib.request
from threading import Thread
from typing import List
from typing import Any, Dict, List
from urllib.error import HTTPError, URLError

import env
import owlready2
import yaml


def _download_owls(owl_info_yml: str = env.OWL_INFO_YAML, output_dir: str = env.ONTOLOGY_DIR):
def _download_owls(owl_info_yml: str = env.OWL_INFO_YAML, output_dir: str = env.ONTOLOGY_DIR) -> None:
"""
Downloads the ontology owl files specified in 'owl_info_yml' into 'output_dir'
Expand All @@ -25,7 +25,7 @@ def _download_owls(owl_info_yml: str = env.OWL_INFO_YAML, output_dir: str = env.
with open(owl_info_yml, "r") as owl_info_handle:
owl_info = yaml.safe_load(owl_info_handle)

def download(_ontology, _url):
def download(_ontology: str, _url: str) -> None:
print(f"Start Downloading {_ontology}")
# Format of owl (handles cases where they are compressed)
download_format = _url.split(".")[-1]
Expand Down Expand Up @@ -58,7 +58,7 @@ def download(_ontology, _url):
t.join()


def _decompress(infile: str, tofile: str):
def _decompress(infile: str, tofile: str) -> None:
"""
Decompresses a gziped file
Expand All @@ -76,7 +76,7 @@ def _parse_owls(
working_dir: str = env.ONTOLOGY_DIR,
owl_info_yml: str = env.OWL_INFO_YAML,
output_json_file: str = env.PARSED_ONTOLOGIES_FILE,
):
) -> None:
"""
Parser all owl files in working_dir. Extracts information from all classes in the owl file.
The extracted information is written into a gzipped a json file with the following structure:
Expand Down Expand Up @@ -118,7 +118,7 @@ def _parse_owls(
owl_files.append(os.path.join(working_dir, owl_file))

# Parse owl files
onto_dict = {}
onto_dict: Dict[str, Any] = {}
for owl_file in owl_files:
world = owlready2.World()
onto = world.get_ontology(owl_file)
Expand Down

0 comments on commit 4a70384

Please sign in to comment.