|
14 | 14 | from typing import Dict, Generator, List, Tuple, Union # noqa: F401 |
15 | 15 | import copy |
16 | 16 | import json |
| 17 | +import logging |
17 | 18 |
|
18 | 19 | from bson.objectid import ObjectId |
19 | 20 | from mypy_extensions import TypedDict |
|
27 | 28 | validate_input_metadata, |
28 | 29 | write_metadata_to_bq, |
29 | 30 | ) |
| 31 | + from monitor import setup_logger |
30 | 32 | except ImportError: |
31 | 33 | # Used when importing as external package, e.g. imports in single_cell_portal code |
32 | 34 | from .annotations import Annotations |
33 | 35 | 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 | +) |
34 | 43 |
|
35 | 44 |
|
36 | 45 | class CellMetadata(Annotations): |
@@ -141,16 +150,22 @@ def transform(self): |
141 | 150 | if not self.numeric_array_columns.get(annot_name) |
142 | 151 | else "group" |
143 | 152 | ) |
| 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 | + |
144 | 161 | yield AnnotationModel( |
145 | 162 | annot_header, |
146 | 163 | self.Model( |
147 | 164 | { |
148 | 165 | "name": annot_name, |
149 | 166 | "annotation_type": stored_mongo_annot_type, |
150 | 167 | # 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 [], |
154 | 169 | "study_file_id": self.study_file_id, |
155 | 170 | "study_id": self.study_id, |
156 | 171 | } |
|
0 commit comments