Add support for W&B dedicated cloud instances in Weave tracing integration (#20765)
Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:

committed by
GitHub

parent
930c4cb609
commit
e6e76852d5
@@ -98,6 +98,7 @@ class WeaveConfig(BaseTracingConfig):
|
|||||||
entity: str | None = None
|
entity: str | None = None
|
||||||
project: str
|
project: str
|
||||||
endpoint: str = "https://trace.wandb.ai"
|
endpoint: str = "https://trace.wandb.ai"
|
||||||
|
host: str | None = None
|
||||||
|
|
||||||
@field_validator("endpoint")
|
@field_validator("endpoint")
|
||||||
@classmethod
|
@classmethod
|
||||||
@@ -109,6 +110,14 @@ class WeaveConfig(BaseTracingConfig):
|
|||||||
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@field_validator("host")
|
||||||
|
@classmethod
|
||||||
|
def validate_host(cls, v, info: ValidationInfo):
|
||||||
|
if v is not None and v != "":
|
||||||
|
if not v.startswith(("https://", "http://")):
|
||||||
|
raise ValueError("host must start with https:// or http://")
|
||||||
|
return v
|
||||||
|
|
||||||
|
|
||||||
OPS_FILE_PATH = "ops_trace/"
|
OPS_FILE_PATH = "ops_trace/"
|
||||||
OPS_TRACE_FAILED_KEY = "FAILED_OPS_TRACE"
|
OPS_TRACE_FAILED_KEY = "FAILED_OPS_TRACE"
|
||||||
|
@@ -81,7 +81,7 @@ class OpsTraceProviderConfigMap(dict[str, dict[str, Any]]):
|
|||||||
return {
|
return {
|
||||||
"config_class": WeaveConfig,
|
"config_class": WeaveConfig,
|
||||||
"secret_keys": ["api_key"],
|
"secret_keys": ["api_key"],
|
||||||
"other_keys": ["project", "entity", "endpoint"],
|
"other_keys": ["project", "entity", "endpoint", "host"],
|
||||||
"trace_instance": WeaveDataTrace,
|
"trace_instance": WeaveDataTrace,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,9 +40,14 @@ class WeaveDataTrace(BaseTraceInstance):
|
|||||||
self.weave_api_key = weave_config.api_key
|
self.weave_api_key = weave_config.api_key
|
||||||
self.project_name = weave_config.project
|
self.project_name = weave_config.project
|
||||||
self.entity = weave_config.entity
|
self.entity = weave_config.entity
|
||||||
|
self.host = weave_config.host
|
||||||
|
|
||||||
|
# Login with API key first, including host if provided
|
||||||
|
if self.host:
|
||||||
|
login_status = wandb.login(key=self.weave_api_key, verify=True, relogin=True, host=self.host)
|
||||||
|
else:
|
||||||
|
login_status = wandb.login(key=self.weave_api_key, verify=True, relogin=True)
|
||||||
|
|
||||||
# Login with API key first
|
|
||||||
login_status = wandb.login(key=self.weave_api_key, verify=True, relogin=True)
|
|
||||||
if not login_status:
|
if not login_status:
|
||||||
logger.error("Failed to login to Weights & Biases with the provided API key")
|
logger.error("Failed to login to Weights & Biases with the provided API key")
|
||||||
raise ValueError("Weave login failed")
|
raise ValueError("Weave login failed")
|
||||||
@@ -386,7 +391,11 @@ class WeaveDataTrace(BaseTraceInstance):
|
|||||||
|
|
||||||
def api_check(self):
|
def api_check(self):
|
||||||
try:
|
try:
|
||||||
login_status = wandb.login(key=self.weave_api_key, verify=True, relogin=True)
|
if self.host:
|
||||||
|
login_status = wandb.login(key=self.weave_api_key, verify=True, relogin=True, host=self.host)
|
||||||
|
else:
|
||||||
|
login_status = wandb.login(key=self.weave_api_key, verify=True, relogin=True)
|
||||||
|
|
||||||
if not login_status:
|
if not login_status:
|
||||||
raise ValueError("Weave login failed")
|
raise ValueError("Weave login failed")
|
||||||
else:
|
else:
|
||||||
|
@@ -55,6 +55,7 @@ const weaveConfigTemplate = {
|
|||||||
entity: '',
|
entity: '',
|
||||||
project: '',
|
project: '',
|
||||||
endpoint: '',
|
endpoint: '',
|
||||||
|
host: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProviderConfigModal: FC<Props> = ({
|
const ProviderConfigModal: FC<Props> = ({
|
||||||
@@ -226,6 +227,13 @@ const ProviderConfigModal: FC<Props> = ({
|
|||||||
onChange={handleConfigChange('endpoint')}
|
onChange={handleConfigChange('endpoint')}
|
||||||
placeholder={'https://trace.wandb.ai/'}
|
placeholder={'https://trace.wandb.ai/'}
|
||||||
/>
|
/>
|
||||||
|
<Field
|
||||||
|
label='Host'
|
||||||
|
labelClassName='!text-sm'
|
||||||
|
value={(config as WeaveConfig).host}
|
||||||
|
onChange={handleConfigChange('host')}
|
||||||
|
placeholder={'https://api.wandb.ai'}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{type === TracingProvider.langSmith && (
|
{type === TracingProvider.langSmith && (
|
||||||
|
@@ -29,4 +29,5 @@ export type WeaveConfig = {
|
|||||||
entity: string
|
entity: string
|
||||||
project: string
|
project: string
|
||||||
endpoint: string
|
endpoint: string
|
||||||
|
host: string
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user