mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
This commit is contained in:
parent
677b5c33db
commit
930ecfaf1c
5 changed files with 61 additions and 30 deletions
|
@ -37,7 +37,8 @@ export type RayConfigResponse = {
|
|||
export const getRayConfig = () => get<RayConfigResponse>("/api/ray_config", {});
|
||||
|
||||
export type UsageStatsEnabledResponse = {
|
||||
enabled: boolean;
|
||||
usageStatsEnabled: boolean;
|
||||
usageStatsPromptEnabled: boolean;
|
||||
};
|
||||
|
||||
export const getUsageStatsEnabled = () =>
|
||||
|
|
|
@ -105,14 +105,12 @@ const Dashboard: React.FC = () => {
|
|||
}
|
||||
|
||||
const SelectedComponent = tabs[tab].component;
|
||||
const [usageStatsPromptEnabled, setUsageStatsPromptEnabled] = useState(false);
|
||||
const [usageStatsEnabled, setUsageStatsEnabled] = useState(false);
|
||||
useEffect(() => {
|
||||
getUsageStatsEnabled().then((res) => {
|
||||
if (res.enabled) {
|
||||
setUsageStatsEnabled(true);
|
||||
} else {
|
||||
setUsageStatsEnabled(false);
|
||||
}
|
||||
setUsageStatsPromptEnabled(res.usageStatsPromptEnabled);
|
||||
setUsageStatsEnabled(res.usageStatsEnabled);
|
||||
});
|
||||
}, []);
|
||||
return (
|
||||
|
@ -139,13 +137,14 @@ const Dashboard: React.FC = () => {
|
|||
))}
|
||||
</Tabs>
|
||||
<SelectedComponent />
|
||||
{usageStatsPromptEnabled ? (
|
||||
<Alert style={{ marginTop: 30 }} severity="info">
|
||||
{usageStatsEnabled ? (
|
||||
<span>
|
||||
Usage stats collection is enabled. To disable this, add
|
||||
`--disable-usage-stats` to the command that starts the cluster, or
|
||||
run the following command: `ray disable-usage-stats` before starting
|
||||
the cluster. See{" "}
|
||||
run the following command: `ray disable-usage-stats` before
|
||||
starting the cluster. See{" "}
|
||||
<a
|
||||
href="https://docs.ray.io/en/master/cluster/usage-stats.html"
|
||||
target="_blank"
|
||||
|
@ -159,6 +158,7 @@ const Dashboard: React.FC = () => {
|
|||
<span>Usage stats collection is disabled.</span>
|
||||
)}
|
||||
</Alert>
|
||||
) : null}
|
||||
<LastUpdated />
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -18,6 +18,7 @@ class UsageStatsHead(dashboard_utils.DashboardHeadModule):
|
|||
def __init__(self, dashboard_head):
|
||||
super().__init__(dashboard_head)
|
||||
self.usage_stats_enabled = ray_usage_lib.usage_stats_enabled()
|
||||
self.usage_stats_prompt_enabled = ray_usage_lib.usage_stats_prompt_enabled()
|
||||
self.cluster_metadata = ray_usage_lib.get_cluster_metadata(
|
||||
ray.experimental.internal_kv.internal_kv_get_gcs_client(),
|
||||
num_retries=20,
|
||||
|
@ -44,7 +45,8 @@ class UsageStatsHead(dashboard_utils.DashboardHeadModule):
|
|||
return ray.dashboard.optional_utils.rest_response(
|
||||
success=True,
|
||||
message="Fetched usage stats enabled",
|
||||
enabled=self.usage_stats_enabled,
|
||||
usage_stats_enabled=self.usage_stats_enabled,
|
||||
usage_stats_prompt_enabled=self.usage_stats_prompt_enabled,
|
||||
)
|
||||
|
||||
def _report_usage_sync(self):
|
||||
|
|
|
@ -258,7 +258,7 @@ def usage_stats_enabled() -> bool:
|
|||
return _usage_stats_enabledness() is not UsageStatsEnabledness.DISABLED_EXPLICITLY
|
||||
|
||||
|
||||
def _usage_stats_prompt_enabled():
|
||||
def usage_stats_prompt_enabled():
|
||||
return int(os.getenv("RAY_USAGE_STATS_PROMPT_ENABLED", "1")) == 1
|
||||
|
||||
|
||||
|
@ -287,7 +287,7 @@ def _generate_cluster_metadata():
|
|||
|
||||
|
||||
def show_usage_stats_prompt() -> None:
|
||||
if not _usage_stats_prompt_enabled():
|
||||
if not usage_stats_prompt_enabled():
|
||||
return
|
||||
|
||||
from ray.autoscaler._private.cli_logger import cli_logger
|
||||
|
|
|
@ -16,7 +16,11 @@ from ray._private.usage.usage_lib import ClusterConfigToReport
|
|||
from ray._private.usage.usage_lib import UsageStatsEnabledness
|
||||
from ray.autoscaler._private.cli_logger import cli_logger
|
||||
|
||||
from ray._private.test_utils import wait_for_condition
|
||||
from ray._private.test_utils import (
|
||||
format_web_url,
|
||||
wait_for_condition,
|
||||
wait_until_server_available,
|
||||
)
|
||||
|
||||
schema = {
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
|
@ -285,6 +289,30 @@ def test_usage_lib_cluster_metadata_generation(monkeypatch, ray_start_cluster):
|
|||
)
|
||||
|
||||
|
||||
def test_usage_stats_enabled_endpoint(monkeypatch, ray_start_cluster):
|
||||
if os.environ.get("RAY_MINIMAL") == "1":
|
||||
# Doesn't work with minimal installation
|
||||
# since we need http server.
|
||||
return
|
||||
|
||||
import requests
|
||||
|
||||
with monkeypatch.context() as m:
|
||||
m.setenv("RAY_USAGE_STATS_ENABLED", "0")
|
||||
m.setenv("RAY_USAGE_STATS_PROMPT_ENABLED", "0")
|
||||
cluster = ray_start_cluster
|
||||
cluster.add_node(num_cpus=0)
|
||||
context = ray.init(address=cluster.address)
|
||||
webui_url = context["webui_url"]
|
||||
assert wait_until_server_available(webui_url)
|
||||
webui_url = format_web_url(webui_url)
|
||||
response = requests.get(f"{webui_url}/usage_stats_enabled")
|
||||
assert response.status_code == 200
|
||||
assert response.json()["result"] is True
|
||||
assert response.json()["data"]["usageStatsEnabled"] is False
|
||||
assert response.json()["data"]["usageStatsPromptEnabled"] is False
|
||||
|
||||
|
||||
def test_library_usages():
|
||||
if os.environ.get("RAY_MINIMAL") == "1":
|
||||
# Doesn't work with minimal installation
|
||||
|
|
Loading…
Add table
Reference in a new issue