@@ -96,7 +96,9 @@ def from_env(**kwargs: Any) -> 'InfluxDBClient3':
9696 write_options = WriteOptions (write_type = WriteType .synchronous )
9797
9898 if os .getenv (INFLUX_GZIP_THRESHOLD ) is not None :
99- write_options .gzip_threshold = int (os .getenv (INFLUX_GZIP_THRESHOLD ))
99+ gzip_threshold = int (os .getenv (INFLUX_GZIP_THRESHOLD ))
100+ write_options .enable_gzip = True
101+ write_options .gzip_threshold = gzip_threshold
100102
101103 if os .getenv (INFLUX_PRECISION ) is not None :
102104 write_options .write_precision = os .getenv (INFLUX_PRECISION )
@@ -105,7 +107,6 @@ def from_env(**kwargs: Any) -> 'InfluxDBClient3':
105107
106108 if os .getenv (INFLUX_AUTH_SCHEME ) is not None :
107109 kwargs ['auth_scheme' ] = os .getenv (INFLUX_AUTH_SCHEME )
108-
109110 org = os .getenv (INFLUX_ORG , "default" )
110111
111112 return InfluxDBClient3 (
@@ -210,17 +211,18 @@ def __init__(
210211
211212 write_type = DefaultWriteOptions ['write_type' ]
212213 write_precision = DefaultWriteOptions ['write_precision' ]
213- gzip_threshold = DefaultWriteOptions [ 'gzip_threshold' ]
214+ gzip_threshold = None
214215 if isinstance (write_client_options , dict ) and write_client_options .get ('write_options' ) is not None :
215216 write_opts = write_client_options ['write_options' ]
216- write_type = getattr (write_opts , 'write_type' )
217- write_precision = getattr (write_opts , 'write_precision' )
217+ write_type = getattr (write_opts , 'write_type' , write_type )
218+ write_precision = getattr (write_opts , 'write_precision' , write_precision )
218219 gzip_threshold = getattr (write_opts , 'gzip_threshold' )
219220
220221 write_options = WriteOptions (
221222 write_type = write_type ,
222223 write_precision = write_precision ,
223224 gzip_threshold = gzip_threshold ,
225+ enable_gzip = kwargs .get ('enable_gzip' , False )
224226 )
225227
226228 self ._write_client_options = {
@@ -244,6 +246,8 @@ def __init__(
244246 url = f"{ scheme } ://{ hostname } :{ port } " ,
245247 token = self ._token ,
246248 org = self ._org ,
249+ enable_gzip = write_options .enable_gzip ,
250+ gzip_threshold = write_options .gzip_threshold ,
247251 ** kwargs )
248252
249253 self ._write_api = _WriteApi (influxdb_client = self ._client , ** self ._write_client_options )
0 commit comments