Skip to content
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

[Core] Psutil process attr num_fds is not available on Windows #46329

Merged
merged 2 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 19 additions & 39 deletions dashboard/modules/reporter/reporter_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def jsonify_asdict(o) -> str:
),
"component_num_fds": Gauge(
"component_num_fds",
"Number of open fds of all components on the node.",
"Number of open fds of all components on the node (Not available on Windows).",
"count",
COMPONENT_METRICS_TAG_KEYS,
),
Expand All @@ -275,6 +275,21 @@ def jsonify_asdict(o) -> str:
),
}

PSUTIL_PROCESS_ATTRS = (
[
"pid",
"create_time",
"cpu_percent",
"cpu_times",
"cmdline",
"memory_info",
"memory_full_info",
]
+ ["num_fds"]
if sys.platform != "win32"
else []
)

MB = 1024 * 1024

# Types
Expand Down Expand Up @@ -626,20 +641,7 @@ def _get_workers(self):
# the process may have terminated due to race condition.
continue

result.append(
w.as_dict(
attrs=[
"pid",
"create_time",
"cpu_percent",
"cpu_times",
"cmdline",
"memory_info",
"memory_full_info",
"num_fds",
]
)
)
result.append(w.as_dict(attrs=PSUTIL_PROCESS_ATTRS))
return result

def _get_raylet_proc(self):
Expand All @@ -665,35 +667,13 @@ def _get_raylet(self):
if raylet_proc is None:
return {}
else:
return raylet_proc.as_dict(
attrs=[
"pid",
"create_time",
"cpu_percent",
"cpu_times",
"cmdline",
"memory_info",
"memory_full_info",
"num_fds",
]
)
return raylet_proc.as_dict(attrs=PSUTIL_PROCESS_ATTRS)

def _get_agent(self):
# Current proc == agent proc
if not self._agent_proc:
self._agent_proc = psutil.Process()
return self._agent_proc.as_dict(
attrs=[
"pid",
"create_time",
"cpu_percent",
"cpu_times",
"cmdline",
"memory_info",
"memory_full_info",
"num_fds",
]
)
return self._agent_proc.as_dict(attrs=PSUTIL_PROCESS_ATTRS)

def _get_load_avg(self):
if sys.platform == "win32":
Expand Down
2 changes: 0 additions & 2 deletions python/ray/tests/test_metrics_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ def wrap_test_case_for_retry():
test_cases() # Should fail assert


@pytest.mark.skipif(sys.platform == "win32", reason="Not working in Windows.")
@pytest.mark.skipif(prometheus_client is None, reason="Prometheus not installed")
def test_metrics_export_node_metrics(shutdown_only):
# Verify node metrics are available.
Expand Down Expand Up @@ -645,7 +644,6 @@ def check_metrics():
wait_for_condition(check_metrics, timeout=60)


@pytest.mark.skipif(sys.platform == "win32", reason="Not working in Windows.")
def test_per_func_name_stats(shutdown_only):
# Test operation stats are available when flag is on.
comp_metrics = [
Expand Down
Loading