Skip to content

Commit dd82b84

Browse files
committed
fix lints
Signed-off-by: Rahim Dharssi <[email protected]>
1 parent ecd5daa commit dd82b84

File tree

4 files changed

+24
-31
lines changed

4 files changed

+24
-31
lines changed

nemo_run/core/execution/skypilot_jobs.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
_SKYPILOT_AVAILABLE = True
2525
except ImportError:
26-
...
26+
pass
2727

2828
logger = logging.getLogger(__name__)
2929

@@ -110,7 +110,7 @@ class SkypilotJobsExecutor(Executor):
110110
infra: Optional[str] = None
111111
network_tier: Optional[str] = None
112112
retry_until_up: bool = False
113-
packager: Packager = field(default_factory=lambda: GitArchivePackager()) # type: ignore # noqa: F821
113+
packager: Packager = field(default_factory=GitArchivePackager) # type: ignore # noqa: F821
114114

115115
def __post_init__(self):
116116
assert _SKYPILOT_AVAILABLE, (
@@ -204,9 +204,7 @@ def parse_attr(attr: str):
204204
return resources # type: ignore
205205

206206
@classmethod
207-
def status(
208-
cls: Type["SkypilotJobsExecutor"], app_id: str
209-
) -> Optional[dict]:
207+
def status(cls: Type["SkypilotJobsExecutor"], app_id: str) -> Optional[dict]:
210208
from sky import stream_and_get
211209
import sky.exceptions as sky_exceptions
212210
import sky.jobs.client.sdk as sky_jobs
@@ -215,11 +213,7 @@ def status(
215213

216214
try:
217215
job_details: List[Dict[str, Any]] = stream_and_get(
218-
sky_jobs.queue(
219-
refresh=True,
220-
all_users=True,
221-
job_ids=[job_id]
222-
),
216+
sky_jobs.queue(refresh=True, all_users=True, job_ids=[job_id]),
223217
)[0]
224218
except sky_exceptions.ClusterNotUpError:
225219
return None
@@ -400,15 +394,13 @@ def launch(
400394
task: "skyt.Task",
401395
num_nodes: Optional[int] = None,
402396
) -> tuple[Optional[int], Optional["backends.ResourceHandle"]]:
403-
from sky import stream_and_get, skypilot_config
397+
from sky import stream_and_get
404398
from sky.jobs.client.sdk import launch
405399

406400
if num_nodes:
407401
task.num_nodes = num_nodes
408402

409-
job_id, handle = stream_and_get(
410-
launch(task)
411-
)
403+
job_id, handle = stream_and_get(launch(task))
412404

413405
return job_id, handle
414406

nemo_run/run/torchx_backend/schedulers/skypilot_jobs.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import logging
32
import os
43
import shutil
54
import tempfile
@@ -57,9 +56,8 @@
5756
ManagedJobStatus.FAILED_CONTROLLER: AppState.FAILED,
5857
}
5958
except ImportError:
60-
...
59+
pass
6160

62-
log: logging.Logger = logging.getLogger(__name__)
6361
SKYPILOT_JOB_DIRS = os.path.join(get_nemorun_home(), ".skypilot_jobs.json")
6462

6563

@@ -187,7 +185,8 @@ def describe(self, app_id: str) -> Optional[DescribeAppResponse]:
187185
def _cancel_existing(self, app_id: str) -> None:
188186
SkypilotJobsExecutor.cancel(app_id=app_id)
189187

190-
def list(self) -> list[ListAppResponse]: ...
188+
def list(self) -> list[ListAppResponse]:
189+
pass
191190

192191

193192
def create_scheduler(session_name: str, **kwargs: Any) -> SkypilotJobsScheduler:

test/core/execution/test_skypilot_jobs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ def test_to_task(self, mock_task, mock_skypilot_imports, executor):
371371
executor.job_dir = tmp_dir
372372
executor.file_mounts = {"test_file": "/path/to/test_file"}
373373

374-
result = executor.to_task("test_task", ["python", "train.py"], {"TEST_VAR": "test_value"})
374+
result = executor.to_task(
375+
"test_task", ["python", "train.py"], {"TEST_VAR": "test_value"}
376+
)
375377

376378
mock_task.assert_called_once()
377379
assert mock_task.call_args[1]["name"] == "test_task"

test/run/torchx_backend/schedulers/test_skypilot_jobs.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ def test_cancel_existing(skypilot_jobs_scheduler):
8989
def test_describe_no_status(skypilot_jobs_scheduler):
9090
with (
9191
mock.patch.object(SkypilotJobsExecutor, "status") as mock_status,
92-
mock.patch("nemo_run.run.torchx_backend.schedulers.skypilot_jobs._get_job_dirs") as mock_get_job_dirs,
92+
mock.patch(
93+
"nemo_run.run.torchx_backend.schedulers.skypilot_jobs._get_job_dirs"
94+
) as mock_get_job_dirs,
9395
):
9496
mock_status.return_value = None
9597
mock_get_job_dirs.return_value = {}
@@ -101,14 +103,13 @@ def test_describe_no_status(skypilot_jobs_scheduler):
101103
def test_describe_with_status(skypilot_jobs_scheduler):
102104
from sky.jobs.state import ManagedJobStatus
103105

104-
task_details = {
105-
"status": ManagedJobStatus.RUNNING,
106-
"job_id": 123
107-
}
106+
task_details = {"status": ManagedJobStatus.RUNNING, "job_id": 123}
108107

109108
with (
110109
mock.patch.object(SkypilotJobsExecutor, "status") as mock_status,
111-
mock.patch("nemo_run.run.torchx_backend.schedulers.skypilot_jobs._save_job_dir") as mock_save,
110+
mock.patch(
111+
"nemo_run.run.torchx_backend.schedulers.skypilot_jobs._save_job_dir"
112+
) as mock_save,
112113
):
113114
mock_status.return_value = task_details
114115

@@ -122,15 +123,13 @@ def test_describe_with_status(skypilot_jobs_scheduler):
122123

123124

124125
def test_describe_with_past_jobs(skypilot_jobs_scheduler):
125-
past_apps = {
126-
"test_cluster___test_role___123": {
127-
"job_status": "SUCCEEDED"
128-
}
129-
}
126+
past_apps = {"test_cluster___test_role___123": {"job_status": "SUCCEEDED"}}
130127

131128
with (
132129
mock.patch.object(SkypilotJobsExecutor, "status") as mock_status,
133-
mock.patch("nemo_run.run.torchx_backend.schedulers.skypilot_jobs._get_job_dirs") as mock_get_job_dirs,
130+
mock.patch(
131+
"nemo_run.run.torchx_backend.schedulers.skypilot_jobs._get_job_dirs"
132+
) as mock_get_job_dirs,
134133
):
135134
mock_status.return_value = None
136135
mock_get_job_dirs.return_value = past_apps
@@ -141,4 +140,5 @@ def test_describe_with_past_jobs(skypilot_jobs_scheduler):
141140
assert result.app_id == "test_cluster___test_role___123"
142141
# The state should be mapped from SUCCEEDED status
143142
from torchx.specs import AppState
143+
144144
assert result.state == AppState.SUCCEEDED

0 commit comments

Comments
 (0)