Skip to content

Commit a31d0c1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2982791 commit a31d0c1

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

jupyter_scheduler/executors.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ class ExecutionManager(ABC):
2929
_model = None
3030
_db_session = None
3131

32-
def __init__(
33-
self, job_id: str, root_dir: str, db_url: str, staging_paths: Dict[str, str]
34-
):
32+
def __init__(self, job_id: str, root_dir: str, db_url: str, staging_paths: Dict[str, str]):
3533
self.job_id = job_id
3634
self.staging_paths = staging_paths
3735
self.root_dir = root_dir
@@ -175,14 +173,10 @@ def add_side_effects_files(self, staging_dir: str):
175173
if new_files_set:
176174
with self.db_session() as session:
177175
current_packaged_files_set = set(
178-
session.query(Job.packaged_files)
179-
.filter(Job.job_id == self.job_id)
180-
.scalar()
176+
session.query(Job.packaged_files).filter(Job.job_id == self.job_id).scalar()
181177
or []
182178
)
183-
updated_packaged_files = list(
184-
current_packaged_files_set.union(new_files_set)
185-
)
179+
updated_packaged_files = list(current_packaged_files_set.union(new_files_set))
186180
session.query(Job).filter(Job.job_id == self.job_id).update(
187181
{"packaged_files": updated_packaged_files}
188182
)
@@ -192,9 +186,7 @@ def create_output_files(self, job: DescribeJob, notebook_node):
192186
for output_format in job.output_formats:
193187
cls = nbconvert.get_exporter(output_format)
194188
output, _ = cls().from_notebook_node(notebook_node)
195-
with fsspec.open(
196-
self.staging_paths[output_format], "w", encoding="utf-8"
197-
) as f:
189+
with fsspec.open(self.staging_paths[output_format], "w", encoding="utf-8") as f:
198190
f.write(output)
199191

200192
def supported_features(self) -> Dict[JobFeature, bool]:

jupyter_scheduler/tests/test_execution_manager.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ def test_update_completed_cells_hook_database_error():
157157
# Mock db_session with error
158158
mock_db_session = MagicMock()
159159
mock_session_context = MagicMock()
160-
mock_session_context.query.return_value.filter.return_value.update.side_effect = (
161-
Exception("DB Error")
160+
mock_session_context.query.return_value.filter.return_value.update.side_effect = Exception(
161+
"DB Error"
162162
)
163163
mock_db_session.return_value.__enter__.return_value = mock_session_context
164164
manager._db_session = mock_db_session
@@ -260,12 +260,8 @@ def supported_features(self):
260260
with patch.object(DisabledTrackingExecutionManager, "model") as mock_model:
261261
with patch("jupyter_scheduler.executors.open", mock=MagicMock()):
262262
with patch("jupyter_scheduler.executors.nbformat.read") as mock_nb_read:
263-
with patch.object(
264-
DisabledTrackingExecutionManager, "add_side_effects_files"
265-
):
266-
with patch.object(
267-
DisabledTrackingExecutionManager, "create_output_files"
268-
):
263+
with patch.object(DisabledTrackingExecutionManager, "add_side_effects_files"):
264+
with patch.object(DisabledTrackingExecutionManager, "create_output_files"):
269265
with patch(
270266
"jupyter_scheduler.executors.ExecutePreprocessor"
271267
) as mock_ep_class:

0 commit comments

Comments
 (0)