Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/mx-1381 prepare database model rework #69

Merged
merged 45 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
4f2d5b0
Add entityType stub to MExModel
cutoffthetop Jan 23, 2024
8c48c65
Clean up base classes and add AnyXYZModel types
cutoffthetop Jan 23, 2024
7d738c8
Merge branch 'main' of https://github.com/robert-koch-institut/mex-co…
cutoffthetop Jan 23, 2024
0de26b4
Fix tests
cutoffthetop Jan 23, 2024
c203888
Fix fixture using mark
cutoffthetop Feb 14, 2024
7b51ca0
Add transform utils
cutoffthetop Feb 14, 2024
9eb30ba
Replace ContextVar with ContextStore
cutoffthetop Feb 14, 2024
a24cd37
Merge branch 'main' of https://github.com/robert-koch-institut/mex-co…
cutoffthetop Feb 14, 2024
2619f1a
Update poetry
cutoffthetop Feb 14, 2024
c2767d2
Move stableTargetId typehint to extractedData
cutoffthetop Feb 14, 2024
68df38e
Mark frozen fields
cutoffthetop Feb 14, 2024
cf828ec
Add nested model lookup
cutoffthetop Feb 14, 2024
1f2ba8f
Remove mappings that cause circularity
cutoffthetop Feb 14, 2024
62d5e91
Update versions
cutoffthetop Feb 15, 2024
1b02d1b
Add new linting
cutoffthetop Feb 16, 2024
5567101
Merge branch 'main' of https://github.com/robert-koch-institut/mex-co…
cutoffthetop Feb 16, 2024
e880075
Update docstring
cutoffthetop Feb 16, 2024
cdb70c8
Update changelog
cutoffthetop Feb 16, 2024
75d2ee7
Poetry update
cutoffthetop Feb 19, 2024
4b5ffb1
Move stableTargetId to extracted data classes
cutoffthetop Feb 20, 2024
c308312
Merge branch 'main' of https://github.com/robert-koch-institut/mex-co…
cutoffthetop Feb 20, 2024
d3bd12a
Specify identifiers and remove public-api module
cutoffthetop Feb 20, 2024
5dfcdd5
Update cruft
cutoffthetop Feb 20, 2024
c785f4c
Random order testing
cutoffthetop Feb 20, 2024
4395d9b
Bump urllib3 from 2.2.0 to 2.2.1
dependabot[bot] Feb 21, 2024
452c5c6
Clean up and rename MExModel
cutoffthetop Feb 21, 2024
8160df2
Remove public-api, update cruft, maintain code
cutoffthetop Feb 21, 2024
65ba71a
Merge branch 'feature/mx-1562-code-maintenance' into feature/mx-1381-…
cutoffthetop Feb 21, 2024
9d4ae54
Fix changelog style
cutoffthetop Feb 21, 2024
4bcddfa
Add pytest.mark fix to changelog
cutoffthetop Feb 21, 2024
e6fdfdb
Fix makefile docstr
cutoffthetop Feb 21, 2024
38e44d4
Merge branch 'feature/mx-1562-code-maintenance' into feature/mx-1381-…
cutoffthetop Feb 21, 2024
368c0ce
Prefer annotated field syntax
cutoffthetop Feb 21, 2024
13a4b74
Merge branch 'main' of https://github.com/robert-koch-institut/mex-co…
cutoffthetop Feb 23, 2024
1bcbd64
Lock
cutoffthetop Feb 23, 2024
c35c283
Simplify and add tests
cutoffthetop Feb 23, 2024
9aee2ee
Fix code quote
cutoffthetop Feb 23, 2024
4512f90
Merge branch 'main' of https://github.com/robert-koch-institut/mex-co…
cutoffthetop Feb 27, 2024
9af2142
Update cruft ref
cutoffthetop Feb 27, 2024
7a38f7e
Merge branch 'main' into feature/mx-1381-prep-rule-endpoint
cutoffthetop Mar 4, 2024
245670f
Merge branch 'main' of https://github.com/robert-koch-institut/mex-co…
cutoffthetop Mar 4, 2024
8a2668f
Lock file
cutoffthetop Mar 4, 2024
3b83cca
Update cruft
cutoffthetop Mar 4, 2024
68cbb6d
Merge branch 'feature/mx-1381-prep-rule-endpoint' of https://github.c…
cutoffthetop Mar 4, 2024
aa6192b
Prepare release 0.21
cutoffthetop Mar 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"checkout": null,
"commit": "6067fc53d1335a9bda900c5eff8dbf1c42bfe4ca",
"commit": "77ce51f46b0897c6fbd29782c32923075e296c2a",
"context": {
"cookiecutter": {
"project_name": "common",
Expand Down
10 changes: 9 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ updates:
- package-ecosystem: "github-actions"
allow:
- dependency-type: "all"
assignees:
- ${{secrets.MEX_BOT_USER}}
directory: "/"
labels:
- "dependabot"
open-pull-requests-limit: 1
schedule:
interval: "monthly"
interval: "weekly"
- package-ecosystem: "pip"
allow:
- dependency-type: "all"
assignees:
- ${{secrets.MEX_BOT_USER}}
directory: "/"
labels:
- "dependabot"
open-pull-requests-limit: 1
schedule:
interval: "daily"
61 changes: 54 additions & 7 deletions .github/workflows/cookiecutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Cookiecutter

on:
push:
pull_request:
branches: ["main"]
tags: ["**"]
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
Expand All @@ -18,12 +19,13 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1
fetch-depth: 0
token: ${{ secrets.WORKFLOW_TOKEN }}

- name: Cache requirements
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-requirements
with:
Expand All @@ -33,12 +35,57 @@ jobs:
${{ env.cache-name }}-

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Install requirements
run: make setup

- name: Check template
run: cruft check
- name: Configure git
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PUB: ${{ secrets.SIGNING_PUB }}
run: |
eval "$(ssh-agent -s)"
install --directory ~/.ssh --mode 700
base64 -d <<< '${{ secrets.SIGNING_KEY }}' > ~/.ssh/mex
base64 -d <<< '${{ secrets.SIGNING_PUB }}' > ~/.ssh/mex.pub
chmod 600 ~/.ssh/*
ssh-add ~/.ssh/mex
git config --local user.email ${{ vars.MEX_BOT_EMAIL }}
git config --local user.name ${{ vars.MEX_BOT_USER }}
git config --local gpg.format ssh
git config --local user.signingkey ~/.ssh/mex.pub
git config --local commit.gpgsign true

- name: Update template
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if cruft check; then
echo template is up to date
exit 0
fi
if [[ $(gh pr list --label cruft | wc -c) -ne 0 ]]; then
echo already seeing pull request
exit 0
fi
template_url=$(python -c "print(__import__('json').load(open('.cruft.json'))['template'])")
template_ref=$(git ls-remote ${template_url} --heads main --exit-code | cut -c -6)
git checkout main
git checkout -b cruft/cookiecutter-template-${template_ref}
cruft update --skip-apply-ask
printf '# Changes\n\n- bumped cookiecutter template to %s/commit/%s\n' "$template_url" "$template_ref" > .cruft-pr-body
if [[ $(git status --porcelain | grep .rej | wc -c) -ne 0 ]]; then
printf '\n# Conflicts\n' > .cruft-pr-body
fi
git status --porcelain | grep .rej | awk '{print $2;}' | while read -r line ; do
printf '\n```' >> .cruft-pr-body
cat ${line} >> .cruft-pr-body
printf '```\n' >> .cruft-pr-body
done
git add --all --verbose
git commit --message "Bump cookiecutter template to $template_ref" --verbose
git push --set-upstream origin cruft/cookiecutter-template-${template_ref} --force --verbose
gh pr create --title "Bump cookiecutter template to $template_ref" --body-file .cruft-pr-body --label cruft --assignee ${{ vars.MEX_BOT_USER }}
8 changes: 6 additions & 2 deletions .github/workflows/cve-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
branches-ignore:
- 'dependabot/**'
pull_request:
types:
- opened
- reopened
- synchronize
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
Expand All @@ -18,12 +22,12 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Cache trivy
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-trivy
with:
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Cache requirements
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-requirements
with:
Expand All @@ -40,7 +40,7 @@ jobs:
${{ env.cache-name }}-

- name: Cache poetry
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-poetry
with:
Expand All @@ -50,12 +50,12 @@ jobs:
${{ env.cache-name }}-

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11

- name: Setup pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v4

- name: Install requirements
run: make install
Expand All @@ -64,7 +64,7 @@ jobs:
run: make docs

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: ./docs/dist

Expand All @@ -77,4 +77,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4
12 changes: 8 additions & 4 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Linting
on:
push:
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:

env:
Expand All @@ -16,12 +20,12 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Cache requirements
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-requirements
with:
Expand All @@ -31,7 +35,7 @@ jobs:
${{ env.cache-name }}-

- name: Cache poetry
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-poetry
with:
Expand All @@ -41,7 +45,7 @@ jobs:
${{ env.cache-name }}-

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/open-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: 'main'
fetch-depth: 0
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/reviewing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Review

on:
pull_request:
types:
- opened
workflow_dispatch:

jobs:
assignee:
runs-on: ubuntu-latest
timeout-minutes: 10
if: >-
github.event.pull_request.user.login != ${{ vars.MEX_BOT_USER }} &&
github.event.pull_request.user.login != 'dependabot[bot]'
steps:
- name: Add assignee
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [[ -z "${{ github.event.pull_request.assignee.login }}" ]]; then
echo assigning to ${{ github.event.pull_request.user.login }}
gh pr edit ${{ github.event.pull_request.html_url }} --add-assignee ${{ github.event.pull_request.user.login }}
else
echo already assigned
fi
12 changes: 8 additions & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Testing
on:
push:
pull_request:
types:
- opened
- reopened
- synchronize
workflow_dispatch:

env:
Expand All @@ -16,12 +20,12 @@ jobs:
timeout-minutes: 10
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Cache requirements
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-requirements
with:
Expand All @@ -31,7 +35,7 @@ jobs:
${{ env.cache-name }}-

- name: Cache poetry
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-poetry
with:
Expand All @@ -41,7 +45,7 @@ jobs:
${{ env.cache-name }}-

- name: Setup python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ dmypy.json
# ruff
.ruff_cache

# cruft
.cruft-pr-body
*.rej

# PyCharm
.idea/
.idea_modules/
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ default_language_version:
python: python3.11
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.2.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -27,7 +27,7 @@ repos:
- id: fix-byte-order-marker
name: byte-order
- repo: https://github.com/python-poetry/poetry
rev: 1.7.1
rev: 1.8.1
hooks:
- id: poetry-check
name: poetry
Expand Down
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,31 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security

## [0.21.0] - 2024-03-04

### Added

- add `entityType` type hint to `MExModel` (now `BaseEntity`)
- add types for `AnyBaseModel`, `AnyExtractedModel` and `AnyMergedModel`
- create more specific subclasses of `Identifier` (for extracted and merged)
- expose unions, lists and lookups for `Identifier` subclasses in `mex.common.types`

### Changes

- swap `contextvars.ContextVar` for `mex.common.context.ContextStore`
- move `stableTargetId` property from base models to extracted models
- update typing of identifiers to specific subclasses
- use `Annotated[..., Field(...)]` notation for pydantic field configs
- split up `mex.common.models.base` and move out `MExModel` and `JsonSchemaGenerator`
- rename `MExModel` to `BaseEntity` with only type hints an model config
- declare `hadPrimarySource`, `identifier` and `identifierInPrimarySource` as frozen

### Removed

- absorb unused `BaseExtractedData` into `ExtractedData`
- remove `stableTargetId` property from merged models
- drop support for sinks to accept merged items (now only for extracted data)

## [0.20.0] - 2024-02-22

### Changes
Expand Down
Loading
Loading