influxdb-client-python icon indicating copy to clipboard operation
influxdb-client-python copied to clipboard

Creating tasks with import statements fail

Open anwu opened this issue 3 years ago • 1 comments

Steps to reproduce: List the minimal actions needed to reproduce the behavior.

  1. Calling InfluxDBClient.TasksApi.create_task() with an import statement does not work.
  2. Similarly, creating a task directly using the API endpoint /api/v2/tasks with an import statement after the option task variable.
curl http://localhost:8086/api/v2/tasks \
  --header "Content-type: application/json" \
  --header "Authorization: Token INFLUX_TOKEN" \
  --data-binary @- << EOF
    {
    "orgID": "INFLUX_ORG_ID",
    "description": "IoT Center 30d environment average.",
    "flux": "option task = {name: \"iot-center-task-1\", every: 30m}\
            import \"http\"\
            from(bucket: \"iot_center\")\
              |> range(start: -30d)\
              |> filter(fn: (r) => r._measurement == \"environment\")\
              |> aggregateWindow(every: 1h, fn: mean)"
    }
EOF

This will return an error saying that the import statement is invalid.

HTTP response body: {"code":"invalid","message":"invalid options; Err: loc 3:1-3:7: invalid statement @3:1-3:7: import: loc 3:1-3:7: invalid statement @3:1-3:7: import"}

Expected behavior: Expected the task to be created.

Actual behavior: HTTP response from the server saying that the "import" statement is invalid.

HOWEVER, when the import statements are placed BEFORE the "option task ..." declaration, the API call works. The API probably needs to be fixed. But I was told that to file a ticket here and that it will be fixed via the python client library.

Specifications:

  • Client Version: 1.31.1
  • InfluxDB Version: Influx Cloud
  • Platform: Ubuntu 20.04 on WSL

Additional Info: https://influxcommunity.slack.com/archives/CH8RV8PK5/p1659743604599309

anwu avatar Aug 10 '22 20:08 anwu

Hi @anwu,

thanks for using our client.

I have prepared a fixed version within #491. If you would like to use this fixed version before regular release, please install client via:

pip install git+https://github.com/influxdata/influxdb-client-python.git@fix_create_task_with_import

Regards

bednar avatar Aug 11 '22 05:08 bednar