deepctl-cmd-usage 0.1.11__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepctl-cmd-usage
3
- Version: 0.1.11
3
+ Version: 0.2.0
4
4
  Summary: Usage command for deepctl
5
5
  Author-email: Deepgram <devrel@deepgram.com>
6
6
  Maintainer-email: Deepgram <devrel@deepgram.com>
@@ -14,11 +14,11 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
- Requires-Dist: deepctl-core>=0.1.10
17
+ Requires-Dist: deepctl-core>=0.2.16
18
18
  Requires-Dist: deepctl-shared-utils>=0.1.10
19
19
  Requires-Dist: click>=8.0.0
20
20
  Requires-Dist: rich>=13.0.0
21
- Requires-Dist: deepgram-sdk>=6.0.0rc2
21
+ Requires-Dist: deepgram-sdk<8,>=7.7.0
22
22
  Requires-Dist: pydantic>=2.0.0
23
23
 
24
24
  # deepctl-cmd-usage
@@ -58,7 +58,7 @@ pipx run deepctl --help
58
58
 
59
59
  - `click>=8.0.0`
60
60
  - `rich>=13.0.0`
61
- - `deepgram-sdk>=6.0.0rc2`
61
+ - `deepgram-sdk>=7.7.0,<8`
62
62
  - `pydantic>=2.0.0`
63
63
 
64
64
  ## License
@@ -35,7 +35,7 @@ pipx run deepctl --help
35
35
 
36
36
  - `click>=8.0.0`
37
37
  - `rich>=13.0.0`
38
- - `deepgram-sdk>=6.0.0rc2`
38
+ - `deepgram-sdk>=7.7.0,<8`
39
39
  - `pydantic>=2.0.0`
40
40
 
41
41
  ## License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "deepctl-cmd-usage"
7
- version = "0.1.11" # x-release-please-version
7
+ version = "0.2.0" # x-release-please-version
8
8
  description = "Usage command for deepctl"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -21,11 +21,11 @@ classifiers = [
21
21
  keywords = ["deepgram", "cli", "usage", "statistics"]
22
22
  requires-python = ">=3.10"
23
23
  dependencies = [
24
- "deepctl-core>=0.1.10",
24
+ "deepctl-core>=0.2.16",
25
25
  "deepctl-shared-utils>=0.1.10",
26
26
  "click>=8.0.0",
27
27
  "rich>=13.0.0",
28
- "deepgram-sdk>=6.0.0rc2",
28
+ "deepgram-sdk>=7.7.0,<8",
29
29
  "pydantic>=2.0.0",
30
30
  ]
31
31
 
@@ -9,6 +9,8 @@ from deepctl_core import (
9
9
  BaseResult,
10
10
  Config,
11
11
  DeepgramClient,
12
+ get_output_format,
13
+ get_status_console,
12
14
  )
13
15
  from deepctl_shared_utils import validate_date_format
14
16
  from rich.console import Console
@@ -16,6 +18,9 @@ from rich.console import Console
16
18
  from .models import UsageBucket, UsageResult
17
19
 
18
20
  console = Console()
21
+ # Status/progress chrome must never touch stdout, or it corrupts JSON/CSV
22
+ # output that callers pipe into jq and friends.
23
+ status_console = get_status_console()
19
24
 
20
25
 
21
26
  class UsageCommand(BaseCommand):
@@ -108,13 +113,13 @@ class UsageCommand(BaseCommand):
108
113
  # Determine date range
109
114
  if last_week:
110
115
  start_date, end_date = self._get_last_week_range()
111
- console.print("[blue]Fetching usage for last week...[/blue]")
116
+ status_console.print("[blue]Fetching usage for last week...[/blue]")
112
117
  elif last_month:
113
118
  start_date, end_date = self._get_last_month_range()
114
- console.print("[blue]Fetching usage for last month...[/blue]")
119
+ status_console.print("[blue]Fetching usage for last month...[/blue]")
115
120
  elif current_month:
116
121
  start_date, end_date = self._get_current_month_range()
117
- console.print("[blue]Fetching usage for current month...[/blue]")
122
+ status_console.print("[blue]Fetching usage for current month...[/blue]")
118
123
  elif start_date or end_date:
119
124
  # Validate custom date range
120
125
  if start_date and not validate_date_format(start_date):
@@ -128,7 +133,7 @@ class UsageCommand(BaseCommand):
128
133
  message=f"Invalid end date format: {end_date}",
129
134
  )
