From d0c1743ebf763b3ffaa2a02e459da02a5b44365c Mon Sep 17 00:00:00 2001 From: AlejoPrietoDavalos Date: Tue, 6 May 2025 02:56:34 -0300 Subject: [PATCH 1/2] Optional arguments should not be mutable objects. --- roboflow/core/project.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/roboflow/core/project.py b/roboflow/core/project.py index 16fd789c..30a4361f 100644 --- a/roboflow/core/project.py +++ b/roboflow/core/project.py @@ -256,13 +256,7 @@ def generate_version(self, settings): def train( self, - new_version_settings={ - "preprocessing": { - "auto-orient": True, - "resize": {"width": 640, "height": 640, "format": "Stretch to"}, - }, - "augmentation": {}, - }, + new_version_settings=None, speed=None, checkpoint=None, plot_in_notebook=False, @@ -294,6 +288,15 @@ def train( >>> version.train() """ # noqa: E501 // docs + if new_version_settings is None: + new_version_settings = { + "preprocessing": { + "auto-orient": True, + "resize": {"width": 640, "height": 640, "format": "Stretch to"}, + }, + "augmentation": {}, + } + new_version = self.generate_version(settings=new_version_settings) new_version = self.version(new_version) new_model = new_version.train(speed=speed, checkpoint=checkpoint, plot_in_notebook=plot_in_notebook) @@ -557,13 +560,15 @@ def single_upload( split="train", num_retry_uploads=0, batch_name=None, - tag_names=[], + tag_names=None, is_prediction: bool = False, annotation_overwrite=False, sequence_number=None, sequence_size=None, **kwargs, ): + if tag_names is None: + tag_names = [] if image_path and image_id: raise Exception("You can't pass both image_id and image_path") if not (image_path or image_id): @@ -641,7 +646,7 @@ def search( in_dataset: Optional[str] = None, batch: bool = False, batch_id: Optional[str] = None, - fields: list = ["id", "created", "name", "labels"], + fields: Optional[list] = None, ): """ Search for images in a project. @@ -672,6 +677,9 @@ def search( """ # noqa: E501 // docs payload: Dict[str, Union[str, int, List[str]]] = {} + if fields is None: + fields = ["id", "created", "name", "labels"] + if like_image is not None: payload["like_image"] = like_image @@ -719,7 +727,7 @@ def search_all( in_dataset: Optional[str] = None, batch: bool = False, batch_id: Optional[str] = None, - fields: list = ["id", "created"], + fields: Optional[list] = None, ): """ Create a paginated list of search results for use in searching the images in a project. @@ -752,6 +760,10 @@ def search_all( >>> print(result) """ # noqa: E501 // docs + + if fields is None: + fields = ["id", "created"] + while True: data = self.search( like_image=like_image, From babbb6c6488a7a12a2ee9acafec34f5f34eb76a0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 06:00:38 +0000 Subject: [PATCH 2/2] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20?= =?UTF-8?q?format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roboflow/core/project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roboflow/core/project.py b/roboflow/core/project.py index 30a4361f..9b66ea1c 100644 --- a/roboflow/core/project.py +++ b/roboflow/core/project.py @@ -760,10 +760,10 @@ def search_all( >>> print(result) """ # noqa: E501 // docs - + if fields is None: fields = ["id", "created"] - + while True: data = self.search( like_image=like_image,