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

[dashboard] apply isort to dashboard dir #46483

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ filter_files=True
# python/ray/setup-dev.py
# For the rest we will gradually remove them from the blacklist as we
# reformat the code to follow the style guide.
skip_glob=doc/*,python/ray/__init__.py,python/ray/setup-dev.py,python/build/*,python/ray/cloudpickle/*,python/ray/thirdparty_files/*,python/ray/_private/thirdparty/*,python/ray/_private/runtime_env/agent/thirdparty_files/*,python/ray/dag/*.py,ci/*,python/ray/_private/*,dashboard/*,python/ray/includes/*,python/ray/internal/*,python/ray/ray_operator/*,python/ray/scripts/*,python/ray/serve/generated/serve_pb2.py,python/ray/streaming/*,python/ray/tests/*,python/ray/tests/*,python/ray/util/*,python/ray/workers/*,python/ray/workflow/*,rllib/*,release/*,
skip_glob=doc/*,python/ray/__init__.py,python/ray/setup-dev.py,python/build/*,python/ray/cloudpickle/*,python/ray/thirdparty_files/*,python/ray/_private/thirdparty/*,python/ray/_private/runtime_env/agent/thirdparty_files/*,python/ray/dag/*.py,ci/*,python/ray/_private/*,python/ray/includes/*,python/ray/internal/*,python/ray/ray_operator/*,python/ray/scripts/*,python/ray/serve/generated/serve_pb2.py,python/ray/streaming/*,python/ray/tests/*,python/ray/tests/*,python/ray/util/*,python/ray/workers/*,python/ray/workflow/*,rllib/*,release/*,

known_local_folder=ray
known_afterray=psutil,setproctitle
Expand Down
9 changes: 3 additions & 6 deletions dashboard/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,19 @@
import logging.handlers
import os
import pathlib
import sys
import signal
import sys

import ray
import ray._private.ray_constants as ray_constants
import ray._private.services
import ray._private.utils
import ray.dashboard.consts as dashboard_consts
import ray.dashboard.utils as dashboard_utils
from ray._private.process_watcher import create_check_raylet_task
from ray._private.gcs_utils import GcsAioClient
from ray._private.ray_logging import (
setup_component_logger,
configure_log_file,
)
from ray._private.process_watcher import create_check_raylet_task
from ray._private.ray_constants import AGENT_GRPC_MAX_MESSAGE_LENGTH
from ray._private.ray_logging import configure_log_file, setup_component_logger

logger = logging.getLogger(__name__)

Expand Down
3 changes: 2 additions & 1 deletion dashboard/consts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from ray._private.ray_constants import env_integer, env_bool

from ray._private.ray_constants import env_bool, env_integer

DASHBOARD_LOG_FILENAME = "dashboard.log"
DASHBOARD_AGENT_PORT_PREFIX = "DASHBOARD_AGENT_PORT_PREFIX:"
Expand Down
6 changes: 3 additions & 3 deletions dashboard/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import argparse
import logging
import logging.handlers
import os
import platform
import traceback
import signal
import os
import sys
import traceback
from typing import Optional, Set

import ray._private.ray_constants as ray_constants
import ray._private.services
Expand All @@ -14,7 +15,6 @@
import ray.dashboard.head as dashboard_head
import ray.dashboard.utils as dashboard_utils
from ray._private.ray_logging import setup_component_logger
from typing import Optional, Set

# Logger for this module. It should be configured at the entry point
# into the program using Ray. Ray provides a default configuration at
Expand Down
3 changes: 2 additions & 1 deletion dashboard/dashboard_metrics.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Optional

from ray.dashboard.consts import COMPONENT_METRICS_TAG_KEYS


Expand All @@ -17,7 +18,7 @@ def inc(self, *args, **kwargs):

try:

from prometheus_client import CollectorRegistry, Counter, Histogram, Gauge
from prometheus_client import CollectorRegistry, Counter, Gauge, Histogram

# The metrics in this class should be kept in sync with
# python/ray/tests/test_metrics_agent.py
Expand Down
2 changes: 1 addition & 1 deletion dashboard/datacenter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import logging
import ray.dashboard.consts as dashboard_consts

import ray.dashboard.consts as dashboard_consts
from ray.dashboard.utils import (
Dict,
MutableNotificationDict,
Expand Down
12 changes: 5 additions & 7 deletions dashboard/head.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import asyncio
import logging
import os
from pathlib import Path
import threading
from concurrent.futures import Future
from pathlib import Path
from queue import Queue
from typing import Optional, Set

import ray.dashboard.consts as dashboard_consts
import ray.dashboard.utils as dashboard_utils
import ray.experimental.internal_kv as internal_kv
from ray._private.usage.usage_lib import TagKey, record_extra_usage_tag
from ray._private import ray_constants
from ray.dashboard.utils import DashboardHeadModule
from ray._private.usage.usage_lib import TagKey, record_extra_usage_tag
from ray._raylet import GcsClient, check_health
from ray.dashboard.datacenter import DataOrganizer
from ray.dashboard.utils import async_loop_forever
from ray.dashboard.consts import DASHBOARD_METRIC_PORT
from ray.dashboard.dashboard_metrics import DashboardPrometheusMetrics

from typing import Optional, Set
from ray.dashboard.datacenter import DataOrganizer
from ray.dashboard.utils import DashboardHeadModule, async_loop_forever

try:
import prometheus_client
Expand Down
3 changes: 1 addition & 2 deletions dashboard/http_server_agent.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import logging
from ray._private.utils import get_or_create_event_loop

from packaging.version import Version

import ray.dashboard.optional_utils as dashboard_optional_utils

from ray._private.utils import get_or_create_event_loop
from ray.dashboard.optional_deps import aiohttp, aiohttp_cors, hdrs

logger = logging.getLogger(__name__)
Expand Down
8 changes: 2 additions & 6 deletions dashboard/modules/actor/actor_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
import logging
import os
import time

from collections import deque

import aiohttp.web

import ray.dashboard.optional_utils as dashboard_optional_utils
import ray.dashboard.utils as dashboard_utils
from ray._private.gcs_pubsub import GcsAioActorSubscriber
from ray.core.generated import (
gcs_service_pb2,
gcs_service_pb2_grpc,
)
from ray.dashboard.datacenter import DataSource, DataOrganizer
from ray.core.generated import gcs_service_pb2, gcs_service_pb2_grpc
from ray.dashboard.datacenter import DataOrganizer, DataSource
from ray.dashboard.modules.actor import actor_consts

logger = logging.getLogger(__name__)
Expand Down
28 changes: 14 additions & 14 deletions dashboard/modules/dashboard_sdk.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import dataclasses
import importlib
import logging
import json
import logging
import os
import yaml
from pathlib import Path
import ssl
import tempfile
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
import packaging.version
import ray
import ssl

try:
import requests
except ImportError:
requests = None

import packaging.version
import yaml

import ray
from ray._private.runtime_env.packaging import (
create_package,
get_uri_for_directory,
get_uri_for_package,
)
from ray._private.runtime_env.py_modules import upload_py_modules_if_needed
from ray._private.runtime_env.working_dir import upload_working_dir_if_needed
from ray.dashboard.modules.job.common import uri_to_http_components

from ray.util.annotations import DeveloperAPI, PublicAPI
from ray._private.utils import split_address
from ray.autoscaler._private.cli_logger import cli_logger
from ray.dashboard.modules.job.common import uri_to_http_components
from ray.util.annotations import DeveloperAPI, PublicAPI

try:
import requests
except ImportError:
requests = None


logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down
8 changes: 5 additions & 3 deletions dashboard/modules/data/data_head.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import json
import logging
import os
from enum import Enum
from urllib.parse import quote

import aiohttp
from aiohttp.web import Request, Response

import ray.dashboard.optional_utils as optional_utils
import ray.dashboard.utils as dashboard_utils
from ray.dashboard.modules.metrics.metrics_head import (
PROMETHEUS_HOST_ENV_VAR,
DEFAULT_PROMETHEUS_HOST,
PROMETHEUS_HOST_ENV_VAR,
PrometheusQueryError,
)
from urllib.parse import quote
import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down
8 changes: 5 additions & 3 deletions dashboard/modules/data/tests/test_data_head.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import ray
from ray.job_submission import JobSubmissionClient
import os
import requests
import sys

import pytest
import requests

import ray
from ray.job_submission import JobSubmissionClient

# For local testing on a Macbook, set `export TEST_ON_DARWIN=1`.
TEST_ON_DARWIN = os.environ.get("TEST_ON_DARWIN", "0") == "1"
Expand Down
4 changes: 2 additions & 2 deletions dashboard/modules/event/event_agent.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import time
from concurrent.futures import ThreadPoolExecutor
import logging
import os
import time
from concurrent.futures import ThreadPoolExecutor
from typing import Union

import ray._private.ray_constants as ray_constants
Expand Down
14 changes: 5 additions & 9 deletions dashboard/modules/event/event_head.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import os
import asyncio
import logging
import os
import time
from typing import Union
from collections import OrderedDict, defaultdict
from concurrent.futures import ThreadPoolExecutor
from typing import Union

import aiohttp.web

import ray.dashboard.utils as dashboard_utils
import ray.dashboard.optional_utils as dashboard_optional_utils
from ray.dashboard.modules.event.event_utils import (
parse_event_strings,
monitor_events,
)
from ray.core.generated import event_pb2
from ray.core.generated import event_pb2_grpc
import ray.dashboard.utils as dashboard_utils
from ray.core.generated import event_pb2, event_pb2_grpc
from ray.dashboard.datacenter import DataSource
from ray.dashboard.modules.event.event_utils import monitor_events, parse_event_strings

logger = logging.getLogger(__name__)
routes = dashboard_optional_utils.DashboardHeadRouteTable
Expand Down
16 changes: 7 additions & 9 deletions dashboard/modules/event/event_utils.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import os
import time
import mmap
import json
import fnmatch
import asyncio
import itertools
import collections
import fnmatch
import itertools
import json
import logging.handlers
from ray._private.utils import get_or_create_event_loop

import mmap
import os
import time
from concurrent.futures import ThreadPoolExecutor

from ray._private.utils import run_background_task
from ray._private.utils import get_or_create_event_loop, run_background_task
from ray.dashboard.modules.event import event_consts
from ray.dashboard.utils import async_loop_forever

Expand Down
37 changes: 17 additions & 20 deletions dashboard/modules/event/tests/test_event.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
import os
import sys
import time
import json
import asyncio
import copy
import json
import logging
import requests
import asyncio
import os
import random
import tempfile
import socket

from pprint import pprint
import sys
import tempfile
import time
from datetime import datetime
from pprint import pprint

import pytest
import numpy as np
import pytest
import requests

import ray
from ray.util.state import list_cluster_events
from ray._private.utils import binary_to_hex
from ray.cluster_utils import AutoscalingCluster
from ray._private.event.event_logger import filter_event_by_level, get_event_logger
from ray.dashboard.tests.conftest import * # noqa
from ray.dashboard.modules.event import event_consts
from ray.core.generated import event_pb2
from ray._private.test_utils import (
format_web_url,
wait_until_server_available,
wait_for_condition,
wait_until_server_available,
)
from ray.dashboard.modules.event.event_utils import (
monitor_events,
)
from ray._private.utils import binary_to_hex
from ray.cluster_utils import AutoscalingCluster
from ray.core.generated import event_pb2
from ray.dashboard.modules.event import event_consts
from ray.dashboard.modules.event.event_utils import monitor_events
from ray.dashboard.tests.conftest import * # noqa
from ray.job_submission import JobSubmissionClient
from ray.util.state import list_cluster_events

logger = logging.getLogger(__name__)

Expand Down
7 changes: 4 additions & 3 deletions dashboard/modules/healthz/healthz_agent.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import ray.dashboard.utils as dashboard_utils
from aiohttp.web import Request, Response

import ray.dashboard.optional_utils as optional_utils
from ray.dashboard.modules.healthz.utils import HealthChecker
import ray.dashboard.utils as dashboard_utils
import ray.exceptions
from aiohttp.web import Request, Response
from ray.dashboard.modules.healthz.utils import HealthChecker

routes = optional_utils.DashboardAgentRouteTable

Expand Down
5 changes: 3 additions & 2 deletions dashboard/modules/healthz/healthz_head.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ray.dashboard.utils as dashboard_utils
from aiohttp.web import HTTPServiceUnavailable, Request, Response

import ray.dashboard.optional_utils as optional_utils
import ray.dashboard.utils as dashboard_utils
from ray.dashboard.modules.healthz.utils import HealthChecker
from aiohttp.web import Request, Response, HTTPServiceUnavailable

routes = optional_utils.DashboardHeadRouteTable

Expand Down
3 changes: 2 additions & 1 deletion dashboard/modules/healthz/tests/test_healthz.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import sys

import pytest
import requests

import ray._private.ray_constants as ray_constants
from ray.tests.conftest import * # noqa: F401 F403
from ray._private.test_utils import find_free_port, wait_for_condition
from ray.tests.conftest import * # noqa: F401 F403


def test_healthz_head(monkeypatch, ray_start_cluster):
Expand Down
Loading