Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous client ignoring write precision when set on Point #669

Open
lundaw opened this issue Sep 13, 2024 · 0 comments
Open

Asynchronous client ignoring write precision when set on Point #669

lundaw opened this issue Sep 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@lundaw
Copy link

lundaw commented Sep 13, 2024

Specifications

  • Client Version: 1.46.0
  • InfluxDB Version: 2.7.10

Code sample to reproduce problem

import asyncio

from influxdb_client import Point, WritePrecision
from influxdb_client.client.influxdb_client_async import InfluxDBClientAsync

_HOST = "http://localhost:8086"
_ORG = "primary"
_TOKEN = "token"
_BUCKET = "MY_BUCKET"
_TIMESTAMP = 1725588000000 # milliseconds, september 6th

async def main() -> None:
  p = Point("debug").field("myval", 42).time(_TIMESTAMP, WritePrecision.MS)

  client = InfluxDBClientAsync(url=_HOST, token=_TOKEN, org=_ORG)
  write_api = client.write_api()
  await write_api.write(bucket=_BUCKET, record=p)
  await client.close()

if __name__ == "__main__":
  asyncio.run(main())

Expected behavior

The write with InfluxDBClientAsync to work the same as InfluxDBClient does with Point defined write precision.

Actual behavior

The InfluxDBClientAsync does not respect the Point write precision, instead defaults to and uses DEFAULT_WRITE_PRECISION.

Additional info

If the write precision is explicitly stated in the write_api.write call, it is handled correctly. Also the docs for the function states that Point data takes precedence which does not happen.

Looking into the calls, I noticed that even though the docstring says that, the self._serialize call in the WriteApiAsync.write has the precision_from_point arguments is set explicitly false. The self._serialize call does the extraction right, but the body is built incorrectly because it only uses the write_precision of the function.

@lundaw lundaw added the bug Something isn't working label Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants