-
Notifications
You must be signed in to change notification settings - Fork 16
Implement Evaluator Versions #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 5 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
0a00bcd
Refactor Fireworks client integration
d465a89
remove launch.json
348bb58
Add .vscode/launch.json to .gitignore
acaa901
Enhance environment variable loading in auth module
4b71ddb
Add evaluator version creation in evaluation module
3dbcd59
test
532e071
REVERT this later
5e7a5fa
Merge branch 'main' into dhuang/dxe-478-implement-evaluator-versions
060d72c
fix mock tests
bc31c9f
Add error handling for evaluator creation in evaluation module
ea08062
Support EP_REMOTE_API_KEY
f246087
Merge branch 'main' into dhuang/dxe-478-implement-evaluator-versions
6b53ac1
include launch.json.backup
ec0c8ca
rename to .example and add docker run extra arg
fc036f5
use ignore-docker by default
4566584
delete backup
f103b69
ignore-docker by default in dev
9c3e417
Refactor evaluator function calls to use Fireworks directly for metho…
ea673f4
use in-flight SDK version
26fbc2d
Enhance evaluator handling by returning version ID on creation and up…
4702307
update
9d1bc74
use published a22 of fireworks-ai
3314bec
uv lock
66f191a
Refactor dotenv handling in auth module and integrate environment var…
165afe1
add create rft launch configuration
838c7a5
Refactor dotenv handling in auth module and integrate environment var…
71599e6
Merge branch 'pass-dot-env-to-docker-container' into dhuang/dxe-478-i…
0144c9f
actually not necessary for local test since local-test mounts the wor…
c8774a6
increase sql retries
2076f0a
Refactor dotenv loading to use explicit paths in CLI and API modules
8acdc35
Merge branch 'main' into dhuang/dxe-478-implement-evaluator-versions
432a649
Refactor dotenv loading to use explicit paths in CLI and API modules
ab04086
Merge branch 'ensure-explicit-dotenv' into dhuang/dxe-478-implement-e…
3c2db59
"ep create evj"
17eb18f
use SDK for Dataset API calls
1fd66f7
Implement evaluator upload and status polling in create commands
fc4f913
Add secret management for uploads in CLI
2f88428
handle existing secrets with caution
c6a8c51
Integrate secrets upload handling in CLI commands
a2165fb
Remove unused `_to_pyargs_nodeid` function from `upload.py` to enhanc…
1445d75
increase sql retries
7969a6e
Refactor secret loading in CLI to use python-dotenv
d4a445b
make connection more robust
b3adfee
Merge branch 'increase-sql-retries' into dhuang/dxe-478-implement-eva…
37f4856
passes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -243,3 +243,5 @@ package.json | |
| tau2-bench | ||
| *.err | ||
| eval-protocol | ||
|
|
||
| .vscode/launch.json | ||
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| """ | ||
| Consolidated Fireworks client factory. | ||
|
|
||
| This module provides a single point of instantiation for the Fireworks SDK client, | ||
| ensuring consistent handling of environment variables and configuration across the | ||
| eval_protocol codebase. | ||
|
|
||
| Environment variables: | ||
| FIREWORKS_API_KEY: API key for authentication (required) | ||
| FIREWORKS_ACCOUNT_ID: Account ID (optional, can be derived from API key) | ||
| FIREWORKS_API_BASE: Base URL for the API (default: https://api.fireworks.ai) | ||
| FIREWORKS_EXTRA_HEADERS: JSON-encoded extra headers to include in requests | ||
| Example: '{"X-Custom-Header": "value", "X-Another": "another-value"}' | ||
| """ | ||
|
|
||
| import json | ||
| import logging | ||
| import os | ||
| from typing import Mapping, Optional | ||
|
|
||
| from fireworks import Fireworks | ||
|
|
||
| from eval_protocol.auth import ( | ||
| get_fireworks_account_id, | ||
| get_fireworks_api_base, | ||
| get_fireworks_api_key, | ||
| ) | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def get_fireworks_extra_headers() -> Optional[Mapping[str, str]]: | ||
| """ | ||
| Retrieves extra headers from the FIREWORKS_EXTRA_HEADERS environment variable. | ||
|
|
||
| The value should be a JSON-encoded object mapping header names to values. | ||
| Example: '{"X-Custom-Header": "value"}' | ||
|
|
||
| Returns: | ||
| A mapping of header names to values if set and valid, otherwise None. | ||
| """ | ||
| extra_headers_str = os.environ.get("FIREWORKS_EXTRA_HEADERS") | ||
| if not extra_headers_str or not extra_headers_str.strip(): | ||
| return None | ||
|
|
||
| try: | ||
| headers = json.loads(extra_headers_str) | ||
| if not isinstance(headers, dict): | ||
| logger.warning( | ||
| "FIREWORKS_EXTRA_HEADERS must be a JSON object, got %s. Ignoring.", | ||
| type(headers).__name__, | ||
| ) | ||
| return None | ||
| # Validate all keys and values are strings | ||
| for k, v in headers.items(): | ||
| if not isinstance(k, str) or not isinstance(v, str): | ||
| logger.warning( | ||
| "FIREWORKS_EXTRA_HEADERS contains non-string key or value: %s=%s. Ignoring all extra headers.", | ||
| k, | ||
| v, | ||
| ) | ||
| return None | ||
| logger.debug("Using FIREWORKS_EXTRA_HEADERS: %s", list(headers.keys())) | ||
| return headers | ||
| except json.JSONDecodeError as e: | ||
| logger.warning("Failed to parse FIREWORKS_EXTRA_HEADERS as JSON: %s. Ignoring.", e) | ||
| return None | ||
|
|
||
|
|
||
| def create_fireworks_client( | ||
| *, | ||
| api_key: Optional[str] = None, | ||
| account_id: Optional[str] = None, | ||
| base_url: Optional[str] = None, | ||
| extra_headers: Optional[Mapping[str, str]] = None, | ||
| ) -> Fireworks: | ||
| """ | ||
| Create a Fireworks client with consistent configuration. | ||
|
|
||
| This factory function centralizes the logic for creating Fireworks clients, | ||
| ensuring that environment variables are handled consistently across the codebase. | ||
|
|
||
| Resolution order for each parameter: | ||
| 1. Explicit argument passed to this function | ||
| 2. Environment variable (via auth module helpers) | ||
| 3. SDK defaults (for base_url only) | ||
|
|
||
| Args: | ||
| api_key: Fireworks API key. If not provided, resolves from FIREWORKS_API_KEY. | ||
| account_id: Fireworks account ID. If not provided, resolves from FIREWORKS_ACCOUNT_ID | ||
| or derives from the API key via the verifyApiKey endpoint. | ||
| base_url: Base URL for the Fireworks API. If not provided, resolves from | ||
| FIREWORKS_API_BASE or defaults to https://api.fireworks.ai. | ||
| extra_headers: Additional headers to include in all requests. If not provided, | ||
| resolves from FIREWORKS_EXTRA_HEADERS environment variable (JSON-encoded). | ||
|
|
||
| Returns: | ||
| A configured Fireworks client instance. | ||
|
|
||
| Raises: | ||
| fireworks.FireworksError: If api_key is not provided and FIREWORKS_API_KEY | ||
| environment variable is not set. | ||
| """ | ||
| # Resolve parameters from environment if not explicitly provided | ||
| resolved_api_key = api_key or get_fireworks_api_key() | ||
| resolved_account_id = account_id or get_fireworks_account_id() | ||
| resolved_base_url = base_url or get_fireworks_api_base() | ||
|
|
||
| # Merge extra headers: env var headers first, then explicit headers override | ||
| env_extra_headers = get_fireworks_extra_headers() | ||
| merged_headers: Optional[Mapping[str, str]] = None | ||
| if env_extra_headers or extra_headers: | ||
| merged = {} | ||
| if env_extra_headers: | ||
| merged.update(env_extra_headers) | ||
| if extra_headers: | ||
| merged.update(extra_headers) | ||
| merged_headers = merged if merged else None | ||
|
|
||
| logger.debug( | ||
| "Creating Fireworks client: base_url=%s, account_id=%s, extra_headers=%s", | ||
| resolved_base_url, | ||
| resolved_account_id, | ||
| list(merged_headers.keys()) if merged_headers else None, | ||
| ) | ||
|
|
||
| return Fireworks( | ||
| api_key=resolved_api_key, | ||
| account_id=resolved_account_id, | ||
| base_url=resolved_base_url, | ||
| default_headers=merged_headers, | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.