Skip to content

Commit 37136b5

Browse files
authored
Merge pull request #222 from broadinstitute/development
Release 1.12.3
2 parents 391f12a + fb8cc0a commit 37136b5

File tree

5 files changed

+303
-4
lines changed

5 files changed

+303
-4
lines changed

ingest/cell_metadata.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from typing import Dict, Generator, List, Tuple, Union # noqa: F401
1515
import copy
1616
import json
17+
import logging
1718

1819
from bson.objectid import ObjectId
1920
from mypy_extensions import TypedDict
@@ -27,10 +28,18 @@
2728
validate_input_metadata,
2829
write_metadata_to_bq,
2930
)
31+
from monitor import setup_logger
3032
except ImportError:
3133
# Used when importing as external package, e.g. imports in single_cell_portal code
3234
from .annotations import Annotations
3335
from .ingest_files import DataArray, IngestFiles
36+
from ..monitor import setup_logger
37+
38+
dev_logger = setup_logger(__name__, "log.txt", format="support_configs")
39+
40+
user_logger = setup_logger(
41+
__name__ + ".user_logger", "user_log.txt", level=logging.ERROR
42+
)
3443

3544

3645
class CellMetadata(Annotations):
@@ -141,16 +150,22 @@ def transform(self):
141150
if not self.numeric_array_columns.get(annot_name)
142151
else "group"
143152
)
153+
154+
group = True if annot_type == "group" else False
155+
# should not store annotations with >200 unique values for viz
156+
# annot_header is the column of data, which includes name and type
157+
# large is any annotation with more than 200 + 2 unique values
158+
unique_values = list(self.file[annot_header].unique())
159+
large = True if len(unique_values) > 202 else False
160+
144161
yield AnnotationModel(
145162
annot_header,
146163
self.Model(
147164
{
148165
"name": annot_name,
149166
"annotation_type": stored_mongo_annot_type,
150167
# unique values from "group" type annotations else []
151-
"values": list(self.file[annot_header].unique())
152-
if annot_type == "group"
153-
else [],
168+
"values": unique_values if (group and not large) else [],
154169
"study_file_id": self.study_file_id,
155170
"study_id": self.study_id,
156171
}

ingest/expression_files/dense_ingestor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ def filter_expression_scores(scores: List, cells: List):
187187
):
188188
valid_expression_scores.append(expression_score)
189189
associated_cells.append(cells[idx])
190+
except ValueError as err:
191+
raise ValueError(f"Expected numeric expression score - {err}")
190192
except Exception:
191193
raise ValueError("Score '{expression_score}' is not valid")
192194
return valid_expression_scores, associated_cells

ingest/validation/validate_metadata.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,10 @@ def report_issues(metadata):
10311031
is_valid = True
10321032
except re.error:
10331033
pass
1034-
issue_msg = f"{issue_text} [ Error count: {len(cells)} ]"
1034+
if issue_type == "error":
1035+
issue_msg = f"{issue_text} [ Error count: {len(cells)} ]"
1036+
elif issue_type == "warn":
1037+
issue_msg = f"{issue_text} [ Warn count: {len(cells)} ]"
10351038
record_issue(issue_type, issue_msg)
10361039
else:
10371040
record_issue(issue_type, issue_text)

0 commit comments

Comments
 (0)