Skip to content

Commit

Permalink
Merge pull request #2 from ASIDataScience/return-paths-in-tmpdir
Browse files Browse the repository at this point in the history
return paths in tmpdir; update docstring
  • Loading branch information
janfreyberg committed Dec 3, 2018
2 parents f451657 + 37453f1 commit 54a57d3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions faculty_mill/faculty_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@


@contextmanager
def tmpdir():
def tmpdir() -> Path:
if Path("/project").is_dir():
with TemporaryDirectory(prefix=".", dir="/project") as tmpdir:
yield tmpdir
yield Path(tmpdir)
else:
with TemporaryDirectory(prefix=".") as tmpdir:
yield tmpdir
yield Path(tmpdir)


@click.command(
Expand Down Expand Up @@ -67,6 +67,8 @@ def main(
Publish a report from NOTEBOOK under the name REPORT_NAME in the
current project.
Pass '-' as NOTEBOOK in order to parse file content from stdin.
This command supports all flags and options that papermill supports.
"""

Expand All @@ -75,12 +77,11 @@ def main(
report_client = sherlockml.client("report")

with tmpdir() as directory:
directory = Path(directory)

input_path = directory / "input.ipynb"
output_path = directory / "output.ipynb"

# write the input file to the new file
# write the input file to the new, temporary input file
# this is to allow processing of stdin
with input_path.open("w") as input_file:
shutil.copyfileobj(notebook, input_file)

Expand Down

0 comments on commit 54a57d3

Please sign in to comment.