Skip to content

Commit

Permalink
feat!: sharpen up type usage (#332)
Browse files Browse the repository at this point in the history
close #285 

* Clean up types and type annotations where possible. Not exhaustive --
there's some stuff that probably needs refactoring to make progress on
-- but made some good progress, such that I think we can say the "types"
issue is closed enough.
* **maybe important**: by virtue of where json model dumps were
happening, this introduced a small change to the order of the keys in
some dicts that were getting sha512'd, which meant the ID changed during
testing. I set JSON serialization to first sort keys in order so that
this doesn't matter in the future, but this does entail a one-time
change in digest ID. if that's bad, I can revert and try to figure out a
workaround.
* Also changed how stuff from GKS/VRS models are imported so that the
code is a little more succinct. I think `models.Variation` style imports
were a relic from a Python-JSONschema-objects custom and we don't need
to do it anymore.
  • Loading branch information
jsstevenson authored May 10, 2024
1 parent 7891226 commit 4855309
Show file tree
Hide file tree
Showing 29 changed files with 585 additions and 423 deletions.
85 changes: 85 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Bug Report
description: Report a bug.
labels: ["bug"]
body:
- type: textarea
attributes:
label: Describe the bug
description: Provide a clear and concise description of what the bug is.
validations:
required: true
- type: textarea
attributes:
label: Steps to reproduce
description: Provide detailed steps to replicate the bug.
placeholder: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: What did you expect to happen?
validations:
required: true
- type: textarea
attributes:
label: Current behavior
description: |
What actually happened?
Include full errors, stack traces, and/or relevant logs.
validations:
required: true
- type: textarea
attributes:
label: Possible reason(s)
description: Provide any insights into what might be causing the issue.
validations:
required: false
- type: textarea
attributes:
label: Suggested fix
description: Provide any suggestions on how to resolve the bug.
validations:
required: false
- type: textarea
attributes:
label: Branch, commit, and/or version
description: Provide the branch, commit, and/or version you're using.
placeholder: |
branch: issue-1
commit: abc123d
validations:
required: true
- type: textarea
attributes:
label: Screenshots
description: If applicable, add screenshots with descriptions to help explain your problem.
validations:
required: false
- type: textarea
attributes:
label: Environment details
description: Provide environment details (OS name and version, etc).
validations:
required: true
- type: textarea
attributes:
label: Additional details
description: Provide any other additional details about the problem.
validations:
required: false
- type: dropdown
attributes:
label: Contribution
description: Can you contribute to the development of this feature?
options:
- "Yes, I can create a PR for this fix."
- "Yes, but I can only provide ideas and feedback."
- "No, I cannot contribute."
validations:
required: true
60 changes: 60 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Feature Request
description: Suggest an idea for this project.
labels: ["enhancement"]
body:
- type: textarea
attributes:
label: Feature description
description: Provide a clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Use case
description: |
Why do you need this feature? For example: "I'm always frustrated when..."
validations:
required: true
- type: textarea
attributes:
label: Proposed solution
description: Provide proposed solution.
validations:
required: false
- type: textarea
attributes:
label: Alternatives considered
description: Describe any alternative solutions you've considered.
validations:
required: false
- type: textarea
attributes:
label: Implementation details
description: Provide any technical details on how the feature might be implemented.
validations:
required: false
- type: textarea
attributes:
label: Potential Impact
description: |
Discuss any potential impacts of this feature on existing functionality or performance, if known.
Will this feature cause breaking changes?
What challenges might arise?
validations:
required: false
- type: textarea
attributes:
label: Additional context
description: Provide any other context or screenshots about the feature.
validations:
required: false
- type: dropdown
attributes:
label: Contribution
description: Can you contribute to the development of this feature?
options:
- "Yes, I can create a PR for this feature."
- "Yes, but I can only provide ideas and feedback."
- "No, I cannot contribute."
validations:
required: true
13 changes: 13 additions & 0 deletions .github/workflows/branch_workflow_rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Branch workflow rules
on:
pull_request:
types: [opened, reopened, edited]
jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- name: check_branch_names
if: ${{ github.base_ref == 'main' && github.head_ref != 'staging' }}
run: |
echo "Head branch must be 'staging' when creating a PR where the base branch is 'main'"
exit 1
2 changes: 1 addition & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3

Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/stale.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Make comments on stale issues and PRs"

on:
schedule:
- cron: "30 13 * * *"

jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v9
with:
remove-stale-when-updated: true

days-before-issue-stale: 45
stale-issue-label: stale
stale-issue-message: "This issue is stale because it has been open 45 days with no activity. Please make a comment for triaging or closing the issue."

days-before-pr-stale: 7
stale-pr-label: stale
stale-pr-message: "This PR is stale because it has been open 7 days with no activity. Please review this PR."
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ classifiers = [
"Topic :: Scientific/Engineering :: Bio-Informatics",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.8"
requires-python = ">=3.10"
description = "A search interface for cancer variant interpretations assembled by aggregating and harmonizing across multiple cancer variant interpretation knowledgebases."
license = {file = "LICENSE"}
dependencies = [
Expand Down
8 changes: 4 additions & 4 deletions src/metakb/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import logging
import re
import tempfile
from collections.abc import Callable
from os import environ
from pathlib import Path
from timeit import default_timer as timer
from typing import Optional
from zipfile import ZipFile

import asyncclick as click
Expand Down Expand Up @@ -117,7 +117,7 @@ async def update_metakb_db(
force_load_normalizers_db: bool,
normalizers_db_url: str,
load_latest_cdms: bool,
load_target_cdm: Optional[Path],
load_target_cdm: Path | None,
load_latest_s3_cdms: bool,
update_cached: bool,
) -> None:
Expand Down Expand Up @@ -228,7 +228,7 @@ def _load_normalizers_db() -> None:

def _update_normalizer_db(
name: str,
update_normalizer_db_fn: callable,
update_normalizer_db_fn: Callable[[str, bool, str, bool, bool, bool], None],
) -> None:
"""Update Normalizer DynamoDB database.
Expand Down Expand Up @@ -331,7 +331,7 @@ def _retrieve_s3_cdms() -> str:
key=lambda f: f.key,
reverse=True,
)
newest_version: Optional[str] = None
newest_version: str | None = None

for file in bucket:
match = re.match(
Expand Down
Loading

0 comments on commit 4855309

Please sign in to comment.