Skip to content

Commit 892446a

Browse files
authored
Merge pull request #51 from spectriclabs/dev
Constrain ellipses to a configurable level
2 parents cc7d78e + 4528626 commit 892446a

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

elastic_datashader/config.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Config:
2121
datashader_headers: Dict[Any, Any]
2222
elastic_hosts: str
2323
ellipse_render_mode: str
24+
ellipse_render_min_zoom: int
2425
hostname: str
2526
log_level: int
2627
max_batch: int
@@ -93,14 +94,15 @@ def config_from_env(env) -> Config:
9394
datashader_headers=load_datashader_headers(env.get("DATASHADER_HEADER_FILE", "headers.yaml")),
9495
elastic_hosts=env.get("DATASHADER_ELASTIC", "http://localhost:9200"),
9596
ellipse_render_mode=env.get("DATASHADER_ELLIPSE_RENDER_MODE", "matrix"),
97+
ellipse_render_min_zoom=env.get("DATASHADER_ELLIPSE_RENDER_MIN_ZOOM", 8),
9698
hostname=getfqdn(),
9799
log_level=get_log_level(env.get("DATASHADER_LOG_LEVEL", None)),
98100
max_batch=int(env.get("DATASHADER_MAX_BATCH", 10_000)),
99101
max_bins=int(env.get("DATASHADER_MAX_BINS", 10_000)),
100102
max_ellipses_per_tile=int(env.get("DATASHADER_MAX_ELLIPSES_PER_TILE", 100_000)),
101103
max_legend_items_per_tile=int(env.get("MAX_LEGEND_ITEMS_PER_TILE", 20)),
102104
num_ellipse_points=int(env.get("DATASHADER_NUM_ELLIPSE_POINTS", 100)),
103-
query_timeout_seconds=int(env.get("DATASHADER_QUERY_TIMEOUT", 0)),
105+
query_timeout_seconds=int(env.get("DATASHADER_QUERY_TIMEOUT", 900)),
104106
render_timeout=timedelta(seconds=int(env.get("DATASHADER_RENDER_TIMEOUT", 30))),
105107
tms_key=env.get("DATASHADER_TMS_KEY", None),
106108
use_scroll=true_if_none(env.get("DATASHADER_USE_SCROLL", None)),

elastic_datashader/elastic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def get_search_base(
197197
# Connect to Elasticsearch
198198
es = Elasticsearch(
199199
hosts_url_to_nodeconfig(elastic_hosts),
200-
timeout=900,
200+
timeout=config.query_timeout_seconds,
201201
headers=get_es_headers(headers, user, x_opaque_id),
202202
)
203203

elastic_datashader/tilegen.py

+3
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,9 @@ def generate_nonaggregated_tile(
637637
metrics = {"over_max": False}
638638

639639
if render_mode == "ellipses":
640+
if z < config.ellipse_render_min_zoom:
641+
img = gen_overlay(gen_empty(tile_width_px, tile_height_px), color=(128, 128, 128, 128))
642+
return img, metrics
640643
field_names = get_ellipse_field_names(params)
641644
count_s = count_s.source(includes=populated_field_names(field_names))
642645
df = pd.DataFrame.from_dict(

tests/test_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_config_defaults():
2020
assert cfg.max_batch == 10000
2121
assert cfg.max_ellipses_per_tile == 100000
2222
assert cfg.allowlist_headers is None
23-
assert cfg.query_timeout_seconds == 0
23+
assert cfg.query_timeout_seconds == 900
2424
assert cfg.hostname == socket.getfqdn()
2525

2626

0 commit comments

Comments
 (0)