Skip to content

Commit 0e77df4

Browse files
committed
influxdb: skip DataFrameClient with INFLUXDB_NO_DATAFRAME_CLIENT
Since the DataFrameClient import is very expensive (imports pandas, which brings in a lot of modules), provide an env var "INFLUXDB_NO_DATAFRAME_CLIENT" that can be used to skip loading it when just the simple InfluxDBClient is needed.
1 parent 9909a9f commit 0e77df4

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ Examples
9494

9595
Here's a basic example (for more see the examples directory)::
9696

97-
$ python
97+
# Since the DataFrame client is slow to import, if you only need InfluxDBClient,
98+
# use INFLUXDB_NO_DATAFRAME_CLIENT.
99+
$ INFLUXDB_NO_DATAFRAME_CLIENT=1 python
98100

99101
>>> from influxdb import InfluxDBClient
100102

docs/source/api-documentation.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ To connect to a InfluxDB, you must create a
1010
connects to InfluxDB on ``localhost`` with the default
1111
ports. The below instantiation statements are all equivalent::
1212

13+
# Set INFLUXDB_NO_DATAFRAME_CLIENT to save import time for InfluxDBClient
14+
import os
15+
os.environ[ "INFLUXDB_NO_DATAFRAME_CLIENT" ] = "1"
1316
from influxdb import InfluxDBClient
1417

1518
# using Http

examples/tutorial.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import argparse
55

6+
import os
7+
os.environ[ "INFLUXDB_NO_DATAFRAME_CLIENT" ] = "1"
68
from influxdb import InfluxDBClient
79

810

influxdb/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@
77
from __future__ import unicode_literals
88

99
from .client import InfluxDBClient
10-
from .dataframe_client import DataFrameClient
1110
from .helper import SeriesHelper
1211

12+
import os
13+
14+
_DATAFRAME_CLIENT = "INFLUXDB_NO_DATAFRAME_CLIENT" not in os.environ
15+
if _DATAFRAME_CLIENT:
16+
from .dataframe_client import DataFrameClient
17+
1318

1419
__all__ = [
1520
'InfluxDBClient',
16-
'DataFrameClient',
1721
'SeriesHelper',
1822
]
19-
23+
if _DATAFRAME_CLIENT:
24+
__all__.append( 'DataFrameClient' )
2025

2126
__version__ = '5.0.0'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy