MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / update_metadata

Function update_metadata

diffusers/utils/update_metadata.py:75–118  ·  view source on GitHub ↗

Update the metadata for the Diffusers repo in `huggingface/diffusers-metadata`. Args: commit_sha (`str`): The commit SHA on Diffusers corresponding to this update.

(commit_sha: str)

Source from the content-addressed store, hash-verified

73
74
75def update_metadata(commit_sha: str):
76 """
77 Update the metadata for the Diffusers repo in `huggingface/diffusers-metadata`.
78
79 Args:
80 commit_sha (`str`): The commit SHA on Diffusers corresponding to this update.
81 """
82 pipelines_table = get_supported_pipeline_table()
83 pipelines_table = pd.DataFrame(pipelines_table)
84 pipelines_dataset = Dataset.from_pandas(pipelines_table)
85
86 hub_pipeline_tags_json = hf_hub_download(
87 repo_id="huggingface/diffusers-metadata",
88 filename=PIPELINE_TAG_JSON,
89 repo_type="dataset",
90 )
91 with open(hub_pipeline_tags_json) as f:
92 hub_pipeline_tags_json = f.read()
93
94 with tempfile.TemporaryDirectory() as tmp_dir:
95 pipelines_dataset.to_json(os.path.join(tmp_dir, PIPELINE_TAG_JSON))
96
97 with open(os.path.join(tmp_dir, PIPELINE_TAG_JSON)) as f:
98 pipeline_tags_json = f.read()
99
100 hub_pipeline_tags_equal = hub_pipeline_tags_json == pipeline_tags_json
101 if hub_pipeline_tags_equal:
102 print("No updates, not pushing the metadata files.")
103 return
104
105 if commit_sha is not None:
106 commit_message = (
107 f"Update with commit {commit_sha}\n\nSee: "
108 f"https://github.com/huggingface/diffusers/commit/{commit_sha}"
109 )
110 else:
111 commit_message = "Update"
112
113 upload_folder(
114 repo_id="huggingface/diffusers-metadata",
115 folder_path=tmp_dir,
116 repo_type="dataset",
117 commit_message=commit_message,
118 )
119
120
121if __name__ == "__main__":

Callers 1

update_metadata.pyFile · 0.85

Calls 1

Tested by

no test coverage detected