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 const getRayConfig = () => get<RayConfigResponse>("/api/ray_config", {});
|
||||||
|
|
||||||
export type UsageStatsEnabledResponse = {
|
export type UsageStatsEnabledResponse = {
|
||||||
enabled: boolean;
|
usageStatsEnabled: boolean;
|
||||||
|
usageStatsPromptEnabled: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getUsageStatsEnabled = () =>
|
export const getUsageStatsEnabled = () =>
|
||||||
|
|
|
@ -105,14 +105,12 @@ const Dashboard: React.FC = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const SelectedComponent = tabs[tab].component;
|
const SelectedComponent = tabs[tab].component;
|
||||||
|
const [usageStatsPromptEnabled, setUsageStatsPromptEnabled] = useState(false);
|
||||||
const [usageStatsEnabled, setUsageStatsEnabled] = useState(false);
|
const [usageStatsEnabled, setUsageStatsEnabled] = useState(false);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getUsageStatsEnabled().then((res) => {
|
getUsageStatsEnabled().then((res) => {
|
||||||
if (res.enabled) {
|
setUsageStatsPromptEnabled(res.usageStatsPromptEnabled);
|
||||||
setUsageStatsEnabled(true);
|
setUsageStatsEnabled(res.usageStatsEnabled);
|
||||||
} else {
|
|
||||||
setUsageStatsEnabled(false);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
|
@ -139,26 +137,28 @@ const Dashboard: React.FC = () => {
|
||||||
))}
|
))}
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<SelectedComponent />
|
<SelectedComponent />
|
||||||
<Alert style={{ marginTop: 30 }} severity="info">
|
{usageStatsPromptEnabled ? (
|
||||||
{usageStatsEnabled ? (
|
<Alert style={{ marginTop: 30 }} severity="info">
|
||||||
<span>
|
{usageStatsEnabled ? (
|
||||||
Usage stats collection is enabled. To disable this, add
|
<span>
|
||||||
`--disable-usage-stats` to the command that starts the cluster, or
|
Usage stats collection is enabled. To disable this, add
|
||||||
run the following command: `ray disable-usage-stats` before starting
|
`--disable-usage-stats` to the command that starts the cluster, or
|
||||||
the cluster. See{" "}
|
run the following command: `ray disable-usage-stats` before
|
||||||
<a
|
starting the cluster. See{" "}
|
||||||
href="https://docs.ray.io/en/master/cluster/usage-stats.html"
|
<a
|
||||||
target="_blank"
|
href="https://docs.ray.io/en/master/cluster/usage-stats.html"
|
||||||
rel="noreferrer"
|
target="_blank"
|
||||||
>
|
rel="noreferrer"
|
||||||
https://docs.ray.io/en/master/cluster/usage-stats.html
|
>
|
||||||
</a>{" "}
|
https://docs.ray.io/en/master/cluster/usage-stats.html
|
||||||
for more details.
|
</a>{" "}
|
||||||
</span>
|
for more details.
|
||||||
) : (
|
</span>
|
||||||
<span>Usage stats collection is disabled.</span>
|
) : (
|
||||||
)}
|
<span>Usage stats collection is disabled.</span>
|
||||||
</Alert>
|
)}
|
||||||
|
</Alert>
|
||||||
|
) : null}
|
||||||
<LastUpdated />
|
<LastUpdated />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -18,6 +18,7 @@ class UsageStatsHead(dashboard_utils.DashboardHeadModule):
|
||||||
def __init__(self, dashboard_head):
|
def __init__(self, dashboard_head):
|
||||||
super().__init__(dashboard_head)
|
super().__init__(dashboard_head)
|
||||||
self.usage_stats_enabled = ray_usage_lib.usage_stats_enabled()
|
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(
|
self.cluster_metadata = ray_usage_lib.get_cluster_metadata(
|
||||||
ray.experimental.internal_kv.internal_kv_get_gcs_client(),
|
ray.experimental.internal_kv.internal_kv_get_gcs_client(),
|
||||||
num_retries=20,
|
num_retries=20,
|
||||||
|
@ -44,7 +45,8 @@ class UsageStatsHead(dashboard_utils.DashboardHeadModule):
|
||||||
return ray.dashboard.optional_utils.rest_response(
|
return ray.dashboard.optional_utils.rest_response(
|
||||||
success=True,
|
success=True,
|
||||||
message="Fetched usage stats enabled",
|
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):
|
def _report_usage_sync(self):
|
||||||
|
|
|
@ -258,7 +258,7 @@ def usage_stats_enabled() -> bool:
|
||||||
return _usage_stats_enabledness() is not UsageStatsEnabledness.DISABLED_EXPLICITLY
|
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
|
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:
|
def show_usage_stats_prompt() -> None:
|
||||||
if not _usage_stats_prompt_enabled():
|
if not usage_stats_prompt_enabled():
|
||||||
return
|
return
|
||||||
|
|
||||||
from ray.autoscaler._private.cli_logger import cli_logger
|
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._private.usage.usage_lib import UsageStatsEnabledness
|
||||||
from ray.autoscaler._private.cli_logger import cli_logger
|
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 = {
|
||||||
"$schema": "http://json-schema.org/draft-07/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():
|
def test_library_usages():
|
||||||
if os.environ.get("RAY_MINIMAL") == "1":
|
if os.environ.get("RAY_MINIMAL") == "1":
|
||||||
# Doesn't work with minimal installation
|
# Doesn't work with minimal installation
|
||||||
|
|
Loading…
Add table
Reference in a new issue