influxdb3-python icon indicating copy to clipboard operation
influxdb3-python copied to clipboard

feat: support env

Open NguyenHoangSon96 opened this issue 7 months ago • 5 comments
trafficstars

Closes Issue

Proposed Changes

  • Support creates InfluxDB client with environment variables with the same name as the Go client

Checklist

  • [x] CHANGELOG.md updated
  • [x] Rebased/mergeable
  • [x] A test has been added if appropriate
  • [x] Tests pass
  • [x] Commit messages are conventional
  • [x] Sign CLA (if not already signed)

NguyenHoangSon96 avatar Apr 16 '25 01:04 NguyenHoangSon96

Codecov Report

Attention: Patch coverage is 96.66667% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.84%. Comparing base (93129b0) to head (ec8813c). Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
influxdb_client_3/write_client/client/write_api.py 76.92% 3 Missing :warning:
influxdb_client_3/__init__.py 98.85% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #127      +/-   ##
==========================================
+ Coverage   61.92%   63.84%   +1.92%     
==========================================
  Files          33       33              
  Lines        2135     2246     +111     
==========================================
+ Hits         1322     1434     +112     
+ Misses        813      812       -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Apr 21 '25 03:04 codecov[bot]

I think config from environment variables was already supported (see method from_env_properties). What you should support is:

  • different set of environment variable names (same as in go -- https://github.com/InfluxCommunity/influxdb3-go/blob/main/influxdb3/client.go#L258-L267)
  • plus also keep it backward compatible, so it should work with both the old names and the new names

jansimonb avatar Apr 22 '25 09:04 jansimonb

I think config from environment variables was already supported (see method from_env_properties). What you should support is:

  • different set of environment variable names (same as in go -- https://github.com/InfluxCommunity/influxdb3-go/blob/main/influxdb3/client.go#L258-L267)
  • plus also keep it backward compatible, so it should work with both the old names and the new names

Hi Jan I don't get it from_env_properties supports names with v2 in its string My new function supports names like in golang "INFLUX_HOST" "INFLUX_TOKEN" "INFLUX_DATABASE" "INFLUX_ORG"

NguyenHoangSon96 avatar Apr 22 '25 09:04 NguyenHoangSon96

Hi @jansimonb I pushed the latest code. Please take a look when you have time I converted to draft because I'm not very confident with the fix 🙈 I have not added comments for new functions...

NguyenHoangSon96 avatar Apr 24 '25 10:04 NguyenHoangSon96

In from_env_properties (what we want to deprecate) there are 13 environment variables supported. In the new from_env we support 7 env variables. Does that mean that we are loosing some functionality? E.g. is it still possible to use the new from_env method but also configure connection_pool_maxsize?

Hi @jansimonb I have increased the number of parameters we support Please check again

NguyenHoangSon96 avatar Apr 29 '25 10:04 NguyenHoangSon96