datacommons-cli 1.1.4__tar.gz → 1.1.5__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.
@@ -0,0 +1,264 @@
1
+ Metadata-Version: 2.4
2
+ Name: datacommons-cli
3
+ Version: 1.1.5
4
+ Summary: Data Commons CLI
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/datacommonsorg/datacommons
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: click>=8.1.7
10
+ Requires-Dist: datacommons-admin==1.1.5
11
+
12
+ # Data Commons CLI
13
+
14
+ <p align="center">
15
+ <a href="https://www.datacommons.org"><img src="https://datacommons.org/images/dc-logo.svg" alt="Data Commons" width="120"></a>
16
+ </p>
17
+
18
+ <p align="center">
19
+ <em>Standard command-line interface for interacting with, deploying, and administering the Data Commons Platform.</em>
20
+ </p>
21
+
22
+ ---
23
+
24
+ [Data Commons](https://www.datacommons.org) is an open-source project initiated by Google that aggregates data from hundreds of public sources, such as the US Census, Eurostat, CDC, and UN, into a unified, standard Knowledge Graph.
25
+
26
+ The **Data Commons Platform** provides the infrastructure to run your own private instance of Data Commons, allowing you to seamlessly combine public datasets with your own custom, private data using modern APIs, graph query engines, and visualization dashboards.
27
+
28
+ ---
29
+
30
+ ## Installation
31
+
32
+ Install the Data Commons CLI using `pip` or `uv`:
33
+
34
+ ### Install with `pip`
35
+
36
+ ```bash
37
+ pip install --user datacommons-cli
38
+ ```
39
+
40
+ If the datacommons command is not found after installing, add Python's user-binary directory to your PATH:
41
+
42
+ ```
43
+ export PATH="$PATH:$(python3 -m site --user-base)/bin"
44
+ ```
45
+
46
+ ### Install with `uv`
47
+
48
+ ```bash
49
+ uv tool install datacommons-cli
50
+ ```
51
+
52
+ If the `datacommons` command is not found after installing, add the appropriate directory to your PATH:
53
+
54
+ ```
55
+ export PATH="~/.local/bin:$PATH"
56
+ ```
57
+
58
+ ### With `uvx`
59
+
60
+ Or execute `datacommons-cli` on-the-fly without installation using `uvx`:
61
+
62
+ ```bash
63
+ uvx datacommons-cli --help
64
+ ```
65
+
66
+ ## Help & Documentation
67
+
68
+ For full documentation, tutorials, and deployment guides, visit:
69
+ 👉 **[docs.datacommons.org](https://docs.datacommons.org)**
70
+
71
+ ---
72
+
73
+ ## Usage
74
+
75
+ The CLI exposes standard operations under the main `datacommons` entrypoint. You can check the version and get help instantly:
76
+
77
+ ```bash
78
+ # Show help menu
79
+ datacommons --help
80
+
81
+ # Show version
82
+ datacommons --version
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Administrative Commands
88
+
89
+ All infrastructure setup, database operations, and ingestion pipelines are managed under the `admin` sub-command group:
90
+
91
+ ```bash
92
+ datacommons admin [OPTIONS] COMMAND [ARGS]...
93
+ ```
94
+
95
+ ### Execution Modes: Local vs. Remote State
96
+
97
+ The `admin` commands interact with your deployed GCP resources (Cloud Spanner, Ingestion Helper Cloud Run service, and Cloud Workflows). To resolve deployment outputs (such as service URLs and Spanner IDs), the CLI supports two execution modes:
98
+
99
+ #### 1. Local State Mode (Default)
100
+ When executed from inside your initialized Terraform deployment directory (e.g., `cd my-instance`), the CLI automatically inspects local Terraform state outputs using `terraform output -json`:
101
+
102
+ ```bash
103
+ cd my-instance
104
+ datacommons admin init-db
105
+ ```
106
+
107
+ #### 2. Remote GCS State Mode (Stateless / CI/CD)
108
+ When running from outside the deployment directory, on a remote workstation, or within automated CI/CD pipelines (e.g., Cloud Build, GitHub Actions), you do not need local Terraform files, `.tfstate` files, or the `terraform` CLI installed.
109
+
110
+ Pass remote-state options directly to the `admin` command group:
111
+
112
+ ```bash
113
+ # Locate remote state automatically via project ID and instance name:
114
+ datacommons admin --project-id my-project --instance-name my-instance init-db
115
+
116
+ # Or specify the exact GCS state URI:
117
+ datacommons admin --tf-state-location gs://my-tfstate-bucket/terraform/state/my-instance/default.tfstate migrate-db -y
118
+ ```
119
+
120
+ > [!TIP]
121
+ > **Why use Remote GCS State Mode?**
122
+ > - **Zero Local Files**: Reads Terraform state outputs directly from Google Cloud Storage into memory using the Cloud Storage API.
123
+ > - **Secure & Stateless**: Adheres to infrastructure security best practices by avoiding downloading `.tfstate` files to local disks or exposing local Terraform execution.
124
+ > - **CI/CD Ready**: Allows automated jobs to trigger migrations or ingestion without cloning or initializing the Terraform repository.
125
+
126
+ #### Remote-State Global Options
127
+
128
+ These options can be passed to `datacommons admin` for any administrative command:
129
+
130
+ | Option | Description |
131
+ | --- | --- |
132
+ | `--project-id TEXT` | GCP project ID used to locate the canonical remote Terraform state bucket (`gs://<project_id>-<instance_name>-tfstate`). Must be specified together with `--instance-name`. |
133
+ | `--instance-name TEXT` | DCP instance name (prefix) used to locate the remote Terraform state bucket. Must be specified together with `--project-id`. |
134
+ | `--tf-state-location TEXT` | Exact GCS URI of the Terraform state file (e.g. `gs://bucket/prefix/default.tfstate`). Overrides canonical bucket derivation. |
135
+
136
+ ---
137
+
138
+ ### Available Commands
139
+
140
+ | Command | Description |
141
+ | --- | --- |
142
+ | **`init`** | Scaffolds a localized Terraform deployment directory for the Data Commons Platform on Google Cloud Platform (GCP). |
143
+ | **`init-db`** | Configures database schemas and seeds baseline tables on Cloud Spanner via the Ingestion Helper service. |
144
+ | **`migrate-db`** | Checks and applies pending schema migrations to the Cloud Spanner database. |
145
+ | **`seed-db`** | Seeds or re-applies base geographic entities and schema definitions to Cloud Spanner. |
146
+ | **`ingest start`** | Triggers a Cloud Workflows + Cloud Run background data ingestion pipeline for custom datasets. |
147
+ | **`ingest show-config`**| Displays current background ingestion parameters, service URLs, and Cloud Run job environment variables. |
148
+
149
+ ---
150
+
151
+ ### Command Reference & Examples
152
+
153
+ #### `datacommons admin init`
154
+ Scaffolds a new deployment directory containing `main.tf`, `terraform.tfvars`, and a deployment README.
155
+
156
+ ```bash
157
+ datacommons admin init --project-id my-gcp-project --instance-name my-instance
158
+ ```
159
+
160
+ Key Options:
161
+ - `--project-id TEXT`: GCP project ID for platform resources.
162
+ - `--instance-name TEXT`: Instance name prefix for provisioned resources (also accepts `--namespace` for backward compatibility).
163
+ - `--dc-api-key TEXT`: Data Commons API key.
164
+ - `--tf-remote-state / --no-tf-remote-state`: Enable/disable remote state management in GCS (default: enabled).
165
+ - `--tf-state-bucket TEXT`: Custom GCS bucket name for Terraform state (defaults to `<project_id>-<instance_name>-tfstate`).
166
+ - `--force`: Overwrite existing files in the target directory if present.
167
+
168
+ #### `datacommons admin init-db`
169
+ Initializes database schema, applies all migrations, and seeds baseline geographic data on Cloud Spanner. If the database has already been initialized, the command safely detects it and prompts you to use `migrate-db` or `seed-db`.
170
+
171
+ ```bash
172
+ # Local state mode:
173
+ datacommons admin init-db
174
+
175
+ # Remote state mode:
176
+ datacommons admin --project-id my-project --instance-name my-instance init-db
177
+
178
+ # Initialize schemas and migrations only (skip baseline data seeding):
179
+ datacommons admin init-db --init-only
180
+ ```
181
+
182
+ #### `datacommons admin migrate-db`
183
+ Inspects pending Spanner schema migrations and applies them sequentially using distributed locks.
184
+
185
+ ```bash
186
+ # Interactive mode (prompts before applying pending migrations):
187
+ datacommons admin migrate-db
188
+
189
+ # Non-interactive / CI/CD mode (auto-approves pending migrations):
190
+ datacommons admin --project-id my-project --instance-name my-instance migrate-db -y
191
+ ```
192
+
193
+ Key Options:
194
+ - `-y`, `--yes`: Automatically confirm and apply pending migrations without interactive prompts.
195
+
196
+ #### `datacommons admin seed-db`
197
+ Seeds baseline geographic nodes and schema mappings on Cloud Spanner via the Ingestion Helper service.
198
+
199
+ ```bash
200
+ datacommons admin seed-db
201
+ # Or via remote state:
202
+ datacommons admin --project-id my-project --instance-name my-instance seed-db
203
+ ```
204
+
205
+ #### `datacommons admin ingest start`
206
+ Triggers an asynchronous data ingestion workflow using Google Cloud Workflows and Cloud Run. Prints the execution ID and a direct Google Cloud Console link for live monitoring.
207
+
208
+ ```bash
209
+ datacommons admin ingest start --imports <import_name>
210
+ # Or via remote state:
211
+ datacommons admin --project-id my-project --instance-name my-instance ingest start --imports un_sdg
212
+ ```
213
+
214
+ Key Options:
215
+ - `--imports TEXT` *(required)*: Comma-separated names of the configured imports to run.
216
+
217
+ #### `datacommons admin ingest show-config`
218
+ Fetches and inspects the active environment variables and configuration for the Cloud Run ingestion job.
219
+
220
+ ```bash
221
+ datacommons admin ingest show-config
222
+ # Or via remote state:
223
+ datacommons admin --project-id my-project --instance-name my-instance ingest show-config
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Data Commons CLI Cheatsheet
229
+
230
+ ### Quickstart Workflow
231
+ ```bash
232
+ # 1. Scaffold Terraform configuration
233
+ datacommons admin init --project-id my-project --instance-name prod
234
+
235
+ # 2. Deploy infrastructure
236
+ cd prod
237
+ terraform init
238
+ terraform apply
239
+
240
+ # 3. Initialize database & seed baseline data
241
+ datacommons admin init-db
242
+
243
+ # 4. Trigger data ingestion
244
+ datacommons admin ingest start --imports my_import
245
+ ```
246
+
247
+ ### Remote / CI/CD Operations Cheatsheet
248
+ ```bash
249
+ # Run migrations non-interactively without local Terraform files
250
+ datacommons admin --project-id my-project --instance-name prod migrate-db -y
251
+
252
+ # Re-seed Spanner database from anywhere
253
+ datacommons admin --project-id my-project --instance-name prod seed-db
254
+
255
+ # Trigger ingestion using an explicit GCS state URI
256
+ datacommons admin --tf-state-location gs://my-project-prod-tfstate/terraform/state/prod/default.tfstate ingest start --imports my_dataset
257
+
258
+ # Inspect ingestion job configuration
259
+ datacommons admin --project-id my-project --instance-name prod ingest show-config
260
+ ```
261
+
262
+ ---
263
+
264
+ License: [Apache-2.0](https://github.com/datacommonsorg/datacommons/blob/main/LICENSE)
@@ -0,0 +1,253 @@
1
+ # Data Commons CLI
2
+
3
+ <p align="center">
4
+ <a href="https://www.datacommons.org"><img src="https://datacommons.org/images/dc-logo.svg" alt="Data Commons" width="120"></a>
5
+ </p>
6
+
7
+ <p align="center">
8
+ <em>Standard command-line interface for interacting with, deploying, and administering the Data Commons Platform.</em>
9
+ </p>
10
+
11
+ ---
12
+
13
+ [Data Commons](https://www.datacommons.org) is an open-source project initiated by Google that aggregates data from hundreds of public sources, such as the US Census, Eurostat, CDC, and UN, into a unified, standard Knowledge Graph.
14
+
15
+ The **Data Commons Platform** provides the infrastructure to run your own private instance of Data Commons, allowing you to seamlessly combine public datasets with your own custom, private data using modern APIs, graph query engines, and visualization dashboards.
16
+
17
+ ---
18
+
19
+ ## Installation
20
+
21
+ Install the Data Commons CLI using `pip` or `uv`:
22
+
23
+ ### Install with `pip`
24
+
25
+ ```bash
26
+ pip install --user datacommons-cli
27
+ ```
28
+
29
+ If the datacommons command is not found after installing, add Python's user-binary directory to your PATH:
30
+
31
+ ```
32
+ export PATH="$PATH:$(python3 -m site --user-base)/bin"
33
+ ```
34
+
35
+ ### Install with `uv`
36
+
37
+ ```bash
38
+ uv tool install datacommons-cli
39
+ ```
40
+
41
+ If the `datacommons` command is not found after installing, add the appropriate directory to your PATH:
42
+
43
+ ```
44
+ export PATH="~/.local/bin:$PATH"
45
+ ```
46
+
47
+ ### With `uvx`
48
+
49
+ Or execute `datacommons-cli` on-the-fly without installation using `uvx`:
50
+
51
+ ```bash
52
+ uvx datacommons-cli --help
53
+ ```
54
+
55
+ ## Help & Documentation
56
+
57
+ For full documentation, tutorials, and deployment guides, visit:
58
+ 👉 **[docs.datacommons.org](https://docs.datacommons.org)**
59
+
60
+ ---
61
+
62
+ ## Usage
63
+
64
+ The CLI exposes standard operations under the main `datacommons` entrypoint. You can check the version and get help instantly:
65
+
66
+ ```bash
67
+ # Show help menu
68
+ datacommons --help
69
+
70
+ # Show version
71
+ datacommons --version
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Administrative Commands
77
+
78
+ All infrastructure setup, database operations, and ingestion pipelines are managed under the `admin` sub-command group:
79
+
80
+ ```bash
81
+ datacommons admin [OPTIONS] COMMAND [ARGS]...
82
+ ```
83
+
84
+ ### Execution Modes: Local vs. Remote State
85
+
86
+ The `admin` commands interact with your deployed GCP resources (Cloud Spanner, Ingestion Helper Cloud Run service, and Cloud Workflows). To resolve deployment outputs (such as service URLs and Spanner IDs), the CLI supports two execution modes:
87
+
88
+ #### 1. Local State Mode (Default)
89
+ When executed from inside your initialized Terraform deployment directory (e.g., `cd my-instance`), the CLI automatically inspects local Terraform state outputs using `terraform output -json`:
90
+
91
+ ```bash
92
+ cd my-instance
93
+ datacommons admin init-db
94
+ ```
95
+
96
+ #### 2. Remote GCS State Mode (Stateless / CI/CD)
97
+ When running from outside the deployment directory, on a remote workstation, or within automated CI/CD pipelines (e.g., Cloud Build, GitHub Actions), you do not need local Terraform files, `.tfstate` files, or the `terraform` CLI installed.
98
+
99
+ Pass remote-state options directly to the `admin` command group:
100
+
101
+ ```bash
102
+ # Locate remote state automatically via project ID and instance name:
103
+ datacommons admin --project-id my-project --instance-name my-instance init-db
104
+
105
+ # Or specify the exact GCS state URI:
106
+ datacommons admin --tf-state-location gs://my-tfstate-bucket/terraform/state/my-instance/default.tfstate migrate-db -y
107
+ ```
108
+
109
+ > [!TIP]
110
+ > **Why use Remote GCS State Mode?**
111
+ > - **Zero Local Files**: Reads Terraform state outputs directly from Google Cloud Storage into memory using the Cloud Storage API.
112
+ > - **Secure & Stateless**: Adheres to infrastructure security best practices by avoiding downloading `.tfstate` files to local disks or exposing local Terraform execution.
113
+ > - **CI/CD Ready**: Allows automated jobs to trigger migrations or ingestion without cloning or initializing the Terraform repository.
114
+
115
+ #### Remote-State Global Options
116
+
117
+ These options can be passed to `datacommons admin` for any administrative command:
118
+
119
+ | Option | Description |
120
+ | --- | --- |
121
+ | `--project-id TEXT` | GCP project ID used to locate the canonical remote Terraform state bucket (`gs://<project_id>-<instance_name>-tfstate`). Must be specified together with `--instance-name`. |
122
+ | `--instance-name TEXT` | DCP instance name (prefix) used to locate the remote Terraform state bucket. Must be specified together with `--project-id`. |
123
+ | `--tf-state-location TEXT` | Exact GCS URI of the Terraform state file (e.g. `gs://bucket/prefix/default.tfstate`). Overrides canonical bucket derivation. |
124
+
125
+ ---
126
+
127
+ ### Available Commands
128
+
129
+ | Command | Description |
130
+ | --- | --- |
131
+ | **`init`** | Scaffolds a localized Terraform deployment directory for the Data Commons Platform on Google Cloud Platform (GCP). |
132
+ | **`init-db`** | Configures database schemas and seeds baseline tables on Cloud Spanner via the Ingestion Helper service. |
133
+ | **`migrate-db`** | Checks and applies pending schema migrations to the Cloud Spanner database. |
134
+ | **`seed-db`** | Seeds or re-applies base geographic entities and schema definitions to Cloud Spanner. |
135
+ | **`ingest start`** | Triggers a Cloud Workflows + Cloud Run background data ingestion pipeline for custom datasets. |
136
+ | **`ingest show-config`**| Displays current background ingestion parameters, service URLs, and Cloud Run job environment variables. |
137
+
138
+ ---
139
+
140
+ ### Command Reference & Examples
141
+
142
+ #### `datacommons admin init`
143
+ Scaffolds a new deployment directory containing `main.tf`, `terraform.tfvars`, and a deployment README.
144
+
145
+ ```bash
146
+ datacommons admin init --project-id my-gcp-project --instance-name my-instance
147
+ ```
148
+
149
+ Key Options:
150
+ - `--project-id TEXT`: GCP project ID for platform resources.
151
+ - `--instance-name TEXT`: Instance name prefix for provisioned resources (also accepts `--namespace` for backward compatibility).
152
+ - `--dc-api-key TEXT`: Data Commons API key.
153
+ - `--tf-remote-state / --no-tf-remote-state`: Enable/disable remote state management in GCS (default: enabled).
154
+ - `--tf-state-bucket TEXT`: Custom GCS bucket name for Terraform state (defaults to `<project_id>-<instance_name>-tfstate`).
155
+ - `--force`: Overwrite existing files in the target directory if present.
156
+
157
+ #### `datacommons admin init-db`
158
+ Initializes database schema, applies all migrations, and seeds baseline geographic data on Cloud Spanner. If the database has already been initialized, the command safely detects it and prompts you to use `migrate-db` or `seed-db`.
159
+
160
+ ```bash
161
+ # Local state mode:
162
+ datacommons admin init-db
163
+
164
+ # Remote state mode:
165
+ datacommons admin --project-id my-project --instance-name my-instance init-db
166
+
167
+ # Initialize schemas and migrations only (skip baseline data seeding):
168
+ datacommons admin init-db --init-only
169
+ ```
170
+
171
+ #### `datacommons admin migrate-db`
172
+ Inspects pending Spanner schema migrations and applies them sequentially using distributed locks.
173
+
174
+ ```bash
175
+ # Interactive mode (prompts before applying pending migrations):
176
+ datacommons admin migrate-db
177
+
178
+ # Non-interactive / CI/CD mode (auto-approves pending migrations):
179
+ datacommons admin --project-id my-project --instance-name my-instance migrate-db -y
180
+ ```
181
+
182
+ Key Options:
183
+ - `-y`, `--yes`: Automatically confirm and apply pending migrations without interactive prompts.
184
+
185
+ #### `datacommons admin seed-db`
186
+ Seeds baseline geographic nodes and schema mappings on Cloud Spanner via the Ingestion Helper service.
187
+
188
+ ```bash
189
+ datacommons admin seed-db
190
+ # Or via remote state:
191
+ datacommons admin --project-id my-project --instance-name my-instance seed-db
192
+ ```
193
+
194
+ #### `datacommons admin ingest start`
195
+ Triggers an asynchronous data ingestion workflow using Google Cloud Workflows and Cloud Run. Prints the execution ID and a direct Google Cloud Console link for live monitoring.
196
+
197
+ ```bash
198
+ datacommons admin ingest start --imports <import_name>
199
+ # Or via remote state:
200
+ datacommons admin --project-id my-project --instance-name my-instance ingest start --imports un_sdg
201
+ ```
202
+
203
+ Key Options:
204
+ - `--imports TEXT` *(required)*: Comma-separated names of the configured imports to run.
205
+
206
+ #### `datacommons admin ingest show-config`
207
+ Fetches and inspects the active environment variables and configuration for the Cloud Run ingestion job.
208
+
209
+ ```bash
210
+ datacommons admin ingest show-config
211
+ # Or via remote state:
212
+ datacommons admin --project-id my-project --instance-name my-instance ingest show-config
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Data Commons CLI Cheatsheet
218
+
219
+ ### Quickstart Workflow
220
+ ```bash
221
+ # 1. Scaffold Terraform configuration
222
+ datacommons admin init --project-id my-project --instance-name prod
223
+
224
+ # 2. Deploy infrastructure
225
+ cd prod
226
+ terraform init
227
+ terraform apply
228
+
229
+ # 3. Initialize database & seed baseline data
230
+ datacommons admin init-db
231
+
232
+ # 4. Trigger data ingestion
233
+ datacommons admin ingest start --imports my_import
234
+ ```
235
+
236
+ ### Remote / CI/CD Operations Cheatsheet
237
+ ```bash
238
+ # Run migrations non-interactively without local Terraform files
239
+ datacommons admin --project-id my-project --instance-name prod migrate-db -y
240
+
241
+ # Re-seed Spanner database from anywhere
242
+ datacommons admin --project-id my-project --instance-name prod seed-db
243
+
244
+ # Trigger ingestion using an explicit GCS state URI
245
+ datacommons admin --tf-state-location gs://my-project-prod-tfstate/terraform/state/prod/default.tfstate ingest start --imports my_dataset
246
+
247
+ # Inspect ingestion job configuration
248
+ datacommons admin --project-id my-project --instance-name prod ingest show-config
249
+ ```
250
+
251
+ ---
252
+
253
+ License: [Apache-2.0](https://github.com/datacommonsorg/datacommons/blob/main/LICENSE)
@@ -0,0 +1 @@
1
+ 1.1.5
@@ -15,9 +15,7 @@
15
15
  import os
16
16
 
17
17
  import click
18
-
19
18
  from datacommons_admin.admin_cli import admin as admin_cli
20
-
21
19
  from . import __version__
22
20
 
23
21
 
@@ -0,0 +1,264 @@
1
+ Metadata-Version: 2.4
2
+ Name: datacommons-cli
3
+ Version: 1.1.5
4
+ Summary: Data Commons CLI
5
+ License-Expression: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/datacommonsorg/datacommons
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: click>=8.1.7
10
+ Requires-Dist: datacommons-admin==1.1.5
11
+
12
+ # Data Commons CLI
13
+
14
+ <p align="center">
15
+ <a href="https://www.datacommons.org"><img src="https://datacommons.org/images/dc-logo.svg" alt="Data Commons" width="120"></a>
16
+ </p>
17
+
18
+ <p align="center">
19
+ <em>Standard command-line interface for interacting with, deploying, and administering the Data Commons Platform.</em>
20
+ </p>
21
+
22
+ ---
23
+
24
+ [Data Commons](https://www.datacommons.org) is an open-source project initiated by Google that aggregates data from hundreds of public sources, such as the US Census, Eurostat, CDC, and UN, into a unified, standard Knowledge Graph.
25
+
26
+ The **Data Commons Platform** provides the infrastructure to run your own private instance of Data Commons, allowing you to seamlessly combine public datasets with your own custom, private data using modern APIs, graph query engines, and visualization dashboards.
27
+
28
+ ---
29
+
30
+ ## Installation
31
+
32
+ Install the Data Commons CLI using `pip` or `uv`:
33
+
34
+ ### Install with `pip`
35
+
36
+ ```bash
37
+ pip install --user datacommons-cli
38
+ ```
39
+
40
+ If the datacommons command is not found after installing, add Python's user-binary directory to your PATH:
41
+
42
+ ```
43
+ export PATH="$PATH:$(python3 -m site --user-base)/bin"
44
+ ```
45
+
46
+ ### Install with `uv`
47
+
48
+ ```bash
49
+ uv tool install datacommons-cli
50
+ ```
51
+
52
+ If the `datacommons` command is not found after installing, add the appropriate directory to your PATH:
53
+
54
+ ```
55
+ export PATH="~/.local/bin:$PATH"
56
+ ```
57
+
58
+ ### With `uvx`
59
+
60
+ Or execute `datacommons-cli` on-the-fly without installation using `uvx`:
61
+
62
+ ```bash
63
+ uvx datacommons-cli --help
64
+ ```
65
+
66
+ ## Help & Documentation
67
+
68
+ For full documentation, tutorials, and deployment guides, visit:
69
+ 👉 **[docs.datacommons.org](https://docs.datacommons.org)**
70
+
71
+ ---
72
+
73
+ ## Usage
74
+
75
+ The CLI exposes standard operations under the main `datacommons` entrypoint. You can check the version and get help instantly:
76
+
77
+ ```bash
78
+ # Show help menu
79
+ datacommons --help
80
+
81
+ # Show version
82
+ datacommons --version
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Administrative Commands
88
+
89
+ All infrastructure setup, database operations, and ingestion pipelines are managed under the `admin` sub-command group:
90
+
91
+ ```bash
92
+ datacommons admin [OPTIONS] COMMAND [ARGS]...
93
+ ```
94
+
95
+ ### Execution Modes: Local vs. Remote State
96
+
97
+ The `admin` commands interact with your deployed GCP resources (Cloud Spanner, Ingestion Helper Cloud Run service, and Cloud Workflows). To resolve deployment outputs (such as service URLs and Spanner IDs), the CLI supports two execution modes:
98
+
99
+ #### 1. Local State Mode (Default)
100
+ When executed from inside your initialized Terraform deployment directory (e.g., `cd my-instance`), the CLI automatically inspects local Terraform state outputs using `terraform output -json`:
101
+
102
+ ```bash
103
+ cd my-instance
104
+ datacommons admin init-db
105
+ ```
106
+
107
+ #### 2. Remote GCS State Mode (Stateless / CI/CD)
108
+ When running from outside the deployment directory, on a remote workstation, or within automated CI/CD pipelines (e.g., Cloud Build, GitHub Actions), you do not need local Terraform files, `.tfstate` files, or the `terraform` CLI installed.
109
+
110
+ Pass remote-state options directly to the `admin` command group:
111
+
112
+ ```bash
113
+ # Locate remote state automatically via project ID and instance name:
114
+ datacommons admin --project-id my-project --instance-name my-instance init-db
115
+
116
+ # Or specify the exact GCS state URI:
117
+ datacommons admin --tf-state-location gs://my-tfstate-bucket/terraform/state/my-instance/default.tfstate migrate-db -y
118
+ ```
119
+
120
+ > [!TIP]
121
+ > **Why use Remote GCS State Mode?**
122
+ > - **Zero Local Files**: Reads Terraform state outputs directly from Google Cloud Storage into memory using the Cloud Storage API.
123
+ > - **Secure & Stateless**: Adheres to infrastructure security best practices by avoiding downloading `.tfstate` files to local disks or exposing local Terraform execution.
124
+ > - **CI/CD Ready**: Allows automated jobs to trigger migrations or ingestion without cloning or initializing the Terraform repository.
125
+
126
+ #### Remote-State Global Options
127
+
128
+ These options can be passed to `datacommons admin` for any administrative command:
129
+
130
+ | Option | Description |
131
+ | --- | --- |
132
+ | `--project-id TEXT` | GCP project ID used to locate the canonical remote Terraform state bucket (`gs://<project_id>-<instance_name>-tfstate`). Must be specified together with `--instance-name`. |
133
+ | `--instance-name TEXT` | DCP instance name (prefix) used to locate the remote Terraform state bucket. Must be specified together with `--project-id`. |
134
+ | `--tf-state-location TEXT` | Exact GCS URI of the Terraform state file (e.g. `gs://bucket/prefix/default.tfstate`). Overrides canonical bucket derivation. |
135
+
136
+ ---
137
+
138
+ ### Available Commands
139
+
140
+ | Command | Description |
141
+ | --- | --- |
142
+ | **`init`** | Scaffolds a localized Terraform deployment directory for the Data Commons Platform on Google Cloud Platform (GCP). |
143
+ | **`init-db`** | Configures database schemas and seeds baseline tables on Cloud Spanner via the Ingestion Helper service. |
144
+ | **`migrate-db`** | Checks and applies pending schema migrations to the Cloud Spanner database. |
145
+ | **`seed-db`** | Seeds or re-applies base geographic entities and schema definitions to Cloud Spanner. |
146
+ | **`ingest start`** | Triggers a Cloud Workflows + Cloud Run background data ingestion pipeline for custom datasets. |
147
+ | **`ingest show-config`**| Displays current background ingestion parameters, service URLs, and Cloud Run job environment variables. |
148
+
149
+ ---
150
+
151
+ ### Command Reference & Examples
152
+
153
+ #### `datacommons admin init`
154
+ Scaffolds a new deployment directory containing `main.tf`, `terraform.tfvars`, and a deployment README.
155
+
156
+ ```bash
157
+ datacommons admin init --project-id my-gcp-project --instance-name my-instance
158
+ ```
159
+
160
+ Key Options:
161
+ - `--project-id TEXT`: GCP project ID for platform resources.
162
+ - `--instance-name TEXT`: Instance name prefix for provisioned resources (also accepts `--namespace` for backward compatibility).
163
+ - `--dc-api-key TEXT`: Data Commons API key.
164
+ - `--tf-remote-state / --no-tf-remote-state`: Enable/disable remote state management in GCS (default: enabled).
165
+ - `--tf-state-bucket TEXT`: Custom GCS bucket name for Terraform state (defaults to `<project_id>-<instance_name>-tfstate`).
166
+ - `--force`: Overwrite existing files in the target directory if present.
167
+
168
+ #### `datacommons admin init-db`
169
+ Initializes database schema, applies all migrations, and seeds baseline geographic data on Cloud Spanner. If the database has already been initialized, the command safely detects it and prompts you to use `migrate-db` or `seed-db`.
170
+
171
+ ```bash
172
+ # Local state mode:
173
+ datacommons admin init-db
174
+
175
+ # Remote state mode:
176
+ datacommons admin --project-id my-project --instance-name my-instance init-db
177
+
178
+ # Initialize schemas and migrations only (skip baseline data seeding):
179
+ datacommons admin init-db --init-only
180
+ ```
181
+
182
+ #### `datacommons admin migrate-db`
183
+ Inspects pending Spanner schema migrations and applies them sequentially using distributed locks.
184
+
185
+ ```bash
186
+ # Interactive mode (prompts before applying pending migrations):
187
+ datacommons admin migrate-db
188
+
189
+ # Non-interactive / CI/CD mode (auto-approves pending migrations):
190
+ datacommons admin --project-id my-project --instance-name my-instance migrate-db -y
191
+ ```
192
+
193
+ Key Options:
194
+ - `-y`, `--yes`: Automatically confirm and apply pending migrations without interactive prompts.
195
+
196
+ #### `datacommons admin seed-db`
197
+ Seeds baseline geographic nodes and schema mappings on Cloud Spanner via the Ingestion Helper service.
198
+
199
+ ```bash
200
+ datacommons admin seed-db
201
+ # Or via remote state:
202
+ datacommons admin --project-id my-project --instance-name my-instance seed-db
203
+ ```
204
+
205
+ #### `datacommons admin ingest start`
206
+ Triggers an asynchronous data ingestion workflow using Google Cloud Workflows and Cloud Run. Prints the execution ID and a direct Google Cloud Console link for live monitoring.
207
+
208
+ ```bash
209
+ datacommons admin ingest start --imports <import_name>
210
+ # Or via remote state:
211
+ datacommons admin --project-id my-project --instance-name my-instance ingest start --imports un_sdg
212
+ ```
213
+
214
+ Key Options:
215
+ - `--imports TEXT` *(required)*: Comma-separated names of the configured imports to run.
216
+
217
+ #### `datacommons admin ingest show-config`
218
+ Fetches and inspects the active environment variables and configuration for the Cloud Run ingestion job.
219
+
220
+ ```bash
221
+ datacommons admin ingest show-config
222
+ # Or via remote state:
223
+ datacommons admin --project-id my-project --instance-name my-instance ingest show-config
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Data Commons CLI Cheatsheet
229
+
230
+ ### Quickstart Workflow
231
+ ```bash
232
+ # 1. Scaffold Terraform configuration
233
+ datacommons admin init --project-id my-project --instance-name prod
234
+
235
+ # 2. Deploy infrastructure
236
+ cd prod
237
+ terraform init
238
+ terraform apply
239
+
240
+ # 3. Initialize database & seed baseline data
241
+ datacommons admin init-db
242
+
243
+ # 4. Trigger data ingestion
244
+ datacommons admin ingest start --imports my_import
245
+ ```
246
+
247
+ ### Remote / CI/CD Operations Cheatsheet
248
+ ```bash
249
+ # Run migrations non-interactively without local Terraform files
250
+ datacommons admin --project-id my-project --instance-name prod migrate-db -y
251
+
252
+ # Re-seed Spanner database from anywhere
253
+ datacommons admin --project-id my-project --instance-name prod seed-db
254
+
255
+ # Trigger ingestion using an explicit GCS state URI
256
+ datacommons admin --tf-state-location gs://my-project-prod-tfstate/terraform/state/prod/default.tfstate ingest start --imports my_dataset
257
+
258
+ # Inspect ingestion job configuration
259
+ datacommons admin --project-id my-project --instance-name prod ingest show-config
260
+ ```
261
+
262
+ ---
263
+
264
+ License: [Apache-2.0](https://github.com/datacommonsorg/datacommons/blob/main/LICENSE)
@@ -0,0 +1,2 @@
1
+ click>=8.1.7
2
+ datacommons-admin==1.1.5
@@ -10,7 +10,7 @@ keywords = []
10
10
  authors = []
11
11
  dependencies = [
12
12
  "click>=8.1.7",
13
- "datacommons-admin==1.1.4",
13
+ "datacommons-admin==1.1.5",
14
14
  ]
15
15
  urls = {Homepage = "https://github.com/datacommonsorg/datacommons"}
16
16
 
@@ -1,132 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: datacommons-cli
3
- Version: 1.1.4
4
- Summary: Data Commons CLI
5
- License-Expression: Apache-2.0
6
- Project-URL: Homepage, https://github.com/datacommonsorg/datacommons
7
- Requires-Python: >=3.11
8
- Description-Content-Type: text/markdown
9
- Requires-Dist: click>=8.1.7
10
- Requires-Dist: datacommons-admin==1.1.4
11
-
12
- # Data Commons CLI
13
-
14
- <p align="center">
15
- <a href="https://www.datacommons.org"><img src="https://datacommons.org/images/dc-logo.svg" alt="Data Commons" width="120"></a>
16
- </p>
17
-
18
- <p align="center">
19
- <em>Standard command-line interface for interacting with, deploying, and administering the Data Commons Platform.</em>
20
- </p>
21
-
22
- ---
23
-
24
- [Data Commons](https://www.datacommons.org) is an open-source project initiated by Google that aggregates data from hundreds of public sources, such as the US Census, Eurostat, CDC, and UN, into a unified, standard Knowledge Graph.
25
-
26
- The **Data Commons Platform** provides the infrastructure to run your own private instance of Data Commons, allowing you to seamlessly combine public datasets with your own custom, private data using modern APIs, graph query engines, and visualization dashboards.
27
-
28
- ---
29
-
30
- ## Installation
31
-
32
- Install the Data Commons CLI using `pip` or `uv`:
33
-
34
- ### Install with `pip`
35
-
36
- ```bash
37
- pip install --user datacommons-cli
38
- ```
39
-
40
- If the datacommons command is not found after installing, add Python's user-binary directory to your PATH:
41
-
42
- ```
43
- export PATH="$PATH:$(python3 -m site --user-base)/bin"
44
- ```
45
-
46
- ### Install with `uv`
47
-
48
- ```bash
49
- uv tool install datacommons-cli
50
- ```
51
-
52
- If the `datacommons` command is not found after installing, add the appropriate directory to your PATH:
53
-
54
- ```
55
- export PATH="~/.local/bin:$PATH"
56
- ```
57
-
58
- ### With `uvx`
59
-
60
- Or execute `datacommons-cli` on-the-fly without installation using `uvx`:
61
-
62
- ```bash
63
- uvx datacommons-cli --help
64
- ```
65
-
66
- ## Help & Documentation
67
-
68
- For full documentation, tutorials, and deployment guides, visit:
69
- 👉 **[docs.datacommons.org](https://docs.datacommons.org)**
70
-
71
- ---
72
-
73
- ## Usage
74
-
75
- The CLI exposes standard operations under the main `datacommons` entrypoint. You can check the version and get help instantly:
76
-
77
- ```bash
78
- # Show help menu
79
- datacommons --help
80
-
81
- # Show version
82
- datacommons --version
83
- ```
84
-
85
- ---
86
-
87
- ## Administrative Commands
88
-
89
- All infrastructure setup, database operations, and ingestion pipelines are managed under the `admin` sub-command group:
90
-
91
- ```bash
92
- datacommons admin [COMMAND] --help
93
- ```
94
-
95
- ### Available Commands
96
-
97
- | Command | Description |
98
- | --- | --- |
99
- | **`init`** | Scaffolds a localized Terraform configuration to deploy the Data Commons Platform on Google Cloud Platform (GCP). |
100
- | **`init-db`** | Configures database schemas and seeds baseline tables on GCP Spanner via the Ingestion Helper service. |
101
- | **`seed-db`** | Re-runs or updates base geographic and schema seeds on GCP Spanner. |
102
- | **`ingest start`** | Triggers a Cloud Run + Cloud Workflows background data ingestion pipeline to import your custom datasets. |
103
- | **`ingest show-config`**| Prints current background ingestion parameters, GCS bucket paths, and active GCP credentials. |
104
-
105
- ### Quickstart: Scaffolding a Private Data Commons
106
-
107
- 1. Initialize your project configuration and scaffold Terraform templates:
108
- ```bash
109
- datacommons admin init --project-id my-gcp-project --instance-name prod
110
- ```
111
-
112
- 2. Change directories to the scaffolded directory (e.g. `cd prod`).
113
-
114
- 3. Initialize and deploy your GCP infrastructure with Terraform:
115
- ```bash
116
- terraform init
117
- terraform apply
118
- ```
119
-
120
- 4. Initialize and seed your Spanner database:
121
- ```bash
122
- datacommons admin init-db
123
- ```
124
-
125
- 5. Trigger the data ingestion pipeline:
126
- ```bash
127
- datacommons admin ingest start --imports <import_name>
128
- ```
129
-
130
- ---
131
-
132
- License: [Apache-2.0](https://github.com/datacommonsorg/datacommons/blob/main/LICENSE)
@@ -1,121 +0,0 @@
1
- # Data Commons CLI
2
-
3
- <p align="center">
4
- <a href="https://www.datacommons.org"><img src="https://datacommons.org/images/dc-logo.svg" alt="Data Commons" width="120"></a>
5
- </p>
6
-
7
- <p align="center">
8
- <em>Standard command-line interface for interacting with, deploying, and administering the Data Commons Platform.</em>
9
- </p>
10
-
11
- ---
12
-
13
- [Data Commons](https://www.datacommons.org) is an open-source project initiated by Google that aggregates data from hundreds of public sources, such as the US Census, Eurostat, CDC, and UN, into a unified, standard Knowledge Graph.
14
-
15
- The **Data Commons Platform** provides the infrastructure to run your own private instance of Data Commons, allowing you to seamlessly combine public datasets with your own custom, private data using modern APIs, graph query engines, and visualization dashboards.
16
-
17
- ---
18
-
19
- ## Installation
20
-
21
- Install the Data Commons CLI using `pip` or `uv`:
22
-
23
- ### Install with `pip`
24
-
25
- ```bash
26
- pip install --user datacommons-cli
27
- ```
28
-
29
- If the datacommons command is not found after installing, add Python's user-binary directory to your PATH:
30
-
31
- ```
32
- export PATH="$PATH:$(python3 -m site --user-base)/bin"
33
- ```
34
-
35
- ### Install with `uv`
36
-
37
- ```bash
38
- uv tool install datacommons-cli
39
- ```
40
-
41
- If the `datacommons` command is not found after installing, add the appropriate directory to your PATH:
42
-
43
- ```
44
- export PATH="~/.local/bin:$PATH"
45
- ```
46
-
47
- ### With `uvx`
48
-
49
- Or execute `datacommons-cli` on-the-fly without installation using `uvx`:
50
-
51
- ```bash
52
- uvx datacommons-cli --help
53
- ```
54
-
55
- ## Help & Documentation
56
-
57
- For full documentation, tutorials, and deployment guides, visit:
58
- 👉 **[docs.datacommons.org](https://docs.datacommons.org)**
59
-
60
- ---
61
-
62
- ## Usage
63
-
64
- The CLI exposes standard operations under the main `datacommons` entrypoint. You can check the version and get help instantly:
65
-
66
- ```bash
67
- # Show help menu
68
- datacommons --help
69
-
70
- # Show version
71
- datacommons --version
72
- ```
73
-
74
- ---
75
-
76
- ## Administrative Commands
77
-
78
- All infrastructure setup, database operations, and ingestion pipelines are managed under the `admin` sub-command group:
79
-
80
- ```bash
81
- datacommons admin [COMMAND] --help
82
- ```
83
-
84
- ### Available Commands
85
-
86
- | Command | Description |
87
- | --- | --- |
88
- | **`init`** | Scaffolds a localized Terraform configuration to deploy the Data Commons Platform on Google Cloud Platform (GCP). |
89
- | **`init-db`** | Configures database schemas and seeds baseline tables on GCP Spanner via the Ingestion Helper service. |
90
- | **`seed-db`** | Re-runs or updates base geographic and schema seeds on GCP Spanner. |
91
- | **`ingest start`** | Triggers a Cloud Run + Cloud Workflows background data ingestion pipeline to import your custom datasets. |
92
- | **`ingest show-config`**| Prints current background ingestion parameters, GCS bucket paths, and active GCP credentials. |
93
-
94
- ### Quickstart: Scaffolding a Private Data Commons
95
-
96
- 1. Initialize your project configuration and scaffold Terraform templates:
97
- ```bash
98
- datacommons admin init --project-id my-gcp-project --instance-name prod
99
- ```
100
-
101
- 2. Change directories to the scaffolded directory (e.g. `cd prod`).
102
-
103
- 3. Initialize and deploy your GCP infrastructure with Terraform:
104
- ```bash
105
- terraform init
106
- terraform apply
107
- ```
108
-
109
- 4. Initialize and seed your Spanner database:
110
- ```bash
111
- datacommons admin init-db
112
- ```
113
-
114
- 5. Trigger the data ingestion pipeline:
115
- ```bash
116
- datacommons admin ingest start --imports <import_name>
117
- ```
118
-
119
- ---
120
-
121
- License: [Apache-2.0](https://github.com/datacommonsorg/datacommons/blob/main/LICENSE)
@@ -1 +0,0 @@
1
- 1.1.4
@@ -1,132 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: datacommons-cli
3
- Version: 1.1.4
4
- Summary: Data Commons CLI
5
- License-Expression: Apache-2.0
6
- Project-URL: Homepage, https://github.com/datacommonsorg/datacommons
7
- Requires-Python: >=3.11
8
- Description-Content-Type: text/markdown
9
- Requires-Dist: click>=8.1.7
10
- Requires-Dist: datacommons-admin==1.1.4
11
-
12
- # Data Commons CLI
13
-
14
- <p align="center">
15
- <a href="https://www.datacommons.org"><img src="https://datacommons.org/images/dc-logo.svg" alt="Data Commons" width="120"></a>
16
- </p>
17
-
18
- <p align="center">
19
- <em>Standard command-line interface for interacting with, deploying, and administering the Data Commons Platform.</em>
20
- </p>
21
-
22
- ---
23
-
24
- [Data Commons](https://www.datacommons.org) is an open-source project initiated by Google that aggregates data from hundreds of public sources, such as the US Census, Eurostat, CDC, and UN, into a unified, standard Knowledge Graph.
25
-
26
- The **Data Commons Platform** provides the infrastructure to run your own private instance of Data Commons, allowing you to seamlessly combine public datasets with your own custom, private data using modern APIs, graph query engines, and visualization dashboards.
27
-
28
- ---
29
-
30
- ## Installation
31
-
32
- Install the Data Commons CLI using `pip` or `uv`:
33
-
34
- ### Install with `pip`
35
-
36
- ```bash
37
- pip install --user datacommons-cli
38
- ```
39
-
40
- If the datacommons command is not found after installing, add Python's user-binary directory to your PATH:
41
-
42
- ```
43
- export PATH="$PATH:$(python3 -m site --user-base)/bin"
44
- ```
45
-
46
- ### Install with `uv`
47
-
48
- ```bash
49
- uv tool install datacommons-cli
50
- ```
51
-
52
- If the `datacommons` command is not found after installing, add the appropriate directory to your PATH:
53
-
54
- ```
55
- export PATH="~/.local/bin:$PATH"
56
- ```
57
-
58
- ### With `uvx`
59
-
60
- Or execute `datacommons-cli` on-the-fly without installation using `uvx`:
61
-
62
- ```bash
63
- uvx datacommons-cli --help
64
- ```
65
-
66
- ## Help & Documentation
67
-
68
- For full documentation, tutorials, and deployment guides, visit:
69
- 👉 **[docs.datacommons.org](https://docs.datacommons.org)**
70
-
71
- ---
72
-
73
- ## Usage
74
-
75
- The CLI exposes standard operations under the main `datacommons` entrypoint. You can check the version and get help instantly:
76
-
77
- ```bash
78
- # Show help menu
79
- datacommons --help
80
-
81
- # Show version
82
- datacommons --version
83
- ```
84
-
85
- ---
86
-
87
- ## Administrative Commands
88
-
89
- All infrastructure setup, database operations, and ingestion pipelines are managed under the `admin` sub-command group:
90
-
91
- ```bash
92
- datacommons admin [COMMAND] --help
93
- ```
94
-
95
- ### Available Commands
96
-
97
- | Command | Description |
98
- | --- | --- |
99
- | **`init`** | Scaffolds a localized Terraform configuration to deploy the Data Commons Platform on Google Cloud Platform (GCP). |
100
- | **`init-db`** | Configures database schemas and seeds baseline tables on GCP Spanner via the Ingestion Helper service. |
101
- | **`seed-db`** | Re-runs or updates base geographic and schema seeds on GCP Spanner. |
102
- | **`ingest start`** | Triggers a Cloud Run + Cloud Workflows background data ingestion pipeline to import your custom datasets. |
103
- | **`ingest show-config`**| Prints current background ingestion parameters, GCS bucket paths, and active GCP credentials. |
104
-
105
- ### Quickstart: Scaffolding a Private Data Commons
106
-
107
- 1. Initialize your project configuration and scaffold Terraform templates:
108
- ```bash
109
- datacommons admin init --project-id my-gcp-project --instance-name prod
110
- ```
111
-
112
- 2. Change directories to the scaffolded directory (e.g. `cd prod`).
113
-
114
- 3. Initialize and deploy your GCP infrastructure with Terraform:
115
- ```bash
116
- terraform init
117
- terraform apply
118
- ```
119
-
120
- 4. Initialize and seed your Spanner database:
121
- ```bash
122
- datacommons admin init-db
123
- ```
124
-
125
- 5. Trigger the data ingestion pipeline:
126
- ```bash
127
- datacommons admin ingest start --imports <import_name>
128
- ```
129
-
130
- ---
131
-
132
- License: [Apache-2.0](https://github.com/datacommonsorg/datacommons/blob/main/LICENSE)
@@ -1,2 +0,0 @@
1
- click>=8.1.7
2
- datacommons-admin==1.1.4