130
135
 
131
- console.print(
136
+ status_console.print(
132
137
  f"[blue]Fetching usage from "
133
138
  f"{start_date or 'beginning'} to "
134
139
  f"{end_date or 'now'}...[/blue]"
@@ -136,7 +141,7 @@ class UsageCommand(BaseCommand):
136
141
  else:
137
142
  # Default to current month
138
143
  start_date, end_date = self._get_current_month_range()
139
- console.print("[blue]Fetching usage for current month...[/blue]")
144
+ status_console.print("[blue]Fetching usage for current month...[/blue]")
140
145
 
141
146
  # Get usage data
142
147
  result = client.get_usage(project_id, start_date, end_date)
@@ -147,7 +152,7 @@ class UsageCommand(BaseCommand):
147
152
  )
148
153
 
149
154
  except Exception as e:
150
- console.print(f"[red]Error fetching usage:[/red] {e}")
155
+ status_console.print(f"[red]Error fetching usage:[/red] {e}")
151
156
  return BaseResult(status="error", message=str(e))
152
157
 
153
158
  def _get_last_week_range(self) -> tuple[str, str]:
@@ -233,44 +238,48 @@ class UsageCommand(BaseCommand):
233
238
  )
234
239
  )
235
240
 
236
- # Display summary
237
- console.print(
238
- f"\n[green]Usage Summary ({start_date} to {end_date}):[/green]"
239
- )
240
- console.print(f" Total Hours: {total_hours:,.1f}")
241
- console.print(f" Total Requests: {total_requests:,}")
242
-
243
- if total_tts_characters > 0:
244
- console.print(f" TTS Characters: {total_tts_characters:,}")
245
-
246
- if total_tokens_out > 0:
247
- console.print(f" Tokens Out: {total_tokens_out:,}")
248
-
249
- # Display detailed breakdown if not summary only
250
- if not summary_only and result_dict["results"]:
251
- console.print("\n[blue]Daily Breakdown:[/blue]")
252
- for item in result_dict["results"]:
253
- item_date = item.get("start", "Unknown")
254
- hours = item.get("total_hours", 0)
255
- requests = item.get("requests", 0)
256
-
257
- console.print(f"\n {item_date}:")
258
- console.print(f" Hours: {hours}")
259
- console.print(f" Requests: {requests}")
260
-
261
- if "tts" in item:
262
- console.print(
263
- f" TTS Characters: "
264
- f"{item['tts'].get('characters', 0):,}"
265
- )
266
- console.print(
267
- f" TTS Requests: {item['tts'].get('requests', 0):,}"
268
- )
269
-
270
- if "tokens" in item and item["tokens"].get("out", 0) > 0:
271
- console.print(
272
- f" Tokens Out: {item['tokens'].get('out', 0):,}"
273
- )
241
+ # Human summary/breakdown only in default mode. For
242
+ # json/yaml/csv the framework serialises the returned result
243
+ # to stdout, so printing here would corrupt that output.
244
+ if get_output_format() == "default":
245
+ console.print(
246
+ f"\n[green]Usage Summary ({start_date} to {end_date}):[/green]"
247
+ )
248
+ console.print(f" Total Hours: {total_hours:,.1f}")
249
+ console.print(f" Total Requests: {total_requests:,}")
250
+
251
+ if total_tts_characters > 0:
252
+ console.print(f" TTS Characters: {total_tts_characters:,}")
253
+
254
+ if total_tokens_out > 0:
255
+ console.print(f" Tokens Out: {total_tokens_out:,}")
256
+
257
+ # Display detailed breakdown if not summary only
258
+ if not summary_only and result_dict["results"]:
259
+ console.print("\n[blue]Daily Breakdown:[/blue]")
260
+ for item in result_dict["results"]:
261
+ item_date = item.get("start", "Unknown")
262
+ hours = item.get("total_hours", 0)
263
+ requests = item.get("requests", 0)
264
+
265
+ console.print(f"\n {item_date}:")
266
+ console.print(f" Hours: {hours}")
267
+ console.print(f" Requests: {requests}")
268
+
269
+ if "tts" in item:
270
+ console.print(
271
+ f" TTS Characters: "
272
+ f"{item['tts'].get('characters', 0):,}"
273
+ )
274
+ console.print(
275
+ f" TTS Requests: "
276
+ f"{item['tts'].get('requests', 0):,}"
277
+ )
278
+
279
+ if "tokens" in item and item["tokens"].get("out", 0) > 0:
280
+ console.print(
281
+ f" Tokens Out: {item['tokens'].get('out', 0):,}"
282
+ )
274
283
 
