Metadata-Version: 2.5
Name: ds-fetch-cli
Version: 1.1.0
Summary: aic-fetch: the command line for AI Commons Fetch. SQL and natural-language queries over your data lake.
Project-URL: Homepage, https://aic-project.com
Project-URL: Documentation, https://grasp-labs.github.io/ds-fetch-py-sdk/
Project-URL: Repository, https://github.com/grasp-labs/ds-fetch-py-sdk/
Project-URL: Issues, https://github.com/grasp-labs/ds-fetch-py-sdk/issues/
Project-URL: Changelog, https://github.com/grasp-labs/ds-fetch-py-sdk/releases
Author-email: AI Commons <hello@grasplabs.com>
Maintainer-email: AI Commons <hello@grasplabs.com>
License-Expression: Apache-2.0
License-File: LICENSE-APACHE
Keywords: ai-commons,aic,cli,data-lake,fetch,sql,text-to-sql
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Database
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: ds-fetch-py-sdk==1.1.0
Requires-Dist: rich<15.0.0,>=13.7
Requires-Dist: typer<1.0.0,>=0.12
Description-Content-Type: text/markdown

# ds-fetch-cli

`aic-fetch`: the command line for [AI Commons](https://aic-project.com) Fetch. Run SQL and
natural-language queries over your tenant's data lake from the terminal. Built on
[ds-fetch-py-sdk](https://pypi.org/project/ds-fetch-py-sdk/).

```bash
uv tool install ds-fetch-cli    # or: pipx install ds-fetch-cli
aic-fetch --install-completion  # optional: tab completion for your shell
```

## Usage

```bash
aic-fetch -e dev login                       # browser sign-in, including SSO
aic-fetch -e dev login --email me@aic.no     # email and password; prompts for MFA if enabled
aic-fetch -e dev datasets                    # what you can query, with files, rows and size
aic-fetch -e dev datasets -n gold.5003105c-8a84-5f77-ab74-5e57003112b8   # only these datasets
aic-fetch -e dev datasets -l silver -l bronze  # only these layers
aic-fetch -e dev dataset gold.5003105c-8a84-5f77-ab74-5e57003112b8
aic-fetch -e dev query 'SELECT department, count(*) FROM gold."5003105c-8a84-5f77-ab74-5e57003112b8" GROUP BY 1'
aic-fetch -e dev query - < report.sql        # SQL from a file or pipe
aic-fetch -e dev validate - < report.sql     # check the SQL without reading any data
aic-fetch -e dev ask "Headcount per department?" -d gold.5003105c-8a84-5f77-ab74-5e57003112b8
aic-fetch -e dev ask "Headcount per department?" --sql-only
aic-fetch -e dev tools                       # ds-tools you can invoke
aic-fetch -e local health
aic-fetch -e dev logout
```


| Option        | Effect                                                                                                                                                      |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `-e`, `--env` | `local`, `dev` or `prod`. Default: `$AIC_ENV`, then `prod`                                                                                                  |
| `--json`      | JSON on stdout for scripts, e.g. `aic-fetch --json query '…' | jq`                                                                                          |
| `--fresh`     | On `datasets`, `dataset`, `query`, `validate`, `ask`: read S3 directly, bypassing the index and cache. Default: `$AIC_FRESH`. Needed locally without `ds-fetch-indexer` |
| `--version`   | CLI and SDK versions                                                                                                                                        |


Tables go to stdout; progress, the generated SQL and row counts go to stderr, so output pipes
cleanly. Errors print one line and exit with code 1. Text from the service and the data lake is
shown literally, with control characters replaced, so data cannot drive your terminal.

## Credentials

The CLI uses the first of these it finds:

1. `AIC_TOKEN`: a platform JWT.
2. `AIC_CLIENT_ID` and `AIC_CLIENT_SECRET`: client credentials, for CI and machines.
3. `AIC_EMAIL` and `AIC_PASSWORD` (plus `AIC_MFA_CODE`): email and password sign-in.
4. The session from `aic-fetch login`, cached in `~/.config/aic/credentials.json`.

`local` and `dev` sign in at `https://auth-dev.grasp-daas.com`, `prod` at `https://auth.grasp-daas.com`.

`AIC_FETCH_URL`, `AIC_TOOLS_URL` and `AIC_ISSUER` override single URLs of the chosen environment.

## License

Apache 2.0