File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed
Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -138,25 +138,25 @@ def _partitioned_test_cases(notebooks):
138138
139139def _rewrite_and_run_notebook (notebook_path , cloned_env ):
140140 notebook_file = os .path .basename (notebook_path )
141- notebook_rel_dir = os .path .dirname (os .path .relpath (notebook_path , "." ))
141+ notebook_rel_dir = os .path .dirname (os .path .relpath (notebook_path , REPO_ROOT ))
142142 out_path = f"out/{ notebook_rel_dir } /{ notebook_file [:- 6 ]} .out.ipynb"
143143 notebook_env = cloned_env ("isolated_notebook_tests" , * PACKAGES )
144144
145145 notebook_file = os .path .basename (notebook_path )
146146
147147 rewritten_notebook_path = rewrite_notebook (notebook_path )
148148
149+ REPO_ROOT .joinpath ("out" , notebook_rel_dir ).mkdir (parents = True , exist_ok = True )
149150 cmd = f"""
150- mkdir -p out/{ notebook_rel_dir }
151- cd { notebook_env }
152151. ./bin/activate
153152pip list
154- papermill { rewritten_notebook_path } { os . getcwd () } / { out_path } """
153+ papermill { rewritten_notebook_path } { REPO_ROOT / out_path } """
155154 result = shell_tools .run (
156155 cmd ,
157156 log_run_to_stderr = False ,
158157 shell = True ,
159158 check = False ,
159+ cwd = notebook_env ,
160160 capture_output = True ,
161161 # important to get rid of PYTHONPATH specifically, which contains
162162 # the Cirq repo path due to check/pytest
Original file line number Diff line number Diff line change @@ -107,18 +107,19 @@ def test_notebooks_against_cirq_head(
107107 Lines in this file that do not have `->` are ignored.
108108 """
109109 notebook_file = os .path .basename (notebook_path )
110- notebook_rel_dir = os .path .dirname (os .path .relpath (notebook_path , "." ))
110+ notebook_rel_dir = os .path .dirname (os .path .relpath (notebook_path , REPO_ROOT ))
111111 out_path = f"out/{ notebook_rel_dir } /{ notebook_file [:- 6 ]} .out.ipynb"
112112 rewritten_notebook_path = rewrite_notebook (notebook_path )
113113 papermill_flags = "--no-request-save-on-cell-execute --autosave-cell-every 0"
114- cmd = f"""mkdir -p out/{ notebook_rel_dir }
115- papermill { rewritten_notebook_path } { out_path } { papermill_flags } """
114+ cmd = f"papermill { rewritten_notebook_path } { REPO_ROOT / out_path } { papermill_flags } "
116115
116+ REPO_ROOT .joinpath ("out" , notebook_rel_dir ).mkdir (parents = True , exist_ok = True )
117117 result = shell_tools .run (
118118 cmd ,
119119 log_run_to_stderr = False ,
120120 shell = True ,
121121 check = False ,
122+ cwd = REPO_ROOT ,
122123 capture_output = True ,
123124 env = env_with_temporary_pip_target ,
124125 )
You can’t perform that action at this time.
0 commit comments