From c752ed319d182052b6b7d405c70676f1307d1a65 Mon Sep 17 00:00:00 2001 From: SeanHH86 <154984842+SeanHH86@users.noreply.github.com> Date: Wed, 9 Oct 2024 21:35:05 +0800 Subject: [PATCH] Support single file upload and bug fix (#45) * Support upload single file * update * Reset dependencies version --- pycsghub/repository.py | 9 +++++--- setup.py | 50 +++++++++++++++++++++--------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/pycsghub/repository.py b/pycsghub/repository.py index 04394ee..ec32090 100644 --- a/pycsghub/repository.py +++ b/pycsghub/repository.py @@ -43,7 +43,7 @@ def __init__( self.endpoint = endpoint self.auto_create = auto_create self.copy_files = copy_files - self.repo_url_prefix = self.repo_url_prefix() + self.repo_url_prefix = self.get_url_prefix() self.namespace, self.name = model_id_to_group_owner_name(model_id=self.repo_id) self.repo_dir = os.path.join(self.work_dir, self.name) @@ -84,7 +84,7 @@ def upload(self) -> None: def copy_repo_files(self): from_path = "" git_cmd_workdir = "" - if self.copy_files: + if self.copy_files or os.path.isfile(self.upload_path): from_path = self.upload_path git_cmd_workdir = self.repo_dir @@ -96,7 +96,10 @@ def copy_repo_files(self): elif os.path.isdir(item_path): shutil.rmtree(item_path) - shutil.copytree(from_path, git_cmd_workdir, dirs_exist_ok=True) + if os.path.isfile(self.upload_path): + shutil.copyfile(self.upload_path, git_cmd_workdir) + else: + shutil.copytree(from_path, git_cmd_workdir, dirs_exist_ok=True) else: from_path = self.repo_dir git_cmd_workdir = self.upload_path diff --git a/setup.py b/setup.py index 614ffc4..85d6e63 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='csghub-sdk', - version='0.3.8', + version='0.3.9', author="opencsg", author_email="contact@opencsg.com", long_description=long_description, @@ -18,38 +18,38 @@ ] }, install_requires=[ - "typer==0.12.3", - "attr==0.3.2", - "ConfigParser==7.0.0", - "contextlib2==21.6.0", - "cryptography==43.0.1", - "Cython==3.0.10", - "dl==0.1.0", - "docutils==0.21.2", - "HTMLParser==0.0.2", + "typer>=0.12.3", + "attr>=0.3.2", + "ConfigParser>=7.0.0", + "contextlib2>=21.6.0", + "cryptography>=43.0.1", + "Cython>=3.0.10", + "dl>=0.1.0", + "docutils>=0.21.2", + "HTMLParser>=0.0.2", "huggingface_hub>=0.22.2", - "ipython==8.12.3", - "ipywidgets==8.1.2", - "keyring==25.2.1", - "lockfile==0.12.2", - "mock==5.1.0", - "Pillow==10.3.0", - "protobuf==5.27.0", + "ipython>=8.12.3", + "ipywidgets>=8.1.2", + "keyring>=25.2.1", + "lockfile>=0.12.2", + "mock>=5.1.0", + "Pillow>=10.3.0", + "protobuf>=5.27.0", "pyOpenSSL>=24.1.0", - "railroad==0.5.0", - "Sphinx==7.3.7", - "thread==2.0.3", + "railroad>=0.5.0", + "Sphinx>=7.3.7", + "thread>=2.0.3", "tornado>=6.4.1", - "tqdm==4.66.3", - "trove_classifiers==2024.5.22", - "truststore==0.9.1", - "urllib3_secure_extra==0.1.0", + "tqdm>=4.66.3", + "trove_classifiers>=2024.5.22", + "truststore>=0.9.1", + "urllib3_secure_extra>=0.1.0", ], extras_require={ "train": [ "torch", "transformers>=4.33.3", - "datasets==2.20.0" + "datasets>=2.20.0" ], }, python_requires=">=3.10",