From ecbabcc41efc644f450700943bf450b07822fbae Mon Sep 17 00:00:00 2001 From: doyle Date: Mon, 14 Sep 2020 12:25:30 -0700 Subject: [PATCH 1/6] Allow skipping DataFrameClient import Importing the DataFrameClient can take quite a while, especially when the source files aren't yet loaded into the page cache. This patch adds an environment variable, INFLUXDB_NO_DATAFRAME_CLIENT, to allow users of this package to skip this import in cases where they don't need it. --- docs/source/api-documentation.rst | 4 ++++ examples/tutorial.py | 2 ++ influxdb/__init__.py | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/source/api-documentation.rst b/docs/source/api-documentation.rst index 35fdb291..49869b65 100644 --- a/docs/source/api-documentation.rst +++ b/docs/source/api-documentation.rst @@ -10,6 +10,10 @@ To connect to a InfluxDB, you must create a connects to InfluxDB on ``localhost`` with the default ports. The below instantiation statements are all equivalent:: + # Set INFLUXDB_NO_DATAFRAME_CLIENT to skip the expensive DataFrameClient + # import in cases where you only need the basic InfluxDBClient. + os.environ["INFLUXDB_NO_DATAFRAME_CLIENT"] = "1" + from influxdb import InfluxDBClient # using Http diff --git a/examples/tutorial.py b/examples/tutorial.py index 12cd49c1..dcd20c8d 100644 --- a/examples/tutorial.py +++ b/examples/tutorial.py @@ -3,6 +3,8 @@ import argparse +import os +os.environ["INFLUXDB_NO_DATAFRAME_CLIENT"] = "1" from influxdb import InfluxDBClient diff --git a/influxdb/__init__.py b/influxdb/__init__.py index 56f2f619..fc7fc735 100644 --- a/influxdb/__init__.py +++ b/influxdb/__init__.py @@ -6,16 +6,20 @@ from __future__ import print_function from __future__ import unicode_literals +import os + from .client import InfluxDBClient -from .dataframe_client import DataFrameClient from .helper import SeriesHelper __all__ = [ 'InfluxDBClient', - 'DataFrameClient', 'SeriesHelper', ] +if "INFLUXDB_NO_DATAFRAME_CLIENT" not in os.environ: + from .dataframe_client import DataFrameClient + __all__.append( "DataFrameClient" ) + __version__ = '5.3.0' From f0237d288f2a27802336b072d3911044504aba6c Mon Sep 17 00:00:00 2001 From: doyle Date: Mon, 14 Sep 2020 12:25:30 -0700 Subject: [PATCH 2/6] Allow skipping DataFrameClient import Importing the DataFrameClient can take quite a while, especially when the source files aren't yet loaded into the page cache. This patch adds an environment variable, INFLUXDB_NO_DATAFRAME_CLIENT, to allow users of this package to skip this import in cases where they don't need it. --- influxdb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/__init__.py b/influxdb/__init__.py index fc7fc735..0908c80b 100644 --- a/influxdb/__init__.py +++ b/influxdb/__init__.py @@ -17,7 +17,7 @@ 'SeriesHelper', ] -if "INFLUXDB_NO_DATAFRAME_CLIENT" not in os.environ: +if os.environ.get("INFLUXDB_NO_DATAFRAME_CLIENT", "0").lower() not in ("0", "false"): from .dataframe_client import DataFrameClient __all__.append( "DataFrameClient" ) From a683fff57ace7d6de0e1e5d48b4092b57c6033e6 Mon Sep 17 00:00:00 2001 From: doyle Date: Mon, 14 Sep 2020 12:25:30 -0700 Subject: [PATCH 3/6] Allow skipping DataFrameClient import Importing the DataFrameClient can take quite a while, especially when the source files aren't yet loaded into the page cache. This patch adds an environment variable, INFLUXDB_NO_DATAFRAME_CLIENT, to allow users of this package to skip this import in cases where they don't need it. --- influxdb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/__init__.py b/influxdb/__init__.py index 0908c80b..90d947b7 100644 --- a/influxdb/__init__.py +++ b/influxdb/__init__.py @@ -17,7 +17,7 @@ 'SeriesHelper', ] -if os.environ.get("INFLUXDB_NO_DATAFRAME_CLIENT", "0").lower() not in ("0", "false"): +if os.environ.get("INFLUXDB_NO_DATAFRAME_CLIENT", "0").lower() not in ("1", "true"): from .dataframe_client import DataFrameClient __all__.append( "DataFrameClient" ) From e48663c089129ad3f07948940ad4db9164931308 Mon Sep 17 00:00:00 2001 From: Jonathan Doyle Date: Tue, 29 Sep 2020 11:13:58 -0700 Subject: [PATCH 4/6] Fix flake regressions --- influxdb/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/influxdb/__init__.py b/influxdb/__init__.py index 90d947b7..7f68ccee 100644 --- a/influxdb/__init__.py +++ b/influxdb/__init__.py @@ -17,9 +17,10 @@ 'SeriesHelper', ] -if os.environ.get("INFLUXDB_NO_DATAFRAME_CLIENT", "0").lower() not in ("1", "true"): - from .dataframe_client import DataFrameClient - __all__.append( "DataFrameClient" ) +NO_DATAFRAME_CLIENT = os.environ.get("INFLUXDB_NO_DATAFRAME_CLIENT", "0") +if NO_DATAFRAME_CLIENT.lower() not in ("1", "true"): + from .dataframe_client import DataFrameClient # noqa: F401 unused import + __all__.append("DataFrameClient") __version__ = '5.3.0' From a4ae5bdb021e0ceefbdcf49c9e36b56c9c394d83 Mon Sep 17 00:00:00 2001 From: Jonathan Doyle Date: Tue, 29 Sep 2020 11:56:55 -0700 Subject: [PATCH 5/6] Fix mismatched indent --- influxdb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/__init__.py b/influxdb/__init__.py index 7f68ccee..32471c2e 100644 --- a/influxdb/__init__.py +++ b/influxdb/__init__.py @@ -20,7 +20,7 @@ NO_DATAFRAME_CLIENT = os.environ.get("INFLUXDB_NO_DATAFRAME_CLIENT", "0") if NO_DATAFRAME_CLIENT.lower() not in ("1", "true"): from .dataframe_client import DataFrameClient # noqa: F401 unused import - __all__.append("DataFrameClient") + __all__.append("DataFrameClient") __version__ = '5.3.0' From 59a1d602dd4f62e4fe679e84adec29725ed3b77a Mon Sep 17 00:00:00 2001 From: Jonathan Doyle Date: Tue, 29 Sep 2020 14:00:17 -0700 Subject: [PATCH 6/6] Add extra space before inline comment --- influxdb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb/__init__.py b/influxdb/__init__.py index 32471c2e..6cd02f48 100644 --- a/influxdb/__init__.py +++ b/influxdb/__init__.py @@ -19,7 +19,7 @@ NO_DATAFRAME_CLIENT = os.environ.get("INFLUXDB_NO_DATAFRAME_CLIENT", "0") if NO_DATAFRAME_CLIENT.lower() not in ("1", "true"): - from .dataframe_client import DataFrameClient # noqa: F401 unused import + from .dataframe_client import DataFrameClient # noqa: F401 unused import __all__.append("DataFrameClient")