Skip to content
Merged

Dev #5477

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
0ca6025
update test requirements
hanars May 20, 2026
b95b675
use django for db setup
hanars May 20, 2026
fe4dd34
update requiremnts
hanars May 20, 2026
068833f
use seqr requiremnts
hanars May 20, 2026
809a6d3
use venv
hanars May 20, 2026
261cdd0
no seqr app migrations
hanars May 20, 2026
f115f20
fix venv
hanars May 20, 2026
62eec9a
split setup steps
hanars May 20, 2026
13d8176
remove venv for now
hanars May 20, 2026
74fa807
add postgres
hanars May 20, 2026
e0e4e1f
Merge branch 'vlm-no-hail' of https://github.com/broadinstitute/seqr …
hanars May 20, 2026
a606624
depndency install order
hanars May 21, 2026
79f1531
psycopg setup
hanars May 21, 2026
d2c1aaa
add clickhous eports
hanars May 21, 2026
7381323
env reset
hanars May 21, 2026
203aa1e
fix clcikhouse host
hanars May 21, 2026
8bd7a87
explicitly create database
hanars May 21, 2026
a0f6eb6
use default github actions docker
hanars May 21, 2026
81766d7
fix clickhouse hostname
hanars May 21, 2026
2601e0c
remove extra psycopg
hanars May 21, 2026
4e68be2
test setup order
hanars May 21, 2026
f4029bb
add clikhouse data dirs
hanars May 21, 2026
1781696
use venv
hanars May 21, 2026
168372b
reload users
hanars May 21, 2026
9da4a70
setup order
hanars May 21, 2026
0c25271
run all db migrations
hanars May 21, 2026
9ee12e9
install postrgres db too
hanars May 21, 2026
17c64ac
postgres db setup
hanars May 21, 2026
0c8add8
use pytest for test db creation
hanars May 21, 2026
cb28176
depndency install
hanars May 21, 2026
dd8a174
use setup_databases explicitly
hanars May 21, 2026
2be770c
pytest django
hanars May 21, 2026
0849693
clean up
hanars May 21, 2026
8d1c300
pytest setup runner
hanars May 21, 2026
7338a2c
debug
hanars May 21, 2026
91c104f
undo debug
hanars May 21, 2026
964421b
do not actually run tests
hanars May 21, 2026
c0aef7b
restart venv
hanars May 26, 2026
8f43fd8
no venv debug
hanars May 26, 2026
893750a
correct db name
hanars May 26, 2026
1d91c51
Revert "no venv debug"
hanars May 26, 2026
8b9ede4
install soiurce
hanars May 26, 2026
b96da89
use explicit venv python for pytest
hanars May 26, 2026
1623ab8
explicitly skip pytest ui
hanars May 26, 2026
288d763
delete old jsx python test
hanars May 26, 2026
c1a67fc
clean up
hanars May 26, 2026
d29c725
clean up
hanars May 26, 2026
9591a59
missing dependencies
hanars May 26, 2026
b208913
more requirements
hanars May 26, 2026
b9d60dd
install order
hanars May 26, 2026
62dac69
DJANGO_SETTINGS_MODULE
hanars May 26, 2026
8bbb867
use migrate directly
hanars May 26, 2026
7880db3
create db
hanars May 26, 2026
22378a6
back to pytets
hanars May 26, 2026
aa9b3ec
rename test db
hanars May 26, 2026
1f2f928
fix syntax
hanars May 26, 2026
794196d
verbosity
hanars May 26, 2026
bc60307
actually keep db
hanars May 26, 2026
74cdea0
more verbose
hanars May 26, 2026
1ef8a20
actually run test
hanars May 26, 2026
5762477
skip tests
hanars May 26, 2026
10d6ce3
run tests
hanars May 26, 2026
56a9012
run single test
hanars May 26, 2026
52e3693
do not recreate db
hanars May 26, 2026
0b684d2
try setup only
hanars May 26, 2026
b9a3952
unblock django db access
hanars May 26, 2026
c1d5bdf
enable databases for vlm tests
hanars May 26, 2026
d34aace
better fixture
hanars May 26, 2026
5d60cc9
custom db setup
hanars May 26, 2026
e1564ff
clean up
hanars May 26, 2026
d959a64
cleaner args
hanars May 26, 2026
f816071
fix typing
hanars May 26, 2026
140ccdc
run vlm tests on fixture update
hanars May 26, 2026
f8a9792
no custom django settings
hanars May 26, 2026
fb5cf50
set up default db
hanars May 26, 2026
1dbeba8
clickhouse settings move up
hanars May 26, 2026
a469c64
settings profile
hanars May 26, 2026
e194003
clickhouse grant permissions
hanars May 26, 2026
b5f83cd
users config
hanars May 26, 2026
5a52747
use config
hanars May 27, 2026
6483e9e
clean up
hanars May 27, 2026
984981c
clean up
hanars May 27, 2026
ab63500
remove user grants for now
hanars May 27, 2026
99f715b
reload users again
hanars May 27, 2026
cc56f31
readd user rants
hanars May 27, 2026
cfcee04
remove unused file
hanars May 27, 2026
a6f28f8
clickhouse official docker for tests
hanars May 27, 2026
3d7a68b
test user access managemnt
hanars May 27, 2026
67988d8
add settings
hanars May 27, 2026
67bc6bf
vlm test access maagement
hanars May 27, 2026
ddcfa46
reload config
hanars May 27, 2026
b8da132
restart clickhouse after confi update
hanars May 27, 2026
4f59076
wait for restart
hanars May 27, 2026
3046d47
explicit sleep for restart
hanars May 27, 2026
a100ce9
change order
hanars May 27, 2026
f486981
test with service wait loop
hanars May 27, 2026
37dfe6b
use correct port ofr curl
hanars May 27, 2026
cacefff
correct endpoint
hanars May 27, 2026
0bde7bf
seqr hosted clickhouse image
hanars May 27, 2026
695408f
health check clean up
hanars May 27, 2026
686e300
debug test failure
hanars May 27, 2026
0e2a4d4
debug test failure
hanars May 27, 2026
41267ee
debug test failure
hanars May 27, 2026
b7e5fad
debug test failure
hanars May 27, 2026
d9c4fcd
try cache settings
hanars May 27, 2026
becdaaa
settings iter
hanars May 27, 2026
5c306ca
settings iter
hanars May 27, 2026
ce4a4ba
settings iter
hanars May 27, 2026
b931447
settings iter
hanars May 28, 2026
22ad270
settings iter
hanars May 28, 2026
737eeb3
settings iter
hanars May 28, 2026
96ff9df
settings iter
hanars May 28, 2026
4ac1ef8
settings iter
hanars May 28, 2026
0cca691
settings iter
hanars May 28, 2026
799c93f
settings iter
hanars May 28, 2026
8a18d93
clean up
hanars May 28, 2026
0491d23
Merge branch 'clickhouse-bump-unit-test-version' of https://github.co…
hanars May 28, 2026
90fefd0
setup for bumped version
hanars May 28, 2026
d2f451c
adjust settings profile
hanars May 28, 2026
915f7cc
run without pytest setup
hanars May 28, 2026
66e0f6b
add dbs
hanars May 28, 2026
964a42e
initialize reference data db
hanars May 28, 2026
6b4e630
skip postgres setup
hanars May 28, 2026
5810451
reference data db
hanars May 28, 2026
896fb22
postgres iage name
hanars May 28, 2026
6816ef4
fix reference data db reate
hanars May 28, 2026
06701ac
create clickhouse db
hanars May 28, 2026
2734699
back to pytest
hanars May 28, 2026
c851d3a
create dbs
hanars May 29, 2026
b3394fd
fix loaddata
hanars May 29, 2026
959cf85
debug clickhouse users
hanars May 29, 2026
7f309d2
remove debug
hanars May 29, 2026
5fb7297
escape chars
hanars May 29, 2026
d0b20cf
fix user creation
hanars May 29, 2026
f6480a7
remove invalid arg
hanars May 29, 2026
7e441c0
lower verbosity
hanars May 29, 2026
ff56d59
Revert "setup for bumped version"
hanars May 29, 2026
49d06f4
Revert "Merge branch 'clickhouse-bump-unit-test-version' of https://g…
hanars May 29, 2026
1b29a75
settings cleanup
hanars May 29, 2026
7523963
Merge branch 'dev' of https://github.com/broadinstitute/seqr into vlm…
hanars May 29, 2026
83376dc
restore merge issues
hanars May 29, 2026
0434fcf
pip cache
hanars May 29, 2026
4c26cdc
pip cache order
hanars May 29, 2026
0508de1
remove unneeded fixture
hanars May 29, 2026
5a2365b
verride method
hanars May 29, 2026
7005f0f
override method
hanars May 29, 2026
759df9c
update test
hanars May 29, 2026
0ca748f
reload gt stats
hanars May 29, 2026
0cb106c
correct counts
hanars May 29, 2026
3c28d81
correct counts
hanars May 29, 2026
012ad43
update total counts
hanars May 29, 2026
bf26cf5
fix counts
hanars May 29, 2026
929f6a4
update coverage
hanars May 29, 2026
e65db74
Merge branch 'dev' of https://github.com/broadinstitute/seqr into vlm…
hanars May 29, 2026
29a3ec7
Merge branch 'dev' of https://github.com/broadinstitute/seqr into vlm…
hanars May 29, 2026
394e7c0
fix vlm requirements install
hanars May 29, 2026
583b627
disable rna reference tracks for grach37
hanars May 29, 2026
e0083eb
Merge pull request #5468 from broadinstitute/rna-seq-hg37-references
hanars May 29, 2026
c7a858b
Merge pull request #5467 from broadinstitute/vlm-docker-reequirents
hanars May 29, 2026
0d3ac44
update gnomad constartint citation
hanars May 29, 2026
71d8608
fix linting
hanars May 29, 2026
2e5be0c
Merge pull request #5469 from broadinstitute/gnomad-constraint-citation
hanars Jun 1, 2026
227b2a3
sync tag updates to postgres dicts
hanars Jun 3, 2026
0498c89
reload metadata on project update
hanars Jun 3, 2026
1386778
family update reload
hanars Jun 3, 2026
a5fabc3
individual update reloads
hanars Jun 4, 2026
622fc4c
log user with relaods
hanars Jun 4, 2026
5722238
fix tests
hanars Jun 4, 2026
0b7806b
fix saved variant data tests
hanars Jun 4, 2026
74d5a58
test family updte metadata
hanars Jun 4, 2026
5034717
individual tests
hanars Jun 4, 2026
6a452a5
test project updates
hanars Jun 4, 2026
262deb8
test saved variant relaod
hanars Jun 4, 2026
9aaa4b9
fix tests
hanars Jun 4, 2026
0bafd43
pr feedback
hanars Jun 4, 2026
fabf64e
Merge pull request #5456 from broadinstitute/clickhouse-bump-unit-tes…
hanars Jun 8, 2026
6d5072e
Merge branch 'dev' of https://github.com/broadinstitute/seqr into vlm…
hanars Jun 8, 2026
692e3ff
actually merge dev
hanars Jun 8, 2026
5738357
update for newwer verrsion
hanars Jun 8, 2026
0d7c2cc
clean up db config for clickhouse
hanars Jun 8, 2026
5aef707
fix settings vars
hanars Jun 8, 2026
3e44ff6
Bump shell-quote from 1.8.1 to 1.8.4 in /ui
dependabot[bot] Jun 9, 2026
d9684c5
Merge pull request #5475 from broadinstitute/dependabot/npm_and_yarn/…
hanars Jun 9, 2026
d9be882
Merge pull request #5472 from broadinstitute/postgres-dict-reloads
hanars Jun 10, 2026
a825833
Merge pull request #5474 from broadinstitute/db-config-cleanup
hanars Jun 10, 2026
b8e95c6
Merge pull request #5448 from broadinstitute/vlm-shared-test-db
hanars Jun 10, 2026
71c12ef
correctly mock response in tests
hanars Jun 10, 2026
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
26 changes: 21 additions & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ jobs:
# Maps tcp port 5432 on service container to the host
- 5432:5432
clickhouse:
image: bitnamilegacy/clickhouse:latest
image: gcr.io/seqr-project/seqr-clickhouse:26.3.9
ports:
- 9000:9000 # Native client interface
- 8123:8123 # HTTP interface
volumes:
- /var/tmp:/var/seqr/clickhouse-data
- /tmp:/in-memory-dir
Expand All @@ -57,12 +58,13 @@ jobs:
CLICKHOUSE_USER: clickhouse_test
CLICKHOUSE_PASSWORD: clickhouse_test
ALLOW_EMPTY_PASSWORD: no
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1

