Skip to content

Commit 84a07c7

Browse files
committed
Add requirements and tests
1 parent 5362fd1 commit 84a07c7

File tree

4 files changed

+142
-6
lines changed

4 files changed

+142
-6
lines changed

eland/etl.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import pandas as pd # type: ignore
2323
from elasticsearch import Elasticsearch
2424
from elasticsearch.helpers import parallel_bulk
25+
from pandas.core.config_init import is_terminal # type: ignore
2526
from pandas.io.parsers import _c_parser_defaults # type: ignore
26-
from tqdm.notebook import tqdm
27-
from pandas.core.config_init import is_terminal
27+
from tqdm.notebook import tqdm # type: ignore
2828

2929
from eland import DataFrame
3030
from eland.common import DEFAULT_CHUNK_SIZE, ensure_es_client
@@ -110,7 +110,7 @@ def pandas_to_eland(
110110
show_progressbar: Optional[bool], default 'None'
111111
* True : show a progress bar only if we detect Jupyter Notebook (for now)
112112
* False : don't show a progress bar
113-
* None : show a progress bar only if we detect Jupyter Notebook
113+
* None : show a progress bar only if we detect Jupyter Notebook
114114
115115
Returns
116116
-------

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ xgboost>=1
1010
nox
1111
lightgbm>=2.3.0
1212
pytest-cov
13+
tqdm

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
elasticsearch>=7.7
22
pandas>=1
33
matplotlib
4+
tqdm

tests/notebook/test_etl.ipynb

Lines changed: 137 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"name": "stdout",
4343
"output_type": "stream",
4444
"text": [
45-
"2020-10-28 22:01:46.397163: read 10000 rows\n",
46-
"2020-10-28 22:01:47.100938: read 13059 rows\n"
45+
"2020-10-28 16:20:43.614617: read 10000 rows\n",
46+
"2020-10-28 16:20:44.276337: read 13059 rows\n"
4747
]
4848
}
4949
],
@@ -80,7 +80,7 @@
8080
{
8181
"data": {
8282
"application/vnd.jupyter.widget-view+json": {
83-
"model_id": "3e3e6e7371be43aabd4f9a2bb62ed737",
83+
"model_id": "2743ed058a8b44919ad4908f9cac0e95",
8484
"version_major": 2,
8585
"version_minor": 0
8686
},
@@ -299,6 +299,140 @@
299299
"source": [
300300
"es.indices.delete(index='churn', ignore=[400, 404])"
301301
]
302+
},
303+
{
304+
"cell_type": "code",
305+
"execution_count": 8,
306+
"metadata": {},
307+
"outputs": [
308+
{
309+
"data": {
310+
"application/vnd.jupyter.widget-view+json": {
311+
"model_id": "97224e2219bf4d828739103324748fb2",
312+
"version_major": 2,
313+
"version_minor": 0
314+
},
315+
"text/plain": [
316+
"HBox(children=(HTML(value='Progress'), FloatProgress(value=0.0, max=13059.0), HTML(value='')))"
317+
]
318+
},
319+
"metadata": {},
320+
"output_type": "display_data"
321+
},
322+
{
323+
"name": "stdout",
324+
"output_type": "stream",
325+
"text": [
326+
"\n"
327+
]
328+
}
329+
],
330+
"source": [
331+
"# NBVAL_IGNORE_OUTPUT\n",
332+
"ed_df = ed.pandas_to_eland(pd_df, es_client='localhost', es_dest_index=\"pandas_flights\", show_progressbar=True)"
333+
]
334+
},
335+
{
336+
"cell_type": "code",
337+
"execution_count": 9,
338+
"metadata": {},
339+
"outputs": [
340+
{
341+
"data": {
342+
"text/plain": [
343+
"{'acknowledged': True}"
344+
]
345+
},
346+
"execution_count": 9,
347+
"metadata": {},
348+
"output_type": "execute_result"
349+
}
350+
],
351+
"source": [
352+
"es.indices.delete(index='pandas_flights', ignore=[400, 404])"
353+
]
354+
},
355+
{
356+
"cell_type": "code",
357+
"execution_count": 10,
358+
"metadata": {},
359+
"outputs": [],
360+
"source": [
361+
"# NBVAL_IGNORE_OUTPUT\n",
362+
"ed_df = ed.pandas_to_eland(pd_df, es_client='localhost', es_dest_index=\"pandas_flights\", show_progressbar=False)"
363+
]
364+
},
365+
{
366+
"cell_type": "code",
367+
"execution_count": 11,
368+
"metadata": {},
369+
"outputs": [
370+
{
371+
"data": {
372+
"text/plain": [
373+
"{'acknowledged': True}"
374+
]
375+
},
376+
"execution_count": 11,
377+
"metadata": {},
378+
"output_type": "execute_result"
379+
}
380+
],
381+
"source": [
382+
"es.indices.delete(index='pandas_flights', ignore=[400, 404])"
383+
]
384+
},
385+
{
386+
"cell_type": "code",
387+
"execution_count": 12,
388+
"metadata": {},
389+
"outputs": [
390+
{
391+
"data": {
392+
"application/vnd.jupyter.widget-view+json": {
393+
"model_id": "37529288403e4db7b3ae8d97c8666d2e",
394+
"version_major": 2,
395+
"version_minor": 0
396+
},
397+
"text/plain": [
398+
"HBox(children=(HTML(value='Progress'), FloatProgress(value=0.0, max=13059.0), HTML(value='')))"
399+
]
400+
},
401+
"metadata": {},
402+
"output_type": "display_data"
403+
},
404+
{
405+
"name": "stdout",
406+
"output_type": "stream",
407+
"text": [
408+
"\n"
409+
]
410+
}
411+
],
412+
"source": [
413+
"# NBVAL_IGNORE_OUTPUT\n",
414+
"ed_df = ed.pandas_to_eland(pd_df, es_client='localhost', es_dest_index=\"pandas_flights\", show_progressbar=None)"
415+
]
416+
},
417+
{
418+
"cell_type": "code",
419+
"execution_count": 13,
420+
"metadata": {},
421+
"outputs": [
422+
{
423+
"data": {
424+
"text/plain": [
425+
"{'acknowledged': True}"
426+
]
427+
},
428+
"execution_count": 13,
429+
"metadata": {},
430+
"output_type": "execute_result"
431+
}
432+
],
433+
"source": [
434+
"es.indices.delete(index='pandas_flights', ignore=[400, 404])"
435+
]
302436
}
303437
],
304438
"metadata": {

0 commit comments

Comments
 (0)