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

Fix duration in cli.create #86

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/frequenz/client/dispatch/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ async def cli(ctx: click.Context, url: str, key: str) -> None:
if ctx.obj is None:
ctx.obj = {}

click.echo(f"Using API URL: {url}", err=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor suggestion for the future: it might make sense to have some sort of --verbose or --debug flag to enable this, it seems a bit too verbose for the default case. You can even use the logging system to implement this.


ctx.obj["client"] = Client(
server_url=url,
key=key,
Expand Down Expand Up @@ -264,6 +266,10 @@ async def create(
# Remove keys with `None` value
kwargs = {k: v for k, v in kwargs.items() if v is not None}

# Required for client.create
if not kwargs.get("duration"):
kwargs["duration"] = None

dispatch = await ctx.obj["client"].create(
recurrence=parse_recurrence(kwargs),
**kwargs,
Expand Down
Loading