steps:
- uses: actions/checkout@v2
- name: Set up Clickhouse Settings
run: |
cat <<EOF > test_config.xml
run: |
cat <<EOF > test_user_config.xml
<clickhouse>
<users>
<clickhouse_test>
Expand All @@ -71,13 +73,20 @@ jobs:
</users>
</clickhouse>
EOF
docker cp ${{ github.workspace }}/test_config.xml clickhouse:/etc/clickhouse-server/users.d/users.xml
docker cp ${{ github.workspace }}/test_user_config.xml clickhouse:/etc/clickhouse-server/users.d/users.xml
docker exec clickhouse clickhouse-client --query "SYSTEM RELOAD USERS"
docker exec clickhouse clickhouse-client --query "CREATE USER clickhouse_read_only IDENTIFIED WITH plaintext_password BY 'clickhouse_test'"
docker exec clickhouse clickhouse-client --query "CREATE SETTINGS PROFILE clickhouse_settings SETTINGS flatten_nested=0, join_use_nulls=1, stop_refreshable_materialized_views_on_startup=1 TO clickhouse_test, clickhouse_read_only"
docker exec clickhouse clickhouse-client --query "CREATE SETTINGS PROFILE clickhouse_settings SETTINGS flatten_nested=0, join_use_nulls=1, stop_refreshable_materialized_views_on_startup=1, allow_materialized_view_with_bad_select=1, enable_join_runtime_filters=0 TO clickhouse_test, clickhouse_read_only"
docker exec clickhouse clickhouse-client --query "GRANT SELECT, SYSTEM VIEWS, dictGet ON *.* TO clickhouse_read_only"
docker exec clickhouse clickhouse-client --query "CREATE NAMED COLLECTION seqr_postgres_named_collection AS user='postgres', password='pgtest', host='postgres', port='5432'"
docker exec clickhouse clickhouse-client --query "SYSTEM RELOAD USERS"
cat <<EOF > test_config.xml
<clickhouse>
<user_files_path>/</user_files_path>
</clickhouse>
EOF
docker cp ${{ github.workspace }}/test_config.xml clickhouse:/etc/clickhouse-server/config.d/config.xml
docker restart clickhouse
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -94,6 +103,13 @@ jobs:
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
pip install -r requirements-dev.txt
- name: Wait for service restart
run: |
timeout 50s sh -c '
until curl --fail http://localhost:8123/ping; do
sleep 5
done
'
- name: Run coverage tests
run: |
export CLICKHOUSE_READER_USER=clickhouse_read_only
Expand Down
84 changes: 78 additions & 6 deletions .github/workflows/vlm-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ on:
paths:
- 'vlm/**'
- '.github/workflows/*vlm*.yaml'
- 'clickhouse_search/fixtures/clickhouse_search.json'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'vlm/**'
- '.github/workflows/*vlm*.yaml'
- 'clickhouse_search/fixtures/clickhouse_search.json'

