CLI refactor#230
Open
echarles wants to merge 35 commits into
Open
Conversation
❌ Deploy Preview for datalayer-core failed.
|
There was a problem hiding this comment.
Pull request overview
This PR refactors “tokens” into “API keys” across the TypeScript UI/client and the Python client/CLI, while also introducing new scheduler functionality (API + UI menu + CLI) and some shared UI/time utilities.
Changes:
- Replace IAM “tokens” endpoints/types/docs/UI with “API keys” equivalents (including new variants like
secret,publishable, etc.). - Add scheduler support: API module (
/api/scheduler/v1), ReactScheduleMenucomponent, and aschedulesCLI command. - Add shared utilities/components (Logger, Timeline, enhanced relative time + tooltips) and update CLI/console terminology from “runtime” to “agent”.
Reviewed changes
Copilot reviewed 94 out of 100 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/views/iam-tokens/Tokens.tsx | Removed legacy tokens view. |
| src/views/iam-tokens/IAMTokens.tsx | Removed legacy IAMTokens component. |
| src/views/api-keys/index.ts | Adds API-keys view barrel exports. |
| src/views/api-keys/APIKeysStandalone.tsx | New standalone API keys list UI with stronger delete confirmation. |
| src/views/api-keys/APIKeys.tsx | New configurable API keys list component. |
| src/views/api-keys/APIKeyNew.tsx | Renames/updates token creation flow to API keys and new variants. |
| src/views/api-keys/APIKeyEdit.tsx | Renames/updates token edit flow to API keys. |
| src/utils/Logger.ts | Adds scoped console logger utility. |
| src/utils/index.ts | Exports Logger utilities. |
| src/utils/Date.ts | Improves relative time formatting + adds tooltip details helper. |
| src/state/substates/CoreState.ts | Updates logger import path. |
| src/models/ProjectDTO.ts | Updates terminology in doc comments. |
| src/models/IAMToken.ts | Expands token variant union to API-key variants. |
| src/hooks/useProjectStore.ts | Updates terminology in doc comments. |
| src/hooks/useProjects.ts | Updates terminology in doc comments. |
| src/hooks/useCache.ts | Switches IAM token endpoints to /api-keys and normalizes response payloads. |
| src/components/timeline/Timeline.tsx | Adds new horizontal timeline component. |
| src/components/timeline/index.ts | Barrel export for timeline components. |
| src/components/time/LiveRelativeTime.tsx | Adds live-updating relative time with optional tooltip details. |
| src/components/time/index.ts | Barrel export for time components. |
| src/components/scheduler/ScheduleMenu.tsx | Adds scheduler menu UI that persists cron schedules. |
| src/components/scheduler/index.ts | Exports ScheduleMenu from scheduler components. |
| src/components/index.ts | Exposes scheduler/time/timeline component modules. |
| src/components/display/LiveRelativeTime.tsx | Keeps backward-compat export via new time component. |
| src/components/checkout/StripeCheckout.tsx | Adds auto-open upgrade behavior + improves cancellation UX copy. |
| src/api/scheduler/schedules.ts | Adds scheduler schedules API helpers. |
| src/api/scheduler/index.ts | Scheduler API barrel export. |
| src/api/runtimes/runtimes.ts | Terminology updates in request typings/comments. |
| src/api/runtimes/checkpoints.ts | Terminology updates in request typings/comments. |
| src/api/index.ts | Exports scheduler API module. |
| src/api/constants.ts | Adds scheduler base path + default service URL. |
| README.md | Updates CLI examples + adds evals multi-agentspec notes. |
| pyproject.toml | Adds dependency + packages templates/static assets. |
| examples/nextjs/src/app/welcome/page.tsx | Updates token language/links to API key equivalents. |
| examples/nextjs/README.md | Updates API token wording + API key link + minor doc edits. |
| docs/docs/python/Tokens/index.mdx | Removes Tokens docs page. |
| docs/docs/python/Tokens/category.yml | Removes Tokens docs category. |
| docs/docs/python/APIKeys/index.mdx | Adds new API keys docs page. |
| docs/docs/python/APIKeys/category.yml | Adds API keys docs category. |
| docs/docs/index.mdx | Replaces docs homepage content with consolidated API entrypoint. |
| datalayer_core/utils/urls.py | Replaces ray_url with scheduler_url and adds URL dict helpers. |
| datalayer_core/utils/notebook.py | Makes notebook cell ID extraction more robust. |
| datalayer_core/tests/test_ray.py | Updates URL resolution tests to runtimes_url. |
| datalayer_core/tests/test_client.py | Updates token tests to API keys list method. |
| datalayer_core/tests/test_cli.py | Updates CLI tests from tokens to api-keys. |
| datalayer_core/tests/test_cli_exec_examples.py | Adds tests for exec example file generators. |
| datalayer_core/templates/index.html | Fixes JSON quoting/commas in embedded config. |
| datalayer_core/sandboxes/code_sandbox_snapshots.py | Moves snapshot helpers into a new sandboxes package. |
| datalayer_core/sandboxes/init.py | Exposes sandbox snapshot helpers. |
| datalayer_core/runtimes/sandbox_snapshot.py | Removes old snapshot helper module. |
| datalayer_core/runtimes/init.py | Removes empty runtimes package init. |
| datalayer_core/models/token.py | Removes legacy TokenModel/TokenType. |
| datalayer_core/models/api_key.py | Adds ApiKeyModel/ApiKeyType. |
| datalayer_core/models/init.py | Exposes ApiKeyModel/ApiKeyType in models package. |
| datalayer_core/mixins/runtimes.py | Adds env-based billable account fallbacks for runtime creation. |
| datalayer_core/mixins/ray.py | Routes Ray mixin through runtimes_url. |
| datalayer_core/mixins/evals.py | Adds billable account uid support + env fallbacks. |
| datalayer_core/mixins/api_keys.py | Adds API key create/list/delete mixins. |
| datalayer_core/mixins/init.py | Swaps TokensMixin for ApiKeysMixin. |
| datalayer_core/evals/evals.py | Adds shared evals helpers (JSON parsing, client factory). |
| datalayer_core/evals/init.py | Adds evals package init. |
| datalayer_core/displays/tokens.py | Removes tokens display table. |
| datalayer_core/displays/runtimes.py | Renames display titles from Runtimes to Agents. |
| datalayer_core/displays/runtime_checkpoints.py | Renames “Agent Spec” label to “Agentspec”. |
| datalayer_core/displays/environments.py | Reworks environment display formatting for richer CLI output. |
| datalayer_core/displays/api_keys.py | Adds API keys display table. |
| datalayer_core/console/manager.py | Refactors console runtime selection/launching and kernel ID handling. |
| datalayer_core/console/consoleapp.py | Renames console alias from runtime to agent. |
| datalayer_core/client/client.py | Migrates to agents/sandboxes modules and adds runtime health probing. |
| datalayer_core/cli/commands/usage.py | Defaults billable account uid from environment variables. |
| datalayer_core/cli/commands/tokens.py | Removes tokens CLI commands. |
| datalayer_core/cli/commands/schedules.py | Adds schedules CLI list command (schedules + runs). |
| datalayer_core/cli/commands/runtimes.py | Removes runtimes CLI commands. |
| datalayer_core/cli/commands/README.md | Updates exec command docs to “sandbox” language + examples. |
| datalayer_core/cli/commands/ray.py | Adds runtimes-url override + improves Ray jobs error UX. |
| datalayer_core/cli/commands/plans.py | Ensures default callback renders plan info + env billable defaults. |
| datalayer_core/cli/commands/envs.py | Avoids metadata key collisions and updates agent wording. |
| datalayer_core/cli/commands/console.py | Renames CLI option --runtime to --agent. |
| datalayer_core/cli/commands/cluster.py | Adds anomaly summary + dynamic panel border style. |
| datalayer_core/cli/commands/checkpoints.py | Renames checkpoint filter option from runtime to agent. |
| datalayer_core/cli/commands/authn.py | Adds --urls output + richer details formatting. |
| datalayer_core/cli/commands/api_keys.py | Adds API keys CLI commands (ls/list/create/delete). |
| datalayer_core/cli/main.py | Adds global overrides (scheduler url, api-key, billable context) + registers new commands. |
| datalayer_core/base/serverapplication.py | Uses pathlib-based template/static paths and includes packaged assets. |
| datalayer_core/agents/utils.py | Updates imports and terminology to new agents modules. |
| datalayer_core/agents/agent_local.py | Adds disable tool approvals support + terminology updates. |
| datalayer_core/agents/agent_cloud.py | Adds api_key alias and imports sandbox snapshot helpers. |
| datalayer_core/agents/init.py | New agents package exports. |
| datalayer_core/version.py | Version bump. |
| CLAUDE.md | Removes repository-specific instructions file. |
Comments suppressed due to low confidence (3)
datalayer_core/mixins/api_keys.py:105
- The exception path returns
{ "sucess": False, ... }(typo), so callers checkingresponse.get('success')won’t see the failure flag. This should use the consistentsuccesskey (and ideallymessagelike the other methods).
src/views/api-keys/APIKeyEdit.tsx:66 formValuesis initialized fromapiKey?.name/apiKey?.description, butapiKeyis undefined on first render. This results in controlled inputs receivingundefinedvalues (React warnings and potential UI bugs). Initialize with empty strings and populate in the queryuseEffect.
src/views/api-keys/APIKeyEdit.tsx:216TextInputfor expiration date usesvalue={apiKey?.expirationDate.toLocaleDateString()}which isundefineduntil the query resolves. For a controlled input, prefer an empty-string fallback to avoid React controlled/uncontrolled warnings.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
119
to
+123
| const weeks = Math.floor(days / 7); | ||
| if (weeks < 52) return `${weeks}w ago`; | ||
| if (weeks < 52) return withDirection(weeks, 'w'); | ||
|
|
||
| const years = Math.floor(days / 365); | ||
| return `${years}y ago`; | ||
| return withDirection(years, 'y'); |
Comment on lines
+1
to
+3
| title: API Keys | ||
| --- | ||
|
|
Comment on lines
+39
to
+47
| client = DatalayerClient() | ||
| token_response = client.create_token( | ||
| name="API_ACCESS_TOKEN", | ||
| description="API key for automated API access" | ||
| ) | ||
|
|
||
| print(f"API key created: {token_response['name']}") | ||
| print(f"API key value: {token_response['token']}") # Store securely! | ||
| print(f"API key UID: {token_response['uid']}") |
Comment on lines
+58
to
+70
| client = DatalayerClient() | ||
|
|
||
| # Create API key that expires in 30 days | ||
| expiration_timestamp = int(time.time()) + (30 * 24 * 60 * 60) # 30 days from now | ||
|
|
||
| token_response = client.create_token( | ||
| name="TEMPORARY_ACCESS_TOKEN", | ||
| description="30-day temporary access API key", | ||
| expiration_date=expiration_timestamp | ||
| ) | ||
|
|
||
| print(f"API key created with expiration: {token_response['name']}") | ||
| print(f"Expires at: {time.ctime(expiration_timestamp)}") |
Comment on lines
+81
to
+90
| client = DatalayerClient() | ||
|
|
||
| # Create secret API key (default type) | ||
| user_token = client.create_token( | ||
| name="USER_API_TOKEN", | ||
| description="User API access key", | ||
| token_type=ApiKeyType.SECRET | ||
| ) | ||
|
|
||
| print(f"Created {user_token['type']} API key: {user_token['name']}") |
Comment on lines
+122
to
+133
| def find_tokens(client, search_term): | ||
| """Find API keys by name or description.""" | ||
| all_tokens = client.list_tokens() | ||
| matching_tokens = [] | ||
|
|
||
| for token in all_tokens: | ||
| if (search_term.lower() in token.name.lower() or | ||
| search_term.lower() in token.description.lower()): | ||
| matching_tokens.append(token) | ||
|
|
||
| return matching_tokens | ||
| ``` |
Comment on lines
+146
to
+155
| # Delete by UID | ||
| success = client.delete_token("token-uid-12345") | ||
| print(f"API key deletion successful: {success}") | ||
|
|
||
| # Delete by Token object | ||
| tokens = client.list_tokens() | ||
| if tokens: | ||
| old_token = tokens[0] # Delete the first API key | ||
| success = client.delete_token(old_token) | ||
| print(f"Deleted API key '{old_token.name}': {success}") |
|
|
||
| - View all available compute environments | ||
| - See environment specifications (language, description) | ||
| - See environmentspecifications (language, description) |
Comment on lines
+7
to
+23
| from datalayer_core.agents.agent_local import ( | ||
| DEFAULT_LOCAL_AGENT_NAME, | ||
| DEFAULT_LOCAL_HOST, | ||
| DEFAULT_LOCAL_LOG_LEVEL, | ||
| DEFAULT_LOCAL_PROTOCOL, | ||
| LocalAgentRuntime, | ||
| ensure_local_agent, | ||
| start_local_agent_runtime, | ||
| terminate_local_agent_runtime, | ||
| ) | ||
| from datalayer_core.agents.utils import ( | ||
| compute_time_reservation_minutes, | ||
| create_cloud_agent_runtime, | ||
| resolve_environment_burning_rate, | ||
| teardown_agent_execution_resources, | ||
| terminate_cloud_agent_runtime, | ||
| ) |
Comment on lines
+25
to
+40
| __all__ = [ | ||
| "RuntimeService", | ||
| "LocalAgentRuntime", | ||
| "DEFAULT_LOCAL_AGENT_NAME", | ||
| "DEFAULT_LOCAL_HOST", | ||
| "DEFAULT_LOCAL_LOG_LEVEL", | ||
| "DEFAULT_LOCAL_PROTOCOL", | ||
| "ensure_local_agent", | ||
| "start_local_agent_runtime", | ||
| "terminate_local_agent_runtime", | ||
| "resolve_environment_burning_rate", | ||
| "compute_time_reservation_minutes", | ||
| "create_cloud_agent_runtime", | ||
| "terminate_cloud_agent_runtime", | ||
| "teardown_agent_execution_resources", | ||
| ] |
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.
No description provided.