skypilot-nightly 1.0.0.dev20250322__py3-none-any.whl → 1.0.0.dev20250324__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. sky/__init__.py +2 -2
  2. sky/adaptors/common.py +11 -7
  3. sky/adaptors/ibm.py +3 -3
  4. sky/authentication.py +14 -4
  5. sky/backends/backend_utils.py +14 -5
  6. sky/client/common.py +8 -4
  7. sky/client/sdk.py +8 -3
  8. sky/clouds/fluidstack.py +5 -2
  9. sky/clouds/lambda_cloud.py +5 -2
  10. sky/clouds/paperspace.py +5 -2
  11. sky/clouds/service_catalog/common.py +2 -1
  12. sky/clouds/utils/scp_utils.py +8 -2
  13. sky/clouds/vsphere.py +5 -2
  14. sky/jobs/client/sdk.py +5 -1
  15. sky/jobs/scheduler.py +7 -1
  16. sky/jobs/utils.py +5 -1
  17. sky/optimizer.py +2 -1
  18. sky/provision/fluidstack/fluidstack_utils.py +7 -2
  19. sky/provision/kubernetes/config.py +7 -2
  20. sky/provision/kubernetes/network_utils.py +9 -3
  21. sky/provision/kubernetes/utils.py +7 -3
  22. sky/provision/lambda_cloud/lambda_utils.py +8 -3
  23. sky/provision/paperspace/utils.py +8 -3
  24. sky/provision/vsphere/common/ssl_helper.py +7 -2
  25. sky/provision/vsphere/common/vapiconnect.py +8 -1
  26. sky/provision/vsphere/vsphere_utils.py +7 -2
  27. sky/serve/client/sdk.py +5 -1
  28. sky/serve/serve_utils.py +16 -6
  29. sky/serve/service.py +2 -1
  30. sky/serve/service_spec.py +7 -2
  31. sky/server/common.py +10 -5
  32. sky/server/requests/payloads.py +7 -2
  33. sky/skylet/autostop_lib.py +7 -2
  34. sky/skylet/job_lib.py +7 -1
  35. sky/skypilot_config.py +7 -2
  36. sky/task.py +5 -1
  37. sky/utils/common_utils.py +14 -6
  38. sky/utils/log_utils.py +9 -3
  39. sky/utils/rich_console_utils.py +21 -0
  40. sky/utils/rich_utils.py +7 -4
  41. sky/utils/subprocess_utils.py +7 -1
  42. sky/utils/ux_utils.py +2 -4
  43. sky/utils/validator.py +14 -4
  44. {skypilot_nightly-1.0.0.dev20250322.dist-info → skypilot_nightly-1.0.0.dev20250324.dist-info}/METADATA +1 -1
  45. {skypilot_nightly-1.0.0.dev20250322.dist-info → skypilot_nightly-1.0.0.dev20250324.dist-info}/RECORD +49 -48
  46. {skypilot_nightly-1.0.0.dev20250322.dist-info → skypilot_nightly-1.0.0.dev20250324.dist-info}/WHEEL +0 -0
  47. {skypilot_nightly-1.0.0.dev20250322.dist-info → skypilot_nightly-1.0.0.dev20250324.dist-info}/entry_points.txt +0 -0
  48. {skypilot_nightly-1.0.0.dev20250322.dist-info → skypilot_nightly-1.0.0.dev20250324.dist-info}/licenses/LICENSE +0 -0
  49. {skypilot_nightly-1.0.0.dev20250322.dist-info → skypilot_nightly-1.0.0.dev20250324.dist-info}/top_level.txt +0 -0
sky/__init__.py CHANGED
@@ -5,7 +5,7 @@ from typing import Optional
5
5
  import urllib.request
6
6
 
7
7
  # Replaced with the current commit when building the wheels.
8
- _SKYPILOT_COMMIT_SHA = '139a09e3445956740743049d352cd1cb6d202479'
8
+ _SKYPILOT_COMMIT_SHA = '633e16611f2f858dc27c9eae2f410811e0bc714c'
9
9
 
10
10
 
11
11
  def _get_git_commit():
@@ -35,7 +35,7 @@ def _get_git_commit():
35
35
 
36
36
 
37
37
  __commit__ = _get_git_commit()
38
- __version__ = '1.0.0.dev20250322'
38
+ __version__ = '1.0.0.dev20250324'
39
39
  __root_dir__ = os.path.dirname(os.path.abspath(__file__))