jobs:
vlm_clickhouse:
runs-on: ubuntu-latest
container: python:3.11-slim-bullseye

services:
clickhouse:
image: bitnamilegacy/clickhouse:latest
image: gcr.io/seqr-project/seqr-clickhouse:26.3.9
ports:
- 8123:8123 # HTTP interface
- 9000:9000 # Native client interface
volumes:
- /var/tmp:/var/seqr/clickhouse-data
- /tmp:/in-memory-dir
options: >-
--health-cmd "clickhouse-client --query 'SELECT 1'"
--health-interval 10s
Expand All @@ -38,25 +43,92 @@ jobs:
CLICKHOUSE_USER: clickhouse_test_user
CLICKHOUSE_PASSWORD: clickhouse_test_password
ALLOW_EMPTY_PASSWORD: no
CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
postgres:
image: postgres
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: pgtest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
cache: 'pip'
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip wheel
pip install -r vlm/requirements.txt
pip install -r vlm/requirements-test.txt
- name: Set up Clickhouse Settings and Data
run: python3 vlm/setup_clickhouse_test_data.py clickhouse 8123 clickhouse_test_user clickhouse_test_password
- name: Set up Clickhouse Settings
run: |
cat <<EOF > test_user_config.xml
<clickhouse>
<users>
<clickhouse_test_user>
<named_collection_control>1</named_collection_control>
</clickhouse_test_user>
</users>
</clickhouse>
EOF
docker cp ${{ github.workspace }}/test_user_config.xml clickhouse:/etc/clickhouse-server/users.d/users.xml
docker exec clickhouse clickhouse-client --query "CREATE USER vlm_test_user IDENTIFIED WITH plaintext_password BY 'vlm_test_password'"
docker exec clickhouse clickhouse-client --query "SYSTEM RELOAD USERS"
docker exec clickhouse clickhouse-client --query "CREATE SETTINGS PROFILE clickhouse_settings SETTINGS flatten_nested=0, join_use_nulls=1, stop_refreshable_materialized_views_on_startup=1 TO vlm_test_user, clickhouse_test_user"
docker exec clickhouse clickhouse-client --query "CREATE NAMED COLLECTION seqr_postgres_named_collection AS user='postgres', password='pgtest', host='postgres', port='5432'"
docker exec clickhouse clickhouse-client --query "SYSTEM RELOAD USERS"
cat <<EOF > test_config.xml
<clickhouse>
<user_files_path>/</user_files_path>
</clickhouse>
EOF
docker cp ${{ github.workspace }}/test_config.xml clickhouse:/etc/clickhouse-server/config.d/config.xml
docker restart clickhouse
- name: Wait for service restart
run: |
timeout 50s sh -c '
until curl --fail http://localhost:8123/ping; do
sleep 5
done
'
- name: Set up Clickhouse Test Database
run: |
python3 -m venv .venv
source .venv/bin/activate
pip install -r vlm/requirements.txt
pip install -r vlm/requirements-test.txt
pip install pytest-django
pip install -r requirements.txt
pip install -r requirements-dev.txt
export CLICKHOUSE_WRITER_USER=clickhouse_test_user
export CLICKHOUSE_WRITER_PASSWORD=clickhouse_test_password
export CLICKHOUSE_SERVICE_HOSTNAME=localhost
export POSTGRES_SERVICE_HOSTNAME=localhost
python3 -m pytest --setup-only --create-db --reuse-db --ds=settings
- name: Set up Clickhouse test user
run: |
docker exec clickhouse clickhouse-client --query "GRANT SELECT ON test_seqr.\`GRCh37/SNV_INDEL/key_lookup\` TO vlm_test_user"
docker exec clickhouse clickhouse-client --query "GRANT SELECT ON test_seqr.\`GRCh38/SNV_INDEL/key_lookup\` TO vlm_test_user"
docker exec clickhouse clickhouse-client --query "GRANT dictGet ON test_seqr.\`GRCh37/SNV_INDEL/gt_stats_dict\` TO vlm_test_user"
docker exec clickhouse clickhouse-client --query "GRANT dictGet ON test_seqr.\`GRCh38/SNV_INDEL/gt_stats_dict\` TO vlm_test_user"
docker exec clickhouse clickhouse-client --query "SYSTEM RELOAD USERS"
- name: Run coverage tests
run: |
export SEQR_BASE_URL=https://test-seqr.org/
export NODE_ID=TestVLM
export CLICKHOUSE_SERVICE_HOSTNAME=clickhouse
export CLICKHOUSE_SERVICE_HOSTNAME=localhost
export CLICKHOUSE_SERVICE_PORT=8123
export CLICKHOUSE_VLM_USERNAME=vlm_test_user
export CLICKHOUSE_VLM_PASSWORD=vlm_test_password
export CLICKHOUSE_DATABASE=test_seqr
coverage run --source="./vlm" --omit="./vlm/__main__.py","./vlm/setup_clickhouse_test_data.py" -m pytest vlm/
coverage run --source="./vlm" --omit="./vlm/__main__.py","./vlm/conftest.py" -m pytest vlm/
coverage report -m --fail-under=95

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import OrderedDict
from django.core.management.base import BaseCommand, CommandError

