Skip to content

Commit 35c737e

Browse files
Merge pull request #719 from broadinstitute/mw/fix_v3_autoclass_warn
Show the GCS migration warning only once
2 parents 5341e3c + de8fabc commit 35c737e

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

gnomad_qc/v3/resources/annotations.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
RELEASES,
2020
VERSIONS,
2121
)
22+
from gnomad_qc.v3.resources.resource_utils import show_v3_migration_warning
2223

2324
SUBSETS = SUBSETS["v3"]
2425

@@ -36,12 +37,7 @@ def _annotations_root(version: str = CURRENT_VERSION) -> str:
3637
:param version: Version of annotation path to return
3738
:return: root path of the variant annotation files
3839
"""
39-
logging.warning(
40-
"Most objects in 'gs://gnomad/annotations' were moved to either "
41-
"'gs://gnomad-archive' or 'gs://gnomad-autoclass'. This function now returns "
42-
"'gs://gnomad-autoclass/annotations' paths, if no resource is found there, "
43-
"please check 'gs://gnomad-archive/annotations'."
44-
)
40+
show_v3_migration_warning("annotations")
4541
return f"gs://gnomad-autoclass/annotations/hail-0.2/ht/genomes_v{version}"
4642

4743

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Centralized migration warnings for v3 resources moved to new GCS locations."""
2+
3+
import functools
4+
import logging
5+
from typing import Literal
6+
7+
8+
@functools.lru_cache(maxsize=2)
9+
def show_v3_migration_warning(target: Literal["annotations", "sample_qc"]) -> None:
10+
"""
11+
Show GCS migration warning for v3 resources (only once per target per session).
12+
13+
:param target: Type of resource that was migrated ("annotations" or "sample_qc")
14+
"""
15+
logging.warning(
16+
f"Most objects in 'gs://gnomad/{target}' were moved to either "
17+
f"'gs://gnomad-archive' or 'gs://gnomad-autoclass'. This function now returns "
18+
f"'gs://gnomad-autoclass/{target}' paths, if no resource is found there, "
19+
f"please check 'gs://gnomad-archive/{target}'."
20+
)

gnomad_qc/v3/resources/sample_qc.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from gnomad.sample_qc.relatedness import get_relationship_expr
1212

1313
from gnomad_qc.v3.resources.constants import CURRENT_VERSION, VERSIONS
14+
from gnomad_qc.v3.resources.resource_utils import show_v3_migration_warning
1415

1516
########################################################################################
1617
# Note: Some of the resources in this file have been moved to gs://gnomad-archive,
@@ -27,12 +28,7 @@ def get_sample_qc_root(version: str = CURRENT_VERSION, mt: bool = False) -> str:
2728
:param mt: Whether path is for a MatrixTable, default is False
2829
:return: Root to sample QC path
2930
"""
30-
logging.warning(
31-
"Most objects in 'gs://gnomad/sample_qc' were moved to either "
32-
"'gs://gnomad-archive' or 'gs://gnomad-autoclass'. This function now returns "
33-
"'gs://gnomad-autoclass/sample_qc' paths, if no resource is found there, "
34-
"please check 'gs://gnomad-archive/sample_qc'."
35-
)
31+
show_v3_migration_warning("sample_qc")
3632
return f"gs://gnomad-autoclass/sample_qc/{'mt' if mt else 'ht'}/genomes_v{version}"
3733

3834

gnomad_qc/v5/data_ingestion/field_md_to_html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
final_sections = []
2828

2929

30-
elements = soup.find_all(["p", "table", "h1", "h2"])
30+
elements = list(soup.find_all(["p", "table", "h1", "h2"]))
3131

3232
paragraphs_before_first_table = []
3333
paragraphs_before_second_table = []

0 commit comments

Comments
 (0)