Skip to content

Commit

Permalink
add extra sampling options (#156)
Browse files Browse the repository at this point in the history
* add options to message model

* add options to settings context
  • Loading branch information
shouples authored Jan 6, 2023
1 parent 83690e2 commit 6f9edd6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/dx/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,17 @@ def handle_resample(
filters=raw_filters,
)

# allow temporary override of the display limit
with settings_context(DISPLAY_MAX_ROWS=sample_size):
# allow temporary override of the display
context_params = dict(
DISPLAY_MAX_ROWS=sample_size,
DISPLAY_MAX_COLUMNS=msg.num_columns,
COLUMN_SAMPLING_METHOD=msg.column_sampling_method,
ROW_SAMPLING_METHOD=msg.row_sampling_method,
)
with settings_context(**context_params):
logger.debug(
f"updating {msg.display_id=} with {min(sample_size, len(resampled_df))}-row resample"
f"updating {msg.display_id=} with {min(sample_size, len(resampled_df))}-row resample",
**context_params,
)
update_display(
resampled_df,
Expand Down
5 changes: 5 additions & 0 deletions src/dx/types/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from pydantic import BaseModel, Field
from typing_extensions import Annotated

from dx.types.main import DXSamplingMethod

logger = structlog.get_logger(__name__)


Expand Down Expand Up @@ -108,6 +110,9 @@ class DEXResampleMessage(BaseModel):
filters: List[Annotated[FilterTypes, Field(discriminator="type")]] = Field(default_factory=list)
limit: int = 50_000
cell_id: Optional[str] = None
num_columns: int = 100
column_sampling_method: DXSamplingMethod = DXSamplingMethod.outer
row_sampling_method: DXSamplingMethod = DXSamplingMethod.random


def clean_pandas_query_column(column: str) -> str:
Expand Down

0 comments on commit 6f9edd6

Please sign in to comment.