mirror of
https://github.com/vale981/ray
synced 2025-03-05 10:01:43 -05:00
33 lines
714 B
Python
33 lines
714 B
Python
![]() |
"""Execute a jupytext markdown notebook."""
|
||
|
|
||
|
import subprocess
|
||
|
import argparse
|
||
|
import tempfile
|
||
|
import sys
|
||
|
|
||
|
import jupytext
|
||
|
|
||
|
parser = argparse.ArgumentParser(description="Run a jupytext parsable markdown file.")
|
||
|
parser.add_argument(
|
||
|
"--path",
|
||
|
help="path to the markdown file",
|
||
|
)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
|
||
|
args, remainder = parser.parse_known_args()
|
||
|
|
||
|
with open(args.path, "r") as f:
|
||
|
notebook = jupytext.read(f)
|
||
|
|
||
|
name = ""
|
||
|
with tempfile.NamedTemporaryFile("w", delete=False) as f:
|
||
|
jupytext.write(notebook, f, fmt="py:percent")
|
||
|
name = f.name
|
||
|
|
||
|
remainder.insert(0, name)
|
||
|
remainder.insert(0, sys.executable)
|
||
|
|
||
|
# Run the notebook
|
||
|
subprocess.run(remainder)
|