Skip to content

Commit

Permalink
MAINT: use st_mtime for tracking modifications
Browse files Browse the repository at this point in the history
[docs only]
  • Loading branch information
agriyakhetarpal committed Dec 4, 2024
1 parent ed82988 commit c5228f5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions doc/convert_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ def call_jupytext(md_files, _contents_path, _contents_cache_path):
return True

is_dirty = False

for md_file in md_files:
basename = os.path.splitext(os.path.basename(md_file))[0]
output_path = os.path.join(_contents_path, f"{basename}.ipynb")
cached_output_path = os.path.join(_contents_cache_path, f"{basename}.ipynb")
cmd_execution_time = os.path.getctime(cached_output_path)
md_file_modification_time = os.path.getmtime(md_file)
if cmd_execution_time <= md_file_modification_time:
cmd_execution_time = os.stat(cached_output_path).st_mtime
md_file_modification_time = os.stat(md_file).st_mtime
if cmd_execution_time < md_file_modification_time:
nb = jupytext.read(md_file)
jupytext.write(nb, output_path, fmt="ipynb", version=4)
is_dirty = True
Expand All @@ -35,6 +36,7 @@ def call_jupytext(md_files, _contents_path, _contents_cache_path):
if __name__ == '__main__':
_contents_cache_path = os.path.join("build", "_contents")
_contents_path = os.path.join("source", "_contents")

os.makedirs(os.path.expanduser(_contents_path), exist_ok=True)

md_files = glob.glob("source/tutorial/stats/*.md")
Expand Down

0 comments on commit c5228f5

Please sign in to comment.