feat: multi-profile support and project discovery#17
feat: multi-profile support and project discovery#17rahim-bhojani wants to merge 3 commits intomainfrom
Conversation
Make `dremio reflection list` work without a dataset path — queries sys.project.reflections with no WHERE filter. Add --limit/-l flag to cap result size for large projects. Closes #10 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address review feedback — support filtering reflections by type (raw/aggregation), status (CAN_ACCELERATE, FAILED, etc.), and dataset name (substring match via ILIKE). All filters compose with each other and with the existing path argument and --limit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Users working across multiple Dremio Cloud orgs/projects no longer need to re-run setup or juggle env vars. The config file now supports named profiles, and the setup wizard discovers projects automatically via the API instead of requiring manual ID entry. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cb49fe0871
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| profiles = raw.get("profiles", {}) | ||
| if profile_name not in profiles: | ||
| raise ValueError(f"Profile '{profile_name}' not found in config") |
There was a problem hiding this comment.
Handle implicit default profile in set_default_profile
set_default_profile only checks the explicit profiles map, so legacy flat configs (which the same module treats as an implicit default profile) always raise “Profile not found”. This makes dremio context use default fail for valid legacy configs even though context list/context current expose default, which breaks the advertised backward-compatibility path for profile management.
Useful? React with 👍 / 👎.
|
|
||
| # Read existing config for profile awareness | ||
| existing_raw = read_config_file(config_path) | ||
| existing_profiles = existing_raw.get("profiles", {}) |
There was a problem hiding this comment.
Include legacy default in setup overwrite checks
Setup computes existing_profiles only from the raw profiles key, so legacy flat configs are treated as having no existing profile names during the prompt. If the user chooses default (or accepts it when slug fallback yields that), write_profile first migrates legacy credentials into profiles.default and then silently overwrites them with the new profile without any overwrite confirmation, causing unintended credential loss.
Useful? React with 👍 / 👎.
| if status is not None: | ||
| conditions.append(f"status = '{status.upper()}'") | ||
| if dataset_name is not None: | ||
| conditions.append(f"dataset_name ILIKE '%{dataset_name}%'") |
There was a problem hiding this comment.
Escape dataset-name filter before SQL interpolation
The --dataset-name value is interpolated directly into a quoted SQL literal without escaping. Inputs containing a single quote (for example O'Reilly) generate invalid SQL and cause reflection list to fail, even though this flag is intended for free-form substring matching.
Useful? React with 👍 / 👎.
Multi-Profile Support for Dremio CLI
Problem
The Dremio CLI currently supports a single configured context — one PAT, one project ID, one region — stored in
~/.config/dremioai/config.yaml. Users who work across multiple organizations or projects must either:dremio setupeach time they switch, which overwrites their existing configDREMIO_TOKEN,DREMIO_PROJECT_ID)--config /path/to/other.yamlon every invocationThe setup experience is also unnecessarily manual — users must copy-paste a project ID from the UI when the CLI could discover available projects automatically.
Proposed Solution
Mirror the Dremio Cloud UI flow: authenticate, discover projects, and let the user choose — then persist the result as a named profile.
Setup flow (interactive):
Running
dremio setupagain adds another profile without overwriting existing ones. Users with multiple orgs run setup once per org (each org has its own PAT).Config format:
Profile switching:
Resolution order (unchanged in spirit): CLI flags (
--token, etc.) > env vars > named profile > default profile.Backwards compatible: Existing flat config files (no
profileskey) are treated as an implicitdefaultprofile. No migration required.What Changed
auth.pyload_config()gainsprofileparam, readsprofilesdict,DREMIO_PROFILEenv var, helper functions for listing/switching profilessetup.pylist_projectsafter PAT auth), additive profile writes, profile naming with slug suggestioncli.py--profile/-pglobal option, registerscontextcommand groupcommands/context.pylist,use,currentsubcommands for profile managementclient.pyDrsConfigas beforeOpen Questions
list_projectsresponse may include org metadata we can display. Need to verify the response shape.Test plan
--profile>DREMIO_PROFILEenv >default_profilein filedremio setupagainst a real Dremio Cloud accountdremio context list/use/currentworkflow🤖 Generated with Claude Code