MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / update_files

Function update_files

tools/docs_and_notebooks_check.py:733–825  ·  view source on GitHub ↗
(
    repo_root: Path,
    cfg: ToolConfig,
    targets: list[str] | None,
    write: bool,
    set_content_date_from_git: bool,
    set_last_verified: date | None,
    set_verified_for: str | None,
    ack_meta_commit_marker: bool,
)

Source from the content-addressed store, hash-verified

731
732
733def update_files(
734 repo_root: Path,
735 cfg: ToolConfig,
736 targets: list[str] | None,
737 write: bool,
738 set_content_date_from_git: bool,
739 set_last_verified: date | None,
740 set_verified_for: str | None,
741 ack_meta_commit_marker: bool,
742) -> list[FileRecord]:
743 today = _iso_today()
744 records = scan_files(repo_root, cfg, targets=targets)
745
746 for rec in records:
747 if rec.kind not in {"ipynb", "md"}:
748 continue
749 if rec.meta and rec.meta.ignore:
750 continue
751
752 meta = rec.meta or DLCMeta()
753
754 # Build the desired metadata WITHOUT touching last_metadata_updated.
755 if set_content_date_from_git and rec.last_content_updated is not None:
756 meta.last_content_updated = rec.last_content_updated
757
758 if set_last_verified is not None:
759 meta.last_verified = set_last_verified
760 if set_verified_for is not None:
761 meta.verified_for = set_verified_for
762
763 desired_base = meta_to_jsonable(meta)
764 abs_path = repo_root / rec.path
765 changed = False
766
767 if rec.kind == "ipynb":
768 nb, _raw, _has_dlc = read_ipynb_meta(abs_path)
769 nb_meta = nb.setdefault("metadata", {})
770 prev = nb_meta.get(DLC_NAMESPACE, {})
771 if not isinstance(prev, dict):
772 prev = {}
773
774 merged_base = dict(prev)
775 merged_base.update(desired_base)
776
777 if merged_base != prev:
778 changed = True
779 if write:
780 _require_meta_marker_ack(write=True, ack_marker=ack_meta_commit_marker)
781
782 meta.last_metadata_updated = today
783 desired_final = meta_to_jsonable(meta)
784
785 merged_final = dict(prev)
786 merged_final.update(desired_final)
787 nb_meta[DLC_NAMESPACE] = merged_final
788 write_ipynb_meta(abs_path, nb)
789
790 elif rec.kind == "md":

Callers 1

mainFunction · 0.85

Calls 12

_iso_todayFunction · 0.85
scan_filesFunction · 0.85
DLCMetaClass · 0.85
meta_to_jsonableFunction · 0.85
read_ipynb_metaFunction · 0.85
_require_meta_marker_ackFunction · 0.85
write_ipynb_metaFunction · 0.85
read_md_frontmatterFunction · 0.85
dump_md_frontmatterFunction · 0.85
compute_days_sinceFunction · 0.85
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected