cometx 3.6.7__tar.gz → 3.6.9__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.
Files changed (60) hide show
  1. {cometx-3.6.7 → cometx-3.6.9}/PKG-INFO +44 -25
  2. {cometx-3.6.7 → cometx-3.6.9}/README.md +43 -24
  3. {cometx-3.6.7 → cometx-3.6.9}/cometx/_version.py +1 -1
  4. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/admin.py +52 -44
  5. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/admin_growth_render.py +134 -148
  6. cometx-3.6.9/cometx/cli/admin_growth_report.py +1228 -0
  7. cometx-3.6.9/cometx/cli/admin_growth_users.py +790 -0
  8. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/migrate_users.py +83 -21
  9. {cometx-3.6.7 → cometx-3.6.9}/cometx/utils.py +179 -0
  10. cometx-3.6.9/cometx/views.py +877 -0
  11. {cometx-3.6.7 → cometx-3.6.9}/cometx.egg-info/PKG-INFO +44 -25
  12. {cometx-3.6.7 → cometx-3.6.9}/cometx.egg-info/SOURCES.txt +2 -0
  13. cometx-3.6.7/cometx/cli/admin_growth_report.py +0 -1294
  14. {cometx-3.6.7 → cometx-3.6.9}/LICENSE +0 -0
  15. {cometx-3.6.7 → cometx-3.6.9}/cometx/__init__.py +0 -0
  16. {cometx-3.6.7 → cometx-3.6.9}/cometx/_typing.py +0 -0
  17. {cometx-3.6.7 → cometx-3.6.9}/cometx/_ui.py +0 -0
  18. {cometx-3.6.7 → cometx-3.6.9}/cometx/api.py +0 -0
  19. {cometx-3.6.7 → cometx-3.6.9}/cometx/audio.py +0 -0
  20. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/__init__.py +0 -0
  21. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/admin_app.py +0 -0
  22. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/admin_gpu_app.py +0 -0
  23. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/admin_gpu_report.py +0 -0
  24. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/admin_optimizer_report.py +0 -0
  25. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/admin_usage_report.py +0 -0
  26. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/admin_utils.py +0 -0
  27. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/config.py +0 -0
  28. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/copy.py +0 -0
  29. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/copy_utils.py +0 -0
  30. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/count.py +0 -0
  31. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/delete_assets.py +0 -0
  32. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/download.py +0 -0
  33. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/list_command.py +0 -0
  34. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/log.py +0 -0
  35. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/rename_duplicates.py +0 -0
  36. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/reproduce.py +0 -0
  37. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/smoke_test.py +0 -0
  38. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/update.py +0 -0
  39. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/upload_optimizer_experiments.py +0 -0
  40. {cometx-3.6.7 → cometx-3.6.9}/cometx/cli/utils.py +0 -0
  41. {cometx-3.6.7 → cometx-3.6.9}/cometx/framework/__init__.py +0 -0
  42. {cometx-3.6.7 → cometx-3.6.9}/cometx/framework/comet/__init__.py +0 -0
  43. {cometx-3.6.7 → cometx-3.6.9}/cometx/framework/comet/download_manager.py +0 -0
  44. {cometx-3.6.7 → cometx-3.6.9}/cometx/framework/neptune.py +0 -0
  45. {cometx-3.6.7 → cometx-3.6.9}/cometx/framework/wandb.py +0 -0
  46. {cometx-3.6.7 → cometx-3.6.9}/cometx/generate_utils.py +0 -0
  47. {cometx-3.6.7 → cometx-3.6.9}/cometx/magics.py +0 -0
  48. {cometx-3.6.7 → cometx-3.6.9}/cometx/optimizer.py +0 -0
  49. {cometx-3.6.7 → cometx-3.6.9}/cometx/panel_utils.py +0 -0
  50. {cometx-3.6.7 → cometx-3.6.9}/cometx/tools/__init__.py +0 -0
  51. {cometx-3.6.7 → cometx-3.6.9}/cometx/tools/dataset.py +0 -0
  52. {cometx-3.6.7 → cometx-3.6.9}/cometx/tools/pointcloud.py +0 -0
  53. {cometx-3.6.7 → cometx-3.6.9}/cometx.egg-info/dependency_links.txt +0 -0
  54. {cometx-3.6.7 → cometx-3.6.9}/cometx.egg-info/entry_points.txt +0 -0
  55. {cometx-3.6.7 → cometx-3.6.9}/cometx.egg-info/requires.txt +0 -0
  56. {cometx-3.6.7 → cometx-3.6.9}/cometx.egg-info/top_level.txt +0 -0
  57. {cometx-3.6.7 → cometx-3.6.9}/pyproject.toml +0 -0
  58. {cometx-3.6.7 → cometx-3.6.9}/setup.cfg +0 -0
  59. {cometx-3.6.7 → cometx-3.6.9}/setup.py +0 -0
  60. {cometx-3.6.7 → cometx-3.6.9}/tests/testlib.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cometx
3
- Version: 3.6.7
3
+ Version: 3.6.9
4
4
  Summary: Python tools for Comet
5
5
  Home-page: https://github.com/comet-ml/cometx/
6
6
  Author: cometx development team
@@ -636,51 +636,70 @@ cometx admin usage-report --app
636
636
 
637
637
  #### growth-report
638
638
 
639
- Generate a cross-platform use-case growth & adoption report (Opik projects, EM projects,
640
- MPM monitored models) as a single self-contained HTML page. Distinct from `usage-report`
641
- (experiment-count PDF): `growth-report` tracks *how many use cases exist and how fast
642
- they're being created*, per workspace/department, across all three products.
639
+ Generate an organization growth & adoption report as a single self-contained HTML
640
+ page, built entirely from the **admin chargeback report**. Distinct from
641
+ `usage-report` (experiment-count PDF): `growth-report` gives an org-wide view of
642
+ workspaces, users, and platform adoption, per workspace/department.
643
+
644
+ **Requires an admin API key** — the report is derived entirely from the admin
645
+ chargeback endpoint, and with a non-admin key the command errors out (non-zero
646
+ exit).
643
647
 
644
648
  ```
645
649
  cometx admin growth-report [WORKSPACE ...]
646
650
  ```
647
651
 
648
652
  **Arguments:**
649
- * `WORKSPACE` (optional, zero or more) - Workspaces to include. If omitted, all workspaces visible to the current API key are used (via `get_workspaces()`).
653
+ * `WORKSPACE` (optional, zero or more) - Workspaces to scope the report to. If omitted, the report is org-wide.
650
654
 
651
655
  **Options:**
652
- * `--units {month,week,day,hour}` - Chart bucket granularity (default: month). Charts always render **all-time** history at this granularity; this is unrelated to `--window` below.
653
- * `--window WINDOW` - Relative analysis window for the KPIs, e.g. `7d`, `14d`, `30d`, `90d`, `2w`, `6m`, `1y` (default: `7d`). `d`=days, `w`=weeks (×7d), `m`=months (approximated as 30 days), `y`=years (approximated as 365 days) — the approximation is intentional, since the window only needs an "installed base before window" cutoff, not calendar-exact arithmetic.
654
- * `--platforms PLATFORMS` - Comma-separated list of platforms to include (default: `em,opik,mpm`). Any of `em`, `opik`, `mpm`.
656
+ * `--units {month,week,day,hour}` - Chart bucket granularity (default: month). Charts render all-time history at this granularity; unrelated to `--window` below.
657
+ * `--window WINDOW` - Relative analysis window for the growth KPIs, e.g. `7d`, `14d`, `30d`, `90d`, `2w`, `6m`, `1y` (default: `7d`). `d`=days, `w`=weeks (×7d), `m`=months (≈30 days), `y`=years (≈365 days).
655
658
  * `--output PATH` - Output HTML file path (default: `growth_report.html`).
656
- * `--limit N` - Limit the number of workspaces processed (useful for a fast smoke-test run).
659
+ * `--active-window WINDOW` - Activity window for the users layer, e.g. `30d`/`60d` (default: `60d`). A user is *active* when their last-used timestamp falls within this window.
660
+ * `--leaderboard-top-n N` - Top/bottom N size for the leaderboards section (default: `5`).
661
+ * `--exclude-personal` - Drop workspaces whose name matches `--personal-pattern` from the chargeback data (default: off; no effect without `--personal-pattern`).
662
+ * `--personal-pattern REGEX` - Regex used with `--exclude-personal` to identify personal-workspace names to drop, e.g. `'^user-'` (default: none).
657
663
  * `--no-open` - Don't automatically open the generated HTML file after generation.
658
664
 
659
665
  **Two time concepts:**
660
666
  * `--units` controls chart *granularity* — every chart shows the full all-time history bucketed at this resolution.
661
- * `--window` controls the *analysis window* used for the KPI numbers (Total / New / % growth) — it's drawn as a shaded band on top of the all-time charts rather than filtering them out.
662
-
663
- **Growth rates:** growth/adoption rates are computed from use-case **creation timestamps**
664
- (`--window` boundary vs. each event's `created` time), not from a separate "installed base"
665
- snapshot, so `pct_growth` is always `new_in_window / count_before_window`.
667
+ * `--window` controls the *analysis window* for the "New in {window} (% of base)" growth KPIs — accounts/workspaces created in the last `--window` vs. those that existed before it.
668
+
669
+ **Growth rates:** the growth KPIs are computed from chargeback `createdAt`
670
+ timestamps as `new_in_window / count_before_window × 100`. Workspace creation is
671
+ proxied from each workspace's earliest member `createdAt`.
672
+
673
+ **Report sections:** an **Organization overview (chargeback)** section (org-wide
674
+ KPIs, workspace platform mix, total-vs-active and added-vs-deleted charts, and a
675
+ by-workspace table), a **Users** section (Total / Active / Active % / New-in-window
676
+ KPIs plus over-time charts), a **Leaderboards** section (top-N and active-aware
677
+ bottom-N workspaces by experiments/projects and users by Opik spans / EM activity,
678
+ exact from chargeback), and a **Personal vs Service accounts** split (service
679
+ accounts from the admin API, with a labeled regex fallback). Each people section
680
+ degrades independently: if its inputs are missing, a warning is printed and only
681
+ that section is dropped.
666
682
 
667
683
  **Caveats:**
668
- * **EM "created" is a proxy** — the Comet API has no true EM project-creation timestamp, so EM project creation is approximated as the earliest experiment start time in that project (falling back to the project's `lastUpdated` time if no experiments exist).
669
- * **Workspace/department "created" is also a proxy** — it's the earliest use-case creation timestamp seen in that workspace, across all platforms.
670
- * **MPM requires provisioning** — if the account/workspace has no MPM model-monitoring provisioned, the MPM collector degrades gracefully (an empty MPM section, `collectors.mpm: false`) instead of failing the whole report.
671
-
672
- Opik and MPM collection require their optional SDKs; install them with `pip install 'cometx[all]'` if they aren't already available. Platforms whose SDK can't be imported are silently dropped from `--platforms` (a note is printed) so the report still succeeds with the remaining platforms.
684
+ * **Chargeback is required** — the whole report is derived from the admin chargeback report; without admin access the command errors out.
685
+ * **Workspace "created" is a proxy** — the earliest member `createdAt`, since chargeback has no workspace-creation timestamp. The added-vs-deleted "deleted" series is also a best-effort proxy (all members removed) and typically reads ~0.
686
+ * **"Total projects" counts EM projects only** — chargeback's per-workspace `projects[]` covers Experiment Management; Opik projects and MPM aren't represented (Opik appears only as a per-user span count; MPM is absent).
673
687
 
674
688
  **Examples:**
675
689
  ```
676
- # Full cross-platform report for all workspaces, default 7-day window
690
+ # Org-wide report, default 7-day window
677
691
  cometx admin growth-report
678
692
 
679
- # Just Opik + EM, 30-day window, monthly chart granularity, for two workspaces
680
- cometx admin growth-report --platforms em,opik --window 30d my-workspace another-workspace
693
+ # 30-day window, scoped to two workspaces
694
+ cometx admin growth-report --window 30d my-workspace another-workspace
695
+
696
+ # Write to a file without auto-opening
697
+ cometx admin growth-report --no-open --output growth.html
681
698
 
682
- # Fast smoke-test run against a single workspace, don't auto-open
683
- cometx admin growth-report --limit 1 --no-open --output growth.html my-workspace
699
+ # 30-day activity window and top/bottom-10 leaderboards, excluding personal
700
+ # workspaces named like "user-..."
701
+ cometx admin growth-report --active-window 30d --leaderboard-top-n 10 \
702
+ --exclude-personal --personal-pattern '^user-'
684
703
  ```
685
704
 
686
705
  #### gpu-report
@@ -580,51 +580,70 @@ cometx admin usage-report --app
580
580
 
581
581
  #### growth-report
582
582
 
583
- Generate a cross-platform use-case growth & adoption report (Opik projects, EM projects,
584
- MPM monitored models) as a single self-contained HTML page. Distinct from `usage-report`
585
- (experiment-count PDF): `growth-report` tracks *how many use cases exist and how fast
586
- they're being created*, per workspace/department, across all three products.
583
+ Generate an organization growth & adoption report as a single self-contained HTML
584
+ page, built entirely from the **admin chargeback report**. Distinct from
585
+ `usage-report` (experiment-count PDF): `growth-report` gives an org-wide view of
586
+ workspaces, users, and platform adoption, per workspace/department.
587
+
588
+ **Requires an admin API key** — the report is derived entirely from the admin
589
+ chargeback endpoint, and with a non-admin key the command errors out (non-zero
590
+ exit).
587
591
 
588
592
  ```
589
593
  cometx admin growth-report [WORKSPACE ...]
590
594
  ```
591
595
 
592
596
  **Arguments:**
593
- * `WORKSPACE` (optional, zero or more) - Workspaces to include. If omitted, all workspaces visible to the current API key are used (via `get_workspaces()`).
597
+ * `WORKSPACE` (optional, zero or more) - Workspaces to scope the report to. If omitted, the report is org-wide.
594
598
 
595
599
  **Options:**
596
- * `--units {month,week,day,hour}` - Chart bucket granularity (default: month). Charts always render **all-time** history at this granularity; this is unrelated to `--window` below.
597
- * `--window WINDOW` - Relative analysis window for the KPIs, e.g. `7d`, `14d`, `30d`, `90d`, `2w`, `6m`, `1y` (default: `7d`). `d`=days, `w`=weeks (×7d), `m`=months (approximated as 30 days), `y`=years (approximated as 365 days) — the approximation is intentional, since the window only needs an "installed base before window" cutoff, not calendar-exact arithmetic.
598
- * `--platforms PLATFORMS` - Comma-separated list of platforms to include (default: `em,opik,mpm`). Any of `em`, `opik`, `mpm`.
600
+ * `--units {month,week,day,hour}` - Chart bucket granularity (default: month). Charts render all-time history at this granularity; unrelated to `--window` below.
601
+ * `--window WINDOW` - Relative analysis window for the growth KPIs, e.g. `7d`, `14d`, `30d`, `90d`, `2w`, `6m`, `1y` (default: `7d`). `d`=days, `w`=weeks (×7d), `m`=months (≈30 days), `y`=years (≈365 days).
599
602
  * `--output PATH` - Output HTML file path (default: `growth_report.html`).
600
- * `--limit N` - Limit the number of workspaces processed (useful for a fast smoke-test run).
603
+ * `--active-window WINDOW` - Activity window for the users layer, e.g. `30d`/`60d` (default: `60d`). A user is *active* when their last-used timestamp falls within this window.
604
+ * `--leaderboard-top-n N` - Top/bottom N size for the leaderboards section (default: `5`).
605
+ * `--exclude-personal` - Drop workspaces whose name matches `--personal-pattern` from the chargeback data (default: off; no effect without `--personal-pattern`).
606
+ * `--personal-pattern REGEX` - Regex used with `--exclude-personal` to identify personal-workspace names to drop, e.g. `'^user-'` (default: none).
601
607
  * `--no-open` - Don't automatically open the generated HTML file after generation.
602
608
 
603
609
  **Two time concepts:**
604
610
  * `--units` controls chart *granularity* — every chart shows the full all-time history bucketed at this resolution.
605
- * `--window` controls the *analysis window* used for the KPI numbers (Total / New / % growth) — it's drawn as a shaded band on top of the all-time charts rather than filtering them out.
606
-
607
- **Growth rates:** growth/adoption rates are computed from use-case **creation timestamps**
608
- (`--window` boundary vs. each event's `created` time), not from a separate "installed base"
609
- snapshot, so `pct_growth` is always `new_in_window / count_before_window`.
611
+ * `--window` controls the *analysis window* for the "New in {window} (% of base)" growth KPIs — accounts/workspaces created in the last `--window` vs. those that existed before it.
612
+
613
+ **Growth rates:** the growth KPIs are computed from chargeback `createdAt`
614
+ timestamps as `new_in_window / count_before_window × 100`. Workspace creation is
615
+ proxied from each workspace's earliest member `createdAt`.
616
+
617
+ **Report sections:** an **Organization overview (chargeback)** section (org-wide
618
+ KPIs, workspace platform mix, total-vs-active and added-vs-deleted charts, and a
619
+ by-workspace table), a **Users** section (Total / Active / Active % / New-in-window
620
+ KPIs plus over-time charts), a **Leaderboards** section (top-N and active-aware
621
+ bottom-N workspaces by experiments/projects and users by Opik spans / EM activity,
622
+ exact from chargeback), and a **Personal vs Service accounts** split (service
623
+ accounts from the admin API, with a labeled regex fallback). Each people section
624
+ degrades independently: if its inputs are missing, a warning is printed and only
625
+ that section is dropped.
610
626
 
611
627
  **Caveats:**
612
- * **EM "created" is a proxy** — the Comet API has no true EM project-creation timestamp, so EM project creation is approximated as the earliest experiment start time in that project (falling back to the project's `lastUpdated` time if no experiments exist).
613
- * **Workspace/department "created" is also a proxy** — it's the earliest use-case creation timestamp seen in that workspace, across all platforms.
614
- * **MPM requires provisioning** — if the account/workspace has no MPM model-monitoring provisioned, the MPM collector degrades gracefully (an empty MPM section, `collectors.mpm: false`) instead of failing the whole report.
615
-
616
- Opik and MPM collection require their optional SDKs; install them with `pip install 'cometx[all]'` if they aren't already available. Platforms whose SDK can't be imported are silently dropped from `--platforms` (a note is printed) so the report still succeeds with the remaining platforms.
628
+ * **Chargeback is required** — the whole report is derived from the admin chargeback report; without admin access the command errors out.
629
+ * **Workspace "created" is a proxy** — the earliest member `createdAt`, since chargeback has no workspace-creation timestamp. The added-vs-deleted "deleted" series is also a best-effort proxy (all members removed) and typically reads ~0.
630
+ * **"Total projects" counts EM projects only** — chargeback's per-workspace `projects[]` covers Experiment Management; Opik projects and MPM aren't represented (Opik appears only as a per-user span count; MPM is absent).
617
631
 
618
632
  **Examples:**
619
633
  ```
620
- # Full cross-platform report for all workspaces, default 7-day window
634
+ # Org-wide report, default 7-day window
621
635
  cometx admin growth-report
622
636
 
623
- # Just Opik + EM, 30-day window, monthly chart granularity, for two workspaces
624
- cometx admin growth-report --platforms em,opik --window 30d my-workspace another-workspace
637
+ # 30-day window, scoped to two workspaces
638
+ cometx admin growth-report --window 30d my-workspace another-workspace
639
+
640
+ # Write to a file without auto-opening
641
+ cometx admin growth-report --no-open --output growth.html
625
642
 
626
- # Fast smoke-test run against a single workspace, don't auto-open
627
- cometx admin growth-report --limit 1 --no-open --output growth.html my-workspace
643
+ # 30-day activity window and top/bottom-10 leaderboards, excluding personal
644
+ # workspaces named like "user-..."
645
+ cometx admin growth-report --active-window 30d --leaderboard-top-n 10 \
646
+ --exclude-personal --personal-pattern '^user-'
628
647
  ```
629
648
 
630
649
  #### gpu-report
@@ -12,5 +12,5 @@
12
12
  # the express permission of Comet ML Inc.
13
13
  # *******************************************************
14
14
 
15
- version_info = (3, 6, 7)
15
+ version_info = (3, 6, 9)
16
16
  __version__ = ".".join(map(str, version_info))
@@ -149,12 +149,13 @@ import argparse
149
149
  import json
150
150
  import os
151
151
  import sys
152
- from urllib.parse import urlparse
153
152
 
154
153
  from comet_ml import API
155
154
 
155
+ from cometx.utils import fetch_chargeback_report
156
+
156
157
  from .admin_gpu_report import main as gpu_report_main
157
- from .admin_growth_report import generate_growth_report
158
+ from .admin_growth_report import GrowthReportError, generate_growth_report
158
159
  from .admin_optimizer_report import generate_json_report
159
160
  from .admin_usage_report import generate_usage_report
160
161
 
@@ -463,28 +464,36 @@ Examples:
463
464
  )
464
465
 
465
466
  # growth-report subcommand
466
- growth_report_description = """Generate a cross-platform use-case growth report for one or more workspaces.
467
+ growth_report_description = """\
468
+ Generate an org-wide people/usage growth report from the admin \
469
+ chargeback report.
467
470
 
468
471
  Arguments:
469
472
  WORKSPACE (optional, one or more)
470
473
  One or more workspaces to run the growth report for.
471
474
  If not provided, all workspaces are included.
472
475
 
476
+ Requires an ADMIN API key: the report is built entirely from the admin
477
+ chargeback report. Without admin access the command exits with an error.
478
+
473
479
  Output:
474
- Generates a self-contained HTML page containing cross-platform (Opik + EM + MPM)
475
- use-case growth and rate charts, broken down by workspace/department.
480
+ Generates a self-contained HTML page with the organization overview, users,
481
+ personal-vs-service, and leaderboard sections, all derived from the admin
482
+ chargeback report and broken down by workspace/department.
476
483
 
477
484
  Examples:
478
485
  cometx admin growth-report
479
486
  cometx admin growth-report my-workspace
480
487
  cometx admin growth-report workspace1 workspace2 --units week
481
488
  cometx admin growth-report my-workspace --window 30d
482
- cometx admin growth-report my-workspace --platforms em,opik
483
489
  cometx admin growth-report my-workspace --output report.html --no-open
484
490
  """
485
491
  growth_parser = subparsers.add_parser(
486
492
  "growth-report",
487
- help="Generate a cross-platform use-case growth report for one or more workspaces",
493
+ help=(
494
+ "Generate an org-wide people/usage growth report from the "
495
+ "admin chargeback report"
496
+ ),
488
497
  description=growth_report_description,
489
498
  formatter_class=argparse.RawDescriptionHelpFormatter,
490
499
  )
@@ -510,12 +519,6 @@ Examples:
510
519
  default="7d",
511
520
  type=str,
512
521
  )
513
- growth_parser.add_argument(
514
- "--platforms",
515
- help="Comma-separated list of platforms to include (default: em,opik,mpm)",
516
- default="em,opik,mpm",
517
- type=str,
518
- )
519
522
  growth_parser.add_argument(
520
523
  "--output",
521
524
  help="Output HTML file path (default: growth_report.html)",
@@ -523,10 +526,32 @@ Examples:
523
526
  type=str,
524
527
  )
525
528
  growth_parser.add_argument(
526
- "--limit",
527
- help="Optional limit on the number of items collected per platform",
529
+ "--active-window",
530
+ default="60d",
531
+ help="Activity window for the users/people layer, e.g. 30d/60d (default: 60d)",
532
+ )
533
+ growth_parser.add_argument(
534
+ "--leaderboard-top-n",
528
535
  type=int,
536
+ default=5,
537
+ help="Top/bottom N size for leaderboards (default: 5)",
538
+ )
539
+ growth_parser.add_argument(
540
+ "--exclude-personal",
541
+ action="store_true",
542
+ default=False,
543
+ help=(
544
+ "Drop workspaces whose name matches --personal-pattern before "
545
+ "collection (default: off; has no effect without --personal-pattern)"
546
+ ),
547
+ )
548
+ growth_parser.add_argument(
549
+ "--personal-pattern",
529
550
  default=None,
551
+ help=(
552
+ "Regex used with --exclude-personal to identify personal-workspace "
553
+ "names to drop, e.g. '^user-' (default: none)"
554
+ ),
530
555
  )
531
556
  growth_parser.add_argument(
532
557
  "--no-open",
@@ -542,39 +567,17 @@ def admin(parsed_args, remaining=None):
542
567
  api = API()
543
568
 
544
569
  if parsed_args.ACTION == "chargeback-report":
545
- if parsed_args.host is not None:
546
- admin_url = parsed_args.host
547
- else:
548
- url = api.config["comet.url_override"]
549
- result = urlparse(url)
550
- admin_url = "%s://%s" % (
551
- result.scheme,
552
- result.netloc,
553
- )
554
-
555
- while admin_url.endswith("/"):
556
- admin_url = admin_url[:-1]
557
-
558
- admin_url += "/api/admin/chargeback/report"
559
-
560
- print("Attempting to get chargeback report from %s..." % admin_url)
570
+ print("Attempting to get chargeback report...")
571
+ report = fetch_chargeback_report(
572
+ api, host=parsed_args.host, report_month=parsed_args.YEAR_MONTH
573
+ )
561
574
  if parsed_args.YEAR_MONTH:
562
- response = api._client.get(
563
- admin_url + ("?reportMonth=%s" % parsed_args.YEAR_MONTH),
564
- headers={"Authorization": api.api_key},
565
- params={},
566
- )
567
575
  filename = "comet-chargeback-report-%s.json" % parsed_args.YEAR_MONTH
568
576
  else:
569
- response = api._client.get(
570
- admin_url,
571
- headers={"Authorization": api.api_key},
572
- params={},
573
- )
574
577
  filename = "comet-chargeback-report.json"
575
578
  print("Attempting to save chargeback report...")
576
579
  with open(filename, "w") as fp:
577
- fp.write(json.dumps(response.json()))
580
+ fp.write(json.dumps(report))
578
581
  print("Chargeback report is saved in %r" % filename)
579
582
  elif parsed_args.ACTION == "usage-report":
580
583
  if parsed_args.app:
@@ -827,11 +830,16 @@ def admin(parsed_args, remaining=None):
827
830
  parsed_args.WORKSPACE,
828
831
  window=parsed_args.window,
829
832
  units=parsed_args.units,
830
- platforms=parsed_args.platforms,
831
833
  output=parsed_args.output,
832
834
  no_open=parsed_args.no_open,
833
- limit=parsed_args.limit,
835
+ active_window=parsed_args.active_window,
836
+ leaderboard_top_n=parsed_args.leaderboard_top_n,
837
+ exclude_personal=parsed_args.exclude_personal,
838
+ personal_pattern=parsed_args.personal_pattern,
834
839
  )
840
+ except GrowthReportError as e:
841
+ print("ERROR: " + str(e))
842
+ sys.exit(1)
835
843
  except Exception as e:
836
844
  print("ERROR: " + str(e))
837
845
  if parsed_args.debug: