Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and JasonWeill committed Aug 7, 2023
1 parent 8a0a2ed commit 58eba46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions jupyter_scheduler/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def execute(self):
with fsspec.open(archive_filepath, "wb") as f:
f.write(fh.getvalue())


class AllFilesArchivingExecutionManager(DefaultExecutionManager):
"""Execution manager that, for automated runs, archives all output files
in and under the output directory into a single zip file
Expand Down Expand Up @@ -260,17 +261,17 @@ def execute(self):
else:
cls = nbconvert.get_exporter(output_format)
output, resources = cls().from_notebook_node(nb)
f = open(self.staging_paths[output_format], 'wb')
f = open(self.staging_paths[output_format], "wb")
f.write(bytes(output, "utf-8"))
f.close()
print(f"Wrote file {self.staging_paths[output_format]}\n")

if "zip" in job.output_formats:
# For automated runs, create a zip file of the current directory
# and everything under it
staging_dir = '.'
staging_dir = "."

# Truncate '.zip' off the end of the filename
basename = self.staging_paths["zip"][:-4]
shutil.make_archive(basename, 'zip', staging_dir)
shutil.make_archive(basename, "zip", staging_dir)
print(f"Wrote zip file {basename}.zip\n")
6 changes: 3 additions & 3 deletions jupyter_scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ def get_staging_paths(self, model: Union[DescribeJob, DescribeJobDefinition]) ->

return staging_paths


class AllFilesArchivingScheduler(Scheduler):
"""Scheduler that, for scheduled runs, captures all files in output directory in a zip file."""

Expand All @@ -739,14 +740,13 @@ def get_staging_paths(self, model: Union[DescribeJob, DescribeJobDefinition]) ->
# Create an output zip file for automated runs
if isinstance(model, DescribeJob) and model.job_definition_id is not None:
staging_paths["zip"] = create_output_filename(
model.input_filename,
model.create_time,
"zip"
model.input_filename, model.create_time, "zip"
)
staging_paths["input"] = os.path.join(self.staging_path, id, model.input_filename)

return staging_paths


class SchedulerWithErrors(Scheduler):
"""
Use only for testing exceptions, not to be used in production
Expand Down

0 comments on commit 58eba46

Please sign in to comment.