275
284
  project_id = result_dict.get("project_id", "")
276
285
  return UsageResult(
@@ -280,13 +289,13 @@ class UsageCommand(BaseCommand):
280
289
  total_hours=float(total_hours),
281
290
  )
282
291
  else:
283
- console.print(
292
+ status_console.print(
284
293
  "[yellow]No usage data found for the specified period[/yellow]"
285
294
  )
286
295
  return BaseResult(status="info", message="No usage data found")
287
296
 
288
297
  except Exception as e:
289
- console.print(f"[red]Error processing usage data:[/red] {e}")
298
+ status_console.print(f"[red]Error processing usage data:[/red] {e}")
290
299
  import traceback
291
300
 
292
301
  traceback.print_exc()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: deepctl-cmd-usage
3
- Version: 0.1.11
3
+ Version: 0.2.0
4
4
  Summary: Usage command for deepctl
5
5
  Author-email: Deepgram <devrel@deepgram.com>
6
6
  Maintainer-email: Deepgram <devrel@deepgram.com>
@@ -14,11 +14,11 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Requires-Python: >=3.10
16
16
  Description-Content-Type: text/markdown
17
- Requires-Dist: deepctl-core>=0.1.10
17
+ Requires-Dist: deepctl-core>=0.2.16
18
18
  Requires-Dist: deepctl-shared-utils>=0.1.10
19
19
  Requires-Dist: click>=8.0.0
20
20
  Requires-Dist: rich>=13.0.0
21
- Requires-Dist: deepgram-sdk>=6.0.0rc2
21
+ Requires-Dist: deepgram-sdk<8,>=7.7.0
22
22
  Requires-Dist: pydantic>=2.0.0
23
23
 
24
24
  # deepctl-cmd-usage
@@ -58,7 +58,7 @@ pipx run deepctl --help
58
58
 
59
59
  - `click>=8.0.0`
60
60
  - `rich>=13.0.0`
61
- - `deepgram-sdk>=6.0.0rc2`
61
+ - `deepgram-sdk>=7.7.0,<8`
62
62
  - `pydantic>=2.0.0`
63
63
 
64
64
  ## License
@@ -1,6 +1,6 @@
1
- deepctl-core>=0.1.10
1
+ deepctl-core>=0.2.16
2
2
  deepctl-shared-utils>=0.1.10
3
3
  click>=8.0.0
4
4
  rich>=13.0.0
5
- deepgram-sdk>=6.0.0rc2
5
+ deepgram-sdk<8,>=7.7.0
6
6
  pydantic>=2.0.0