Skip to content

Commit

Permalink
datasets support revision
Browse files Browse the repository at this point in the history
Signed-off-by: Zhiyuan Chen <[email protected]>
  • Loading branch information
ZhiyuanChen committed Dec 22, 2024
1 parent 6478b0c commit 1b6ff23
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions multimolecule/datasets/conversion_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def copy_readme(root: str, output_path: str):
shutil.copy2(os.path.join(root, readme), output_path)


def push_to_hub(convert_config: ConvertConfig, output_path: str, repo_type: str = "dataset"):
def push_to_hub(convert_config: ConvertConfig, output_path: str, repo_type: str = "dataset", revision: str = "main"):
if convert_config.push_to_hub:
if HfApi is None:
raise ImportError("Please install huggingface_hub to push to the hub.")
Expand All @@ -77,7 +77,11 @@ def push_to_hub(convert_config: ConvertConfig, output_path: str, repo_type: str
api.delete_repo(convert_config.repo_id, token=convert_config.token, missing_ok=True)
api.create_repo(convert_config.repo_id, token=convert_config.token, exist_ok=True, repo_type=repo_type)
api.upload_folder(
repo_id=convert_config.repo_id, folder_path=output_path, token=convert_config.token, repo_type=repo_type
repo_id=convert_config.repo_id,
folder_path=output_path,
token=convert_config.token,
repo_type=repo_type,
revision=revision,
)


Expand Down Expand Up @@ -109,6 +113,7 @@ class ConvertConfig(Config):
delete_existing: bool = False
repo_id: str | None = None
token: str | None = None
revision: str = "main"

def post(self):
if self.repo_id is None:
Expand Down

0 comments on commit 1b6ff23

Please sign in to comment.