feat: Add API client infrastructure and org/project commands#8
Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Open
feat: Add API client infrastructure and org/project commands#8devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
Conversation
…roups - Add new dependencies: httpx, rich, keyring, pydantic, tomli, tomli-w - Add config management (judgment/config.py) with TOML config at ~/.judgment/config.toml - Add shared HTTP client (judgment/api_client.py) with auth and error handling - Add output formatting (judgment/output.py) with rich tables, JSON, styled messages - Add config commands: judgment config set/show/path - Add auth commands: judgment login/logout/whoami - Add org commands: judgment orgs list/show/members/usage - Add project commands: judgment projects list/create/show/favorite/unfavorite - Add global options: --json, --no-color, --org-id, --project-id - Register all new command groups in cli.py while keeping self-host intact Co-Authored-By: abi <abinav_rao@berkeley.edu>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…s, fix org_id context lookup, store API key in keyring on login Co-Authored-By: abi <abinav_rao@berkeley.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
Adds foundational infrastructure for interacting with the Judgment platform REST API, plus organization and project commands as the first reference implementation. New command groups:
config,auth,orgs,projects. Existingself-hostcommands are preserved unchanged.New files:
judgment/api_client.py— Shared HTTP client with auth resolution (env var → keyring → config) and error handlingjudgment/config.py— TOML-based config management at~/.judgment/config.tomljudgment/output.py— Output formatting (rich tables, JSON mode, styled messages)judgment/commands/auth.py—login,logout,whoamijudgment/commands/config_cmd.py—config set,config show,config pathjudgment/commands/orgs.py—orgs list,orgs show,orgs members,orgs usagejudgment/commands/projects.py—projects list,projects create,projects show,projects favorite,projects unfavoriteModified files:
judgment/cli.py— Registers new command groups, adds global--json,--no-color,--org-id,--project-idoptionspyproject.toml— Addshttpx,rich,keyring,pydantic,tomli/tomli-wdependencies🎯 Purpose
Provides the scaffolding so that future CLI command groups (traces, evaluations, scorers, etc.) can be added by following the same pattern: create a Typer sub-app in
judgment/commands/, useJudgmentAPIClientfor HTTP, useoutput.pyhelpers for display.Updates since initial revision
Fixed issues flagged by auto-review:
from __future__ import annotationsto all new modules sodict[str, Any]type hints work on Python 3.8/3.9judgment loginnow stores the API key in both the config file and the system keyring_resolve_org_id()inprojects.pynow correctly walksctx.metaup the context chain instead of using a brokengetattr(ctx, "org_id")sysfromapi_client.pyandOptional/osfromconfig.py🧪 Testing
Manual validation only:
pip install -e .succeedsjudgment --helpshows all five command groups (self-host, config, auth, orgs, projects)judgment config showworks with no config file presentjudgment config pathprints~/.judgment/config.tomljudgment auth --help,judgment orgs --help,judgment projects --helpshow expected subcommandsNo unit tests were added.
✅ Checklist
Key items for human review
httpx.get/post/...instead of using a persistenthttpx.Clientsession. Acceptable for a CLI (one-shot commands), but worth noting for future batch operations.--helpandconfig showchecks. Consider adding tests before merging.config_cmd.py:print_detailis imported but not used.ctx.metafallback:_resolve_org_id()accessescurrent.metawhich could theoretically beNoneon some Typer/Click context objects — verify this doesn't raise on edge cases.📌 Linear Issue
N/A
✏️ Additional Notes
Session Link: https://app.devin.ai/sessions/81260eac71b34b638f85968cb63b0dd0
Requested by: @raoabinav
Future work:
traces,evaluations,scorerscommand groups