40
40
 
41
41
 
sky/adaptors/common.py CHANGED
@@ -6,15 +6,19 @@ from typing import Any, Callable, Optional, Tuple
6
6
 
7
7
 
8
8
  class LazyImport:
9
- """Lazy importer for heavy modules or cloud modules only when enabled.
9
+ """Lazy importer for modules.
10
10
 
11
- We use this for pandas and networkx, as they can be time-consuming to import
12
- (0.1-0.2 seconds). With this class, we can avoid the unnecessary import time
13
- when the module is not used (e.g., `networkx` should not be imported for
14
- `sky status and `pandas` should not be imported for `sky exec`).
11
+ This is mainly used in two cases:
12
+ 1. Heavy 3rd party modules: They can be time-consuming to import
13
+ and not necessary for all `sky` imports, e.g., numpy(700+ms),
14
+ pendulum(500+ms), cryptography(500+ms), pandas(200+ms), and
15
+ networkx(100+ms), etc. With this class, we can avoid the
16
+ unnecessary import time when the module is not used (e.g.,
17
+ `networkx` should not be imported for `sky status` and `pandas`
18
+ should not be imported for `sky exec`).
15
19
 
16
- We also use this for cloud adaptors, because we do not want to import the
17
- cloud dependencies when it is not enabled.
20
+ 2. Cloud modules in cloud adaptors: cloud dependencies are only required
21
+ when a cloud is enabled, so we only import them when actually needed.
18
22
  """
19
23
 
20
24
  def __init__(self,
sky/adaptors/ibm.py CHANGED
@@ -6,9 +6,6 @@ import json
6
6
  import multiprocessing
7
7
  import os
8
8
 
9
- import requests
10
- import yaml
11
-
12
9
  from sky import sky_logging
13
10
  from sky.adaptors import common
14
11
 
@@ -27,6 +24,9 @@ ibm_boto3 = common.LazyImport('ibm_boto3',
27
24
  import_error_message=_IMPORT_ERROR_MESSAGE)
28
25
  ibm_botocore = common.LazyImport('ibm_botocore',
29
26
  import_error_message=_IMPORT_ERROR_MESSAGE)
27
+ requests = common.LazyImport('requests',
28
+ import_error_message=_IMPORT_ERROR_MESSAGE)
29
+ yaml = common.LazyImport('yaml', import_error_message=_IMPORT_ERROR_MESSAGE)
30
30
 
31
31
 
32
32
  def read_credential_file():
sky/authentication.py CHANGED
@@ -25,19 +25,17 @@ import re
25
25
  import socket
26
26
  import subprocess
27
27
  import sys
28
+ import typing
28
29
  from typing import Any, Dict, Tuple
29
30
  import uuid
30
31
 
31
32
  import colorama
32
- from cryptography.hazmat.backends import default_backend
33
- from cryptography.hazmat.primitives import serialization
34
- from cryptography.hazmat.primitives.asymmetric import rsa
35
33
  import filelock
36
- import yaml
37
34
 
38
35
  from sky import clouds
39
36
  from sky import sky_logging
40
37
  from sky import skypilot_config
38
+ from sky.adaptors import common as adaptors_common
41
39
  from sky.adaptors import gcp
42
40
  from sky.adaptors import ibm
43
41
  from sky.adaptors import kubernetes
@@ -67,6 +65,11 @@ MAX_TRIALS = 64
67
65
  # the former dir is empheral.
68
66
  _SSH_KEY_PATH_PREFIX = '~/.sky/clients/{user_hash}/ssh'
69
67
 
68
+ if typing.TYPE_CHECKING:
69
+ import yaml
70
+ else:
71
+ yaml = adaptors_common.LazyImport('yaml')
72
+
70
73
 
71
74
  def get_ssh_key_and_lock_path() -> Tuple[str, str, str]:
72
75
  user_hash = common_utils.get_user_hash()
@@ -82,6 +85,13 @@ def get_ssh_key_and_lock_path() -> Tuple[str, str, str]:
82
85
 
83
86
 
84
87
  def _generate_rsa_key_pair() -> Tuple[str, str]:
88
+ # Keep the import of the cryptography local to avoid expensive
89
+ # third-party imports when not needed.
90
+ # pylint: disable=import-outside-toplevel
91
+ from cryptography.hazmat.backends import default_backend
92
+ from cryptography.hazmat.primitives import serialization
93
+ from cryptography.hazmat.primitives.asymmetric import rsa
94
+
85
95
  key = rsa.generate_private_key(backend=default_backend(),
86
96
  public_exponent=65537,
87
97
  key_size=2048)
@@ -19,12 +19,7 @@ import uuid
19
19
  import colorama
20
20
  import filelock
21
21
  from packaging import version
22
- import requests
23
- from requests import adapters
24
- from requests.packages.urllib3.util import retry as retry_lib
25
- import rich.progress as rich_progress
26
22
  from typing_extensions import Literal
27
- import yaml
28
23
 
29
24
  import sky
30
25
  from sky import authentication as auth
@@ -36,6 +31,7 @@ from sky import global_user_state
36
31
  from sky import provision as provision_lib
37
32
  from sky import sky_logging
38
33
  from sky import skypilot_config
34
+ from sky.adaptors import common as adaptors_common
39
35
  from sky.provision import instance_setup
40
36
  from sky.provision.kubernetes import utils as kubernetes_utils
41
37
  from sky.skylet import constants
@@ -56,10 +52,23 @@ from sky.utils import timeline
56
52
  from sky.utils import ux_utils
57
53
 
58
54
  if typing.TYPE_CHECKING:
55
+ import requests
56
+ from requests import adapters
57
+ from requests.packages.urllib3.util import retry as retry_lib
58
+ import rich.progress as rich_progress
59
+ import yaml
60
+
59
61
  from sky import resources as resources_lib
60
62
  from sky import task as task_lib
61
63
  from sky.backends import cloud_vm_ray_backend
62
64
  from sky.backends import local_docker_backend
65
+ else:
66
+ yaml = adaptors_common.LazyImport('yaml')
67
+ requests = adaptors_common.LazyImport('requests')
68
+ rich_progress = adaptors_common.LazyImport('rich.progress')
69
+ adapters = adaptors_common.LazyImport('requests.adapters')
70
+ retry_lib = adaptors_common.LazyImport(
71
+ 'requests.packages.urllib3.util.retry')
63
72
 
64
73
  logger = sky_logging.init_logger(__name__)
65
74
 
sky/client/common.py CHANGED
@@ -14,10 +14,8 @@ from typing import Dict, Generator, Iterable
14
14
  import uuid
15
15
  import zipfile
16
16
 
17
- import httpx
18
- import requests
19
-
20
17
  from sky import sky_logging
18
+ from sky.adaptors import common as adaptors_common
21
19
  from sky.data import data_utils
22
20
  from sky.data import storage_utils
23
21
  from sky.server import common as server_common
@@ -29,8 +27,14 @@ from sky.utils import subprocess_utils
29
27
  from sky.utils import ux_utils
30
28
 
31
29
  if typing.TYPE_CHECKING:
30
+ import httpx
31
+ import requests
32
+
32
33
  import sky
33
34
  import sky.dag as dag_lib
35
+ else:
36
+ httpx = adaptors_common.LazyImport('httpx')
37
+ requests = adaptors_common.LazyImport('requests')
34
38
 
35
39
  logger = sky_logging.init_logger(__name__)
36
40
 
@@ -143,7 +147,7 @@ class FileChunkIterator:
143
147
 
144
148
  @dataclasses.dataclass
145
149
  class UploadChunkParams:
146
- client: httpx.Client
150
+ client: 'httpx.Client'
147
151
  upload_id: str
148
152
  chunk_index: int
149
153
  total_chunks: int
sky/client/sdk.py CHANGED
@@ -22,14 +22,13 @@ from typing import Any, Dict, List, Optional, Tuple, Union
22
22
  import click
23
23
  import colorama
24
24
  import filelock
25
- import psutil
26
- import requests
27
25
 
28
26
  from sky import admin_policy
29
27
  from sky import backends
30
28
  from sky import exceptions
31
29
  from sky import sky_logging
32
30
  from sky import skypilot_config
31
+ from sky.adaptors import common as adaptors_common
33
32
  from sky.client import common as client_common
34
33
  from sky.server import common as server_common
35
34
  from sky.server.requests import payloads
@@ -50,14 +49,20 @@ from sky.utils import ux_utils
50
49
  if typing.TYPE_CHECKING:
51
50
  import io
52
51
 
52
+ import psutil
53
+ import requests
54
+
53
55
  import sky
56
+ else:
57
+ psutil = adaptors_common.LazyImport('psutil')
58
+ requests = adaptors_common.LazyImport('requests')
54
59
 
55
60
  logger = sky_logging.init_logger(__name__)
56
61
  logging.getLogger('httpx').setLevel(logging.CRITICAL)
57
62
 
58
63
 
59
64
  def stream_response(request_id: Optional[str],
60
- response: requests.Response,
65
+ response: 'requests.Response',
61
66
  output_stream: Optional['io.TextIOBase'] = None) -> Any:
62
67
  """Streams the response to the console.
63
68
 
sky/clouds/fluidstack.py CHANGED
@@ -3,9 +3,8 @@ import os
3
3
  import typing
4
4
  from typing import Dict, Iterator, List, Optional, Tuple, Union
5
5
 
6
- import requests
7
-
8
6
  from sky import clouds
7
+ from sky.adaptors import common as adaptors_common
9
8
  from sky.clouds import service_catalog
10
9
  from sky.provision.fluidstack import fluidstack_utils
11
10
  from sky.utils import registry
@@ -18,8 +17,12 @@ _CREDENTIAL_FILES = [
18
17
  fluidstack_utils.FLUIDSTACK_API_KEY_PATH
19
18
  ]
20
19
  if typing.TYPE_CHECKING:
20
+ import requests
21
+
21
22
  # Renaming to avoid shadowing variables.
22
23
  from sky import resources as resources_lib
24
+ else:
25
+ requests = adaptors_common.LazyImport('requests')
23
26
 
24
27
 
25
28
  @registry.CLOUD_REGISTRY.register
@@ -2,9 +2,8 @@
2
2
  import typing
3
3
  from typing import Dict, Iterator, List, Optional, Tuple, Union
4
4
 
5
- import requests
6
-
7
5
  from sky import clouds
6
+ from sky.adaptors import common as adaptors_common
8
7
  from sky.clouds import service_catalog
9
8
  from sky.provision.lambda_cloud import lambda_utils
10
9
  from sky.utils import registry
@@ -12,8 +11,12 @@ from sky.utils import resources_utils
12
11
  from sky.utils import status_lib
13
12
 
14
13
  if typing.TYPE_CHECKING:
14
+ import requests
15
+
15
16
  # Renaming to avoid shadowing variables.
16
17
  from sky import resources as resources_lib
18
+ else:
19
+ requests = adaptors_common.LazyImport('requests')
17
20
 
18
21
  # Minimum set of files under ~/.lambda_cloud that grant Lambda Cloud access.
19
22
  _CREDENTIAL_FILES = [
sky/clouds/paperspace.py CHANGED
@@ -3,16 +3,19 @@
3
3
  import typing
4
4
  from typing import Dict, Iterator, List, Optional, Tuple, Union
5
5
 
6
- import requests
7
-
8
6
  from sky import clouds
7
+ from sky.adaptors import common as adaptors_common
9
8
  from sky.clouds import service_catalog
10
9
  from sky.provision.paperspace import utils
11
10
  from sky.utils import registry
12
11
  from sky.utils import resources_utils
13
12
 
14
13
  if typing.TYPE_CHECKING:
14
+ import requests
15
+
15
16
  from sky import resources as resources_lib
17
+ else:
18
+ requests = adaptors_common.LazyImport('requests')
16
19
 
17
20
  _CREDENTIAL_FILES = [
18
21
  # credential files for Paperspace,
@@ -8,7 +8,6 @@ import typing
8
8
  from typing import Callable, Dict, List, NamedTuple, Optional, Tuple, Union
9
9
 
10
10
  import filelock
11
- import requests
12
11
 
13
12
  from sky import sky_logging
14
13
  from sky.adaptors import common as adaptors_common
@@ -21,8 +20,10 @@ from sky.utils import ux_utils
21
20
 
22
21
  if typing.TYPE_CHECKING:
23
22
  import pandas as pd
23
+ import requests
24
24
  else:
25
25
  pd = adaptors_common.LazyImport('pandas')
26
+ requests = adaptors_common.LazyImport('requests')
26
27
 
27
28
  logger = sky_logging.init_logger(__name__)
28
29
 
@@ -11,10 +11,16 @@ import json
11
11
  import logging
12
12
  import os
13
13
  import time
14
+ import typing
14
15
  from typing import Any, Dict, List, Optional
15
16
  from urllib import parse
16
17
 
17
- import requests
18
+ from sky.adaptors import common as adaptors_common
19
+
20
+ if typing.TYPE_CHECKING:
21
+ import requests
22
+ else:
23
+ requests = adaptors_common.LazyImport('requests')
18
24
 
19
25
  CREDENTIALS_PATH = '~/.scp/scp_credential'
20
26
  API_ENDPOINT = 'https://openapi.samsungsdscloud.com'
@@ -98,7 +104,7 @@ class Metadata:
98
104
  return list(metadata.keys())
99
105
 
100
106
 
101
- def raise_scp_error(response: requests.Response) -> None:
107
+ def raise_scp_error(response: 'requests.Response') -> None:
102
108
  """Raise SCPCloudError if appropriate. """
103
109
  status_code = response.status_code
104
110
  if status_code in (200, 202):
sky/clouds/vsphere.py CHANGED
@@ -3,9 +3,8 @@ import subprocess
3
3
  import typing
4
4
  from typing import Dict, Iterator, List, Optional, Tuple, Union
5
5
 
6
- import requests
7
-
8
6
  from sky import clouds
7
+ from sky.adaptors import common as adaptors_common
9
8
  from sky.clouds import service_catalog
10
9
  from sky.provision.vsphere import vsphere_utils
11
10
  from sky.provision.vsphere.vsphere_utils import get_vsphere_credentials
@@ -15,8 +14,12 @@ from sky.utils import registry
15
14
  from sky.utils import resources_utils
16
15
 
17
16
  if typing.TYPE_CHECKING:
17
+ import requests
18
+
18
19
  # Renaming to avoid shadowing variables.
19
20
  from sky import resources as resources_lib
21
+ else:
22
+ requests = adaptors_common.LazyImport('requests')
20
23
 
21
24
  _CLOUD_VSPHERE = 'vsphere'
22
25
  _CREDENTIAL_FILES = [
sky/jobs/client/sdk.py CHANGED
@@ -5,9 +5,9 @@ from typing import Dict, List, Optional, Union
5
5
  import webbrowser
6
6
 
7
7
  import click
8
- import requests
9
8
 
10
9
  from sky import sky_logging
10
+ from sky.adaptors import common as adaptors_common
11
11
  from sky.client import common as client_common
12
12
  from sky.client import sdk
13
13
  from sky.server import common as server_common
@@ -20,7 +20,11 @@ from sky.utils import dag_utils
20
20
  if typing.TYPE_CHECKING:
21
21
  import io
22
22
 
23
+ import requests
24
+
23
25
  import sky
26
+ else:
27
+ requests = adaptors_common.LazyImport('requests')
24
28
 
25
29
  logger = sky_logging.init_logger(__name__)
26
30
 
sky/jobs/scheduler.py CHANGED
@@ -41,17 +41,23 @@ import contextlib
41
41
  from functools import lru_cache
42
42
  import os
43
43
  import time
44
+ import typing
44
45
 
45
46
  import filelock
46
- import psutil
47
47
 
48
48
  from sky import sky_logging
49
+ from sky.adaptors import common as adaptors_common
49
50
  from sky.jobs import constants as managed_job_constants
50
51
  from sky.jobs import state
51
52
  from sky.skylet import constants
52
53
  from sky.utils import common_utils
53
54
  from sky.utils import subprocess_utils
54
55
 
56
+ if typing.TYPE_CHECKING:
57
+ import psutil
58
+ else:
59
+ psutil = adaptors_common.LazyImport('psutil')
60
+
55
61
  logger = sky_logging.init_logger('sky.jobs.controller')
56
62
 
57
63
  # The _MANAGED_JOB_SCHEDULER_LOCK should be held whenever we are checking the
sky/jobs/utils.py CHANGED
@@ -17,13 +17,13 @@ from typing import Any, Dict, List, Optional, Set, Tuple, Union
17
17
 
18
18
  import colorama
19
19
  import filelock
20
- import psutil
21
20
  from typing_extensions import Literal
22
21
 
23
22
  from sky import backends
24
23
  from sky import exceptions
25
24
  from sky import global_user_state
26
25
  from sky import sky_logging
26
+ from sky.adaptors import common as adaptors_common
27
27
  from sky.backends import backend_utils
28
28
  from sky.jobs import constants as managed_job_constants
29
29
  from sky.jobs import scheduler
@@ -40,8 +40,12 @@ from sky.utils import subprocess_utils
40
40
  from sky.utils import ux_utils
41
41
 
42
42
  if typing.TYPE_CHECKING:
43
+ import psutil
44
+
43
45
  import sky
44
46
  from sky import dag as dag_lib
47
+ else:
48
+ psutil = adaptors_common.LazyImport('psutil')
45
49
 
46
50
  logger = sky_logging.init_logger(__name__)
47
51
 
sky/optimizer.py CHANGED
@@ -6,7 +6,6 @@ import typing
6
6
  from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
7
7
 
8
8
  import colorama
9
- import numpy as np
10
9
  import prettytable
11
10
 
12
11
  from sky import check as sky_check
@@ -29,10 +28,12 @@ from sky.utils import ux_utils
29
28
 
30
29
  if typing.TYPE_CHECKING:
31
30
  import networkx as nx
31
+ import numpy as np
32
32
 
33
33
  from sky import dag as dag_lib
34
34
  else:
35
35
  nx = adaptors_common.LazyImport('networkx')
36
+ np = adaptors_common.LazyImport('numpy')
36
37
 
37
38
  logger = sky_logging.init_logger(__name__)
38
39
 
@@ -3,13 +3,18 @@
3
3
  import json
4
4
  import os
5
5
  import time
6
+ import typing
6
7
  from typing import Any, Dict, List
7
8
  import uuid
8
9
 
9
- import requests
10
-
10
+ from sky.adaptors import common as adaptors_common
11
11
  from sky.utils import annotations
12
12
 
13
+ if typing.TYPE_CHECKING:
14
+ import requests
15
+ else:
16
+ requests = adaptors_common.LazyImport('requests')
17
+
13
18
 
14
19
  def get_key_suffix():
15
20
  return str(uuid.uuid4()).replace('-', '')[:8]
@@ -3,16 +3,21 @@ import copy
3
3
  import logging
4
4
  import math
5
5
  import os
6
+ import typing
6
7
  from typing import Any, Dict, Optional, Union
7
8
 
8
- import yaml
9
-
9
+ from sky.adaptors import common as adaptors_common
10
10
  from sky.adaptors import kubernetes
11
11
  from sky.provision import common
12
12
  from sky.provision.kubernetes import network_utils
13
13
  from sky.provision.kubernetes import utils as kubernetes_utils
14
14
  from sky.utils import kubernetes_enums
15
15
 
16
+ if typing.TYPE_CHECKING:
17
+ import yaml
18
+ else:
19
+ yaml = adaptors_common.LazyImport('yaml')
20
+
16
21
  logger = logging.getLogger(__name__)
17
22
 
18
23
  # Timeout for deleting a Kubernetes resource (in seconds).
@@ -1,20 +1,26 @@
1
1
  """Kubernetes network provisioning utils."""
2
2
  import os
3
3
  import time
4
+ import typing
4
5
  from typing import Dict, List, Optional, Tuple, Union
5
6
 
6
- import jinja2
7
- import yaml
8
-
9
7
  import sky
10
8
  from sky import exceptions
11
9
  from sky import sky_logging
12
10
  from sky import skypilot_config
11
+ from sky.adaptors import common as adaptors_common
13
12
  from sky.adaptors import kubernetes
14
13
  from sky.provision.kubernetes import utils as kubernetes_utils
15
14
  from sky.utils import kubernetes_enums
16
15
  from sky.utils import ux_utils
17
16
 
17
+ if typing.TYPE_CHECKING:
18
+ import jinja2
19
+ import yaml
20
+ else:
21
+ jinja2 = adaptors_common.LazyImport('jinja2')
22
+ yaml = adaptors_common.LazyImport('yaml')
23
+
18
24
  logger = sky_logging.init_logger(__name__)
19
25
 
20
26
  _INGRESS_TEMPLATE_NAME = 'kubernetes-ingress.yml.j2'
@@ -12,15 +12,13 @@ import typing
12
12
  from typing import Any, Dict, List, Optional, Set, Tuple, Union
13
13
  from urllib.parse import urlparse
14
14
 
15
- import jinja2
16
- import yaml
17
-
18
15
  import sky
19
16
  from sky import clouds
20
17
  from sky import exceptions
21
18
  from sky import models
22
19
  from sky import sky_logging
23
20
  from sky import skypilot_config
21
+ from sky.adaptors import common as adaptors_common
24
22
  from sky.adaptors import gcp
25
23
  from sky.adaptors import kubernetes
26
24
  from sky.provision import constants as provision_constants
@@ -38,8 +36,14 @@ from sky.utils import timeline
38
36
  from sky.utils import ux_utils
39
37
 
40
38
  if typing.TYPE_CHECKING:
39
+ import jinja2
40
+ import yaml
41
+
41
42
  from sky import backends
42
43
  from sky import resources as resources_lib
44
+ else:
45
+ jinja2 = adaptors_common.LazyImport('jinja2')
46
+ yaml = adaptors_common.LazyImport('yaml')
43
47
 
44
48
  # TODO(romilb): Move constants to constants.py
45
49
  DEFAULT_NAMESPACE = 'default'
@@ -3,12 +3,17 @@
3
3
  import json
4
4
  import os
5
5
  import time
6
+ import typing
6
7
  from typing import Any, Dict, List, Optional, Tuple
7
8
 
8
- import requests
9
-
9
+ from sky.adaptors import common as adaptors_common
10
10
  from sky.utils import common_utils
11
11
 
12
+ if typing.TYPE_CHECKING:
13
+ import requests
14
+ else:
15
+ requests = adaptors_common.LazyImport('requests')
16
+
12
17
  CREDENTIALS_PATH = '~/.lambda_cloud/lambda_keys'
13
18
  API_ENDPOINT = 'https://cloud.lambdalabs.com/api/v1'
14
19
  INITIAL_BACKOFF_SECONDS = 10
@@ -76,7 +81,7 @@ class Metadata:
76
81
  json.dump(metadata, f)
77
82
 
78
83
 
79
- def raise_lambda_error(response: requests.Response) -> None:
84
+ def raise_lambda_error(response: 'requests.Response') -> None:
80
85
  """Raise LambdaCloudError if appropriate."""
81
86
  status_code = response.status_code
82
87
  if status_code == 200:
@@ -3,14 +3,19 @@
3
3
  import json
4
4
  import os
5
5
  import time
6
+ import typing
6
7
  from typing import Any, Dict, List, Optional, Union
7
8
 
8
- import requests
9
-
10
9
  from sky import sky_logging
10
+ from sky.adaptors import common as adaptors_common
11
11
  import sky.provision.paperspace.constants as constants
12
12
  from sky.utils import common_utils
13
13
 
14
+ if typing.TYPE_CHECKING:
15
+ import requests
16
+ else:
17
+ requests = adaptors_common.LazyImport('requests')
18
+
14
19
  logger = sky_logging.init_logger(__name__)
15
20
 
16
21
  CREDENTIALS_PATH = '~/.paperspace/config.json'
@@ -25,7 +30,7 @@ class PaperspaceCloudError(Exception):
25
30
  pass
26
31
 
27
32
 
28
- def raise_paperspace_api_error(response: requests.Response) -> None:
33
+ def raise_paperspace_api_error(response: 'requests.Response') -> None:
29
34
  """Raise PaperspaceCloudError if appropriate."""
30
35
  status_code = response.status_code
31
36
  if status_code == 200:
@@ -1,9 +1,14 @@
1
1
  """SSL Helper
2
2
  """
3
-
4
3
  import ssl
4
+ import typing
5
+
6
+ from sky.adaptors import common as adaptors_common
5
7
 
6
- import requests
8
+ if typing.TYPE_CHECKING:
9
+ import requests
10
+ else:
11
+ requests = adaptors_common.LazyImport('requests')
7
12
 
8
13
 
9
14
  def get_unverified_context():
@@ -1,11 +1,18 @@
1
1
  """Vapi Connect
2
2
  """
3
3
 
4
- import requests
4
+ import typing
5
+
5
6
  from urllib3.exceptions import InsecureRequestWarning
6
7
 
8
+ from sky.adaptors import common as adaptors_common
7
9
  from sky.adaptors import vsphere as vsphere_adaptor
8
10
 
11
+ if typing.TYPE_CHECKING:
12
+ import requests
13
+ else:
14
+ requests = adaptors_common.LazyImport('requests')
15
+
9
16
 
10
17
  def get_jsonrpc_endpoint_url(host):
11
18
  # The URL for the stub requests are made against the /api HTTP endpoint