from clickhouse_search.models.postgres_dicts import GeneIdDict
from panelapp.models import PanelAppAU, PanelAppUK
from reference_data.utils.gene_utils import get_genes_by_id_and_symbol
from reference_data.models import GeneInfo, TranscriptInfo, HumanPhenotypeOntology, RefseqTranscript, GeneConstraint, \
Expand Down Expand Up @@ -57,6 +58,8 @@ def handle(self, *args, **options):
data_model_name = GeneInfo.__name__
self._update_gencode(current_versions.get(data_model_name), options['gene_symbol_change_dir'])
self._track_success_updates(data_model_name, latest_version, current_versions, updated)
GeneIdDict.reload()


gene_ids_to_gene, gene_symbols_to_gene = get_genes_by_id_and_symbol() if to_update else (None, None)
for data_cls, latest_version in to_update.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def _mock_handler(_cls, **kwargs):


class NewDbUpdateAllReferenceDataTest(BaseUpdateAllReferenceDataTest):
databases = '__all__'
fixtures = ['users']

def test_empty_db_update_all_reference_data_command(self):
Expand Down Expand Up @@ -78,6 +79,7 @@ def test_empty_db_update_all_reference_data_command(self):

self.mock_slack.assert_not_called()
self.assert_json_logs(user=None, expected=[
('Reloading dictionary seqrdb_gene_ids', None),
('unable to update PrimateAI: Primate_AI failed', {
'severity': 'ERROR',
'@type': 'type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent',
Expand Down
3 changes: 3 additions & 0 deletions reference_data/management/tests/update_gencode_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

class UpdateGencodeTest(ReferenceDataCommandTestCase):

databases = '__all__'

def setUp(self):
super().setUp()

Expand Down Expand Up @@ -202,6 +204,7 @@ def test_update_gencode_latest_command(self):
('Loaded 3 RefseqTranscript records', None),
('Skipped 1 records with unrecognized or duplicated transcripts', None),
('Updated GeneInfo reference data from version "31" to version "39"', None),
('Reloading dictionary seqrdb_gene_ids', None),
('Done', None),
('Updated: GeneInfo', None),
])
Expand Down
10 changes: 9 additions & 1 deletion seqr/views/apis/family_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.db.models import Count, Max, Q, F
from django.db.models.fields.files import ImageFieldFile

from clickhouse_search.models.postgres_dicts import AffectedDict, SexDict, IndividualMetadataDict
from matchmaker.models import MatchmakerSubmission
from reference_data.models import Omim
from seqr.utils.gene_utils import get_genes_for_variant_display
Expand Down Expand Up @@ -210,6 +211,10 @@ def delete_families_handler(request, project_guid):
# delete families
Family.bulk_delete(request.user, project=project, guid__in=family_guids_to_delete)

AffectedDict.reload(request.user)
SexDict.reload(request.user)
IndividualMetadataDict.reload(request.user)

# send response
return create_json_response({
'individualsByGuid': {
Expand All @@ -230,9 +235,12 @@ def update_family_fields_handler(request, family_guid):

request_json = json.loads(request.body)
immutable_keys = [] if external_anvil_project_can_edit(family.project, request.user) else ['family_id']
updated_fields = set()
update_family_from_json(family, request_json, user=request.user, allow_unknown_keys=True, immutable_keys=[
'display_name',
] + immutable_keys)
] + immutable_keys, updated_fields=updated_fields)
if updated_fields.intersection({'post_discovery_omim_numbers', 'post_discovery_mondo_id', 'analysis_status'}):
IndividualMetadataDict.reload(request.user)

return create_json_response({
family.guid: _get_json_for_model(family, user=request.user, process_result=_set_display_name)
Expand Down
16 changes: 16 additions & 0 deletions seqr/views/apis/family_api_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,12 +456,19 @@ def test_update_success_story_types(self):
data=json.dumps({'successStoryTypes': ['O', 'D']}))
self.assertEqual(response.status_code, 403)

self.reset_logs()
self.login_analyst_user()
response = self.client.post(url, content_type='application/json',
data=json.dumps({'successStoryTypes': ['O', 'D']}))
self.assertEqual(response.status_code, 200)
response_json = response.json()
self.assertListEqual(response_json[FAMILY_GUID]['successStoryTypes'], ['O', 'D'])
self.assert_json_logs(self.analyst_user, [
('update Family F000001_1', {'dbUpdate': {
'dbEntity': 'Family', 'entityId': 'F000001_1', 'updateType': 'update', 'updateFields': ['success_story_types'],
}}),
(None, {'httpRequest': mock.ANY, 'requestBody': mock.ANY}),
])

self.check_no_analyst_no_access(url, get_response=lambda: self.client.post(
url, content_type='application/json', data=json.dumps({'successStoryTypes': []})))
Expand All @@ -471,6 +478,7 @@ def test_update_family_fields(self):
url = reverse(update_family_fields_handler, args=[FAMILY_GUID])
self.check_collaborator_login(url)

self.reset_logs()
body = {FAMILY_ID_FIELD: 'new_id', 'description': 'Updated description', 'analysis_status': 'C'}
response = self.client.post(url, content_type='application/json', data=json.dumps(body))
self.assertEqual(response.status_code, 200)
Expand All @@ -481,6 +489,14 @@ def test_update_family_fields(self):
self.assertEqual(response_json[FAMILY_GUID]['analysisStatus'], 'C')
self.assertEqual(response_json[FAMILY_GUID]['analysisStatusLastModifiedBy'], 'Test Collaborator User')
self.assertEqual(response_json[FAMILY_GUID]['analysisStatusLastModifiedDate'], '2020-01-01T00:00:00')
self.assert_json_logs(self.collaborator_user, [
('update Family F000001_1', {'dbUpdate': {
'dbEntity': 'Family', 'entityId': 'F000001_1', 'updateType': 'update',
'updateFields': ['analysis_status', 'analysis_status_last_modified_by', 'analysis_status_last_modified_date', 'description'],
}}),
('Reloading dictionary seqrdb_individual_metadata_dict', None),
(None, {'httpRequest': mock.ANY, 'requestBody': body}),
])

# Do not update audit fields if value does not change
self.login_manager()
Expand Down
8 changes: 8 additions & 0 deletions seqr/views/apis/individual_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.contrib.auth.models import User
from django.db.models import prefetch_related_objects

from clickhouse_search.models.postgres_dicts import IndividualMetadataDict, SexDict, AffectedDict
from reference_data.models import HumanPhenotypeOntology
from seqr.models import Individual, Family, CAN_VIEW
from seqr.utils.file_utils import file_iter
Expand Down Expand Up @@ -93,6 +94,7 @@ def update_individual_hpo_terms(request, individual_guid):
for key in feature_fields
}
update_individual_from_json(individual, update_json, user=request.user, allow_features_update=True)
IndividualMetadataDict.reload(request.user)

individual_json = {k: getattr(individual, _to_snake_case(k)) for k in feature_fields}
add_individual_hpo_details([individual_json])
Expand Down Expand Up @@ -218,6 +220,9 @@ def delete_individuals_handler(request, project_guid):

# delete the individuals
families_with_deleted_individuals = delete_individuals(project, individual_guids_to_delete, request.user)
AffectedDict.reload(request.user)
SexDict.reload(request.user)
IndividualMetadataDict.reload(request.user)

deleted_individuals_by_guid = {
individual_guid: None for individual_guid in individual_guids_to_delete
Expand Down Expand Up @@ -665,6 +670,9 @@ def save_individuals_metadata_table_handler(request, project_guid, upload_file_i
if record.get(ASSIGNED_ANALYST_COL):
family_assigned_analysts[record[ASSIGNED_ANALYST_COL]].append(individual.family.id)

if any(FEATURES_COL in record for record in json_records):
IndividualMetadataDict.reload(request.user)

response = {
'individualsByGuid': {
individual['individualGuid']: individual for individual in _get_json_for_individuals(
Expand Down
Loading
Loading