Skip to content

Commit 1669a8c

Browse files
committed
add dataset download overwrite flag
1 parent cbc2a85 commit 1669a8c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

roboflow/core/version.py

Lines changed: 4 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,8 @@ 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(self.name, self.version, model_format, os.path.abspath(location))
168171

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

0 commit comments

Comments
 (0)