Skip to content

Commit e137f04

Browse files
committed
proper account detection
1 parent 69e53a7 commit e137f04

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

eval_protocol/auth.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,18 @@ def get_fireworks_account_id() -> Optional[str]:
200200
if account_id_from_file:
201201
return account_id_from_file
202202

203-
logger.debug("Fireworks Account ID not found in environment variables or auth.ini.")
203+
# 3) Fallback: if API key is present, attempt to resolve via verifyApiKey
204+
try:
205+
api_key_for_verify = get_fireworks_api_key()
206+
if api_key_for_verify:
207+
resolved = verify_api_key_and_get_account_id(api_key=api_key_for_verify, api_base=get_fireworks_api_base())
208+
if resolved:
209+
logger.debug("Using FIREWORKS_ACCOUNT_ID resolved via verifyApiKey: %s", resolved)
210+
return resolved
211+
except Exception as e:
212+
logger.debug("Failed to resolve FIREWORKS_ACCOUNT_ID via verifyApiKey: %s", e)
213+
214+
logger.debug("Fireworks Account ID not found in environment variables, auth.ini, or via verifyApiKey.")
204215
return None
205216

206217

eval_protocol/evaluation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,9 @@ def _ensure_requirements_present(source_dir: str) -> None:
595595
logger.error("Missing requirements.txt in upload directory: %s", source_dir)
596596
raise ValueError(
597597
"Upload requires requirements.txt in the project root. "
598-
"Please add requirements.txt and re-run ep upload."
598+
"Create a requirements.txt (it can be empty) and rerun 'eval-protocol upload' "
599+
"or 'eval-protocol create rft'. If you're running in a notebook (e.g., Colab), "
600+
f"create the file in your working directory (e.g., {source_dir}/requirements.txt)."
599601
)
600602

601603
@staticmethod

eval_protocol/pytest/handle_persist_flow.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
from eval_protocol.directory_utils import find_eval_protocol_dir
1212
from eval_protocol.models import EvaluationRow
1313
from eval_protocol.pytest.store_experiment_link import store_experiment_link
14+
from eval_protocol.auth import (
15+
get_fireworks_api_key,
16+
get_fireworks_account_id,
17+
verify_api_key_and_get_account_id,
18+
get_fireworks_api_base,
19+
)
1420

1521
import requests
1622

@@ -90,22 +96,16 @@ def handle_persist_flow(all_results: list[list[EvaluationRow]], test_func_name:
9096
if not should_upload:
9197
continue
9298

93-
def get_auth_value(key: str) -> str | None:
94-
"""Get auth value from config file or environment."""
99+
# Resolve credentials using centralized auth helpers with verification fallback
100+
fireworks_api_key = get_fireworks_api_key()
101+
fireworks_account_id = get_fireworks_account_id()
102+
if not fireworks_account_id and fireworks_api_key:
95103
try:
96-
config_path = Path.home() / ".fireworks" / "auth.ini"
97-
if config_path.exists():
98-
config = configparser.ConfigParser() # noqa: F821
99-
config.read(config_path)
100-
for section in ["DEFAULT", "auth"]:
101-
if config.has_section(section) and config.has_option(section, key):
102-
return config.get(section, key)
104+
fireworks_account_id = verify_api_key_and_get_account_id(
105+
api_key=fireworks_api_key, api_base=get_fireworks_api_base()
106+
)
103107
except Exception:
104-
pass
105-
return os.getenv(key)
106-
107-
fireworks_api_key = get_auth_value("FIREWORKS_API_KEY")
108-
fireworks_account_id = get_auth_value("FIREWORKS_ACCOUNT_ID")
108+
fireworks_account_id = None
109109

110110
if not fireworks_api_key and not fireworks_account_id:
111111
store_experiment_link(
@@ -129,7 +129,7 @@ def get_auth_value(key: str) -> str | None:
129129
)
130130
continue
131131

132-
api_base = "https://api.fireworks.ai"
132+
api_base = get_fireworks_api_base()
133133
headers = {
134134
"Authorization": f"Bearer {fireworks_api_key}",
135135
"Content-Type": "application/json",

0 commit comments

Comments
 (0)