Skip to content

Commit d7f3087

Browse files
Merge pull request #96 from roboflow/feature/add_dataset_download_overwrite_flag
add dataset download overwrite flag
2 parents cbc2a85 + fa24a61 commit d7f3087

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

roboflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from roboflow.core.project import Project
99
from roboflow.core.workspace import Workspace
1010

11-
__version__ = "0.2.24"
11+
__version__ = "0.2.25"
1212

1313

1414
def check_key(api_key, model, notebook, num_retries=0):

roboflow/core/version.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,13 @@ def __wait_if_generating(self, recurse=False):
144144
sys.stdout.flush()
145145
return
146146

147-
def download(self, model_format=None, location=None):
147+
def download(self, model_format=None, location=None, overwrite: bool = True):
148148
"""
149149
Download and extract a ZIP of a version's dataset in a given format
150150
151151
:param model_format: A format to use for downloading
152152
:param location: An optional path for saving the file
153+
:param overwrite: An optional flag to prevent dataset overwrite when dataset is already downloaded
153154
154155
:return: Dataset
155156
"""
@@ -165,6 +166,10 @@ def download(self, model_format=None, location=None):
165166

166167
if location is None:
167168
location = self.__get_download_location()
169+
if os.path.exists(location) and not overwrite:
170+
return Dataset(
171+
self.name, self.version, model_format, os.path.abspath(location)
172+
)
168173

169174
if self.__api_key == "coco-128-sample":
170175
link = "https://app.roboflow.com/ds/n9QwXwUK42?key=NnVCe2yMxP"

0 commit comments

Comments
 (0)