frequenz-floss / frequenz-client-dispatch-python

Dispatch API client for Python
https://frequenz-floss.github.io/frequenz-client-dispatch-python/
MIT License
0 stars 3 forks source link

Setting duration works randomly #89

Closed daniel-zullo-frequenz closed 2 months ago

daniel-zullo-frequenz commented 2 months ago

What happened?

Setting duration 99 works

dispatch-cli --url grpc://fz-0004.frequenz.io:50052 --key "********" create 174 peak-shaving BATTERY 23:00 99
Using API URL: grpc://fz-0004.frequenz.io:50052
Dispatch(id=125,
         type='peak-shaving',
         start_time=datetime.datetime(2024, 9, 23, 21, 0, tzinfo=datetime.timezone.utc),
         duration=datetime.timedelta(seconds=99),
         selector=[<ComponentCategory.BATTERY: 5>],
         active=True,
         dry_run=False,
         payload={},
         recurrence=RecurrenceRule(frequency=<Frequency.UNSPECIFIED: 0>,
                                   interval=0,
                                   end_criteria=None,
                                   byminutes=[],
                                   byhours=[],
                                   byweekdays=[],
                                   bymonthdays=[],
                                   bymonths=[]),
         create_time=datetime.datetime(2024, 9, 23, 20, 2, 26, 59430, tzinfo=datetime.timezone.utc),
         update_time=datetime.datetime(2024, 9, 23, 20, 2, 26, 59430, tzinfo=datetime.timezone.utc))
Dispatch created.

Setting duration 100 does NOT work

dispatch-cli --url grpc://fz-0004.frequenz.io:50052 --key "********" create 174 peak-shaving BATTERY 23:00 100
Using API URL: grpc://fz-0004.frequenz.io:50052
Traceback (most recent call last):
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/bin/dispatch-cli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/src/frequenz/client/dispatch/__main__.py", line 469, in main
    asyncio.run(cli.main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/lib/python3.12/site-packages/asyncclick/core.py", line 1120, in main
    rv = await self.invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/lib/python3.12/site-packages/asyncclick/core.py", line 1739, in invoke
    return await _process_result(await sub_ctx.command.invoke(sub_ctx))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/lib/python3.12/site-packages/asyncclick/core.py", line 1485, in invoke
    return await ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/lib/python3.12/site-packages/asyncclick/core.py", line 824, in invoke
    rv = await rv
         ^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/src/frequenz/client/dispatch/__main__.py", line 273, in create
    dispatch = await ctx.obj["client"].create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/src/frequenz/client/dispatch/_client.py", line 285, in create
    request.to_protobuf(), metadata=self._metadata
    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/src/frequenz/client/dispatch/_internal_types.py", line 118, in to_protobuf
    dispatch_data=DispatchData(
                  ^^^^^^^^^^^^^
ValueError: Value out of range: -75750

Setting duration 120 does NOT work either

dispatch-cli --url grpc://fz-0004.frequenz.io:50052 --key "********" create 174 peak-shaving BATTERY 23:00 120
Using API URL: grpc://fz-0004.frequenz.io:50052
Traceback (most recent call last):
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/bin/dispatch-cli", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/src/frequenz/client/dispatch/__main__.py", line 469, in main
    asyncio.run(cli.main())
  File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/lib/python3.12/site-packages/asyncclick/core.py", line 1120, in main
    rv = await self.invoke(ctx)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/lib/python3.12/site-packages/asyncclick/core.py", line 1739, in invoke
    return await _process_result(await sub_ctx.command.invoke(sub_ctx))
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/lib/python3.12/site-packages/asyncclick/core.py", line 1485, in invoke
    return await ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/.venv/lib/python3.12/site-packages/asyncclick/core.py", line 824, in invoke
    rv = await rv
         ^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/src/frequenz/client/dispatch/__main__.py", line 273, in create
    dispatch = await ctx.obj["client"].create(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/src/frequenz/client/dispatch/_client.py", line 285, in create
    request.to_protobuf(), metadata=self._metadata
    ^^^^^^^^^^^^^^^^^^^^^
  File "/home/daniz/projects/frequenz-client-dispatch-python/src/frequenz/client/dispatch/_internal_types.py", line 118, in to_protobuf
    dispatch_data=DispatchData(
                  ^^^^^^^^^^^^^
ValueError: Value out of range: -74559

Setting duration 180 works

dispatch-cli --url grpc://fz-0004.frequenz.io:50052 --key "********" create 174 peak-shaving BATTERY 23:00 180
Using API URL: grpc://fz-0004.frequenz.io:50052
Dispatch(id=126,
         type='peak-shaving',
         start_time=datetime.datetime(2024, 9, 23, 21, 0, tzinfo=datetime.timezone.utc),
         duration=datetime.timedelta(seconds=180),
         selector=[<ComponentCategory.BATTERY: 5>],
         active=True,
         dry_run=False,
         payload={},
         recurrence=RecurrenceRule(frequency=<Frequency.UNSPECIFIED: 0>,
                                   interval=0,
                                   end_criteria=None,
                                   byminutes=[],
                                   byhours=[],
                                   byweekdays=[],
                                   bymonthdays=[],
                                   bymonths=[]),
         create_time=datetime.datetime(2024, 9, 23, 20, 2, 42, 947917, tzinfo=datetime.timezone.utc),
         update_time=datetime.datetime(2024, 9, 23, 20, 2, 42, 947917, tzinfo=datetime.timezone.utc))
Dispatch created.

What did you expect instead?

All the dispatches are created

Affected version(s)

v0.6.0

Affected part(s)

I don't know (part:❓)

Extra information

No response

daniel-zullo-frequenz commented 2 months ago

Closing as it doesn't apply. The unit in the duration was missing. Documentation might need to be updated though