Skip to content

Commit f4b1063

Browse files
committed
refactor!: default auto_save to true and rename --autosave to --no-autosave
Auto save is now enabled by default. The --autosave CLI flag is replaced by --no-autosave to disable it. The old --autosave flag is kept as a deprecated alias with a FutureWarning guiding users to the new default.
1 parent f5201dd commit f4b1063

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

examples/bbox_detection/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## Usage
55

66
```bash
7-
labelme data_annotated --labels labels.txt --autosave
7+
labelme data_annotated --labels labels.txt
88
```
99

1010
![](.readme/annotation.jpg)

labelme/__main__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,17 @@ def main():
137137
default=argparse.SUPPRESS,
138138
)
139139
parser.add_argument(
140-
"--autosave",
140+
"--no-autosave",
141141
dest="auto_save",
142+
action="store_false",
143+
help="disable auto save",
144+
default=argparse.SUPPRESS,
145+
)
146+
parser.add_argument(
147+
"--autosave",
148+
dest="_deprecated_autosave",
142149
action="store_true",
143-
help="auto save",
150+
help=argparse.SUPPRESS,
144151
default=argparse.SUPPRESS,
145152
)
146153
parser.add_argument(
@@ -199,6 +206,15 @@ def main():
199206
)
200207
del args._deprecated_nodata
201208

209+
if hasattr(args, "_deprecated_autosave"):
210+
warnings.warn(
211+
"--autosave is deprecated and will be removed in a future version. "
212+
"Auto save is now enabled by default. Use --no-autosave to disable it.",
213+
FutureWarning,
214+
stacklevel=1,
215+
)
216+
del args._deprecated_autosave
217+
202218
if args.version:
203219
print(f"{__appname__} {__version__}")
204220
sys.exit(0)

labelme/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def get_user_config_file(create_if_missing: bool = True) -> str:
7373
"#\n"
7474
"# Example:\n"
7575
"# with_image_data: true\n"
76-
"# auto_save: true\n"
76+
"# auto_save: false\n"
7777
"# labels: [cat, dog]\n"
7878
)
7979
except Exception:

labelme/config/default_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
auto_save: false
1+
auto_save: true
22
display_label_popup: true
33
with_image_data: false
44
keep_prev: false

tests/e2e/config_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ def test_MainWindow_config(
2424
monkeypatch: pytest.MonkeyPatch,
2525
) -> None:
2626
config_file: Path | None = None
27-
auto_save: bool = False
27+
auto_save: bool = True
2828
if with_config_file:
2929
config_file = tmp_path / "labelmerc.yaml"
30-
config_file.write_text("auto_save: true\nlabels: [cat, dog]\n")
31-
auto_save = True
30+
config_file.write_text("auto_save: false\nlabels: [cat, dog]\n")
31+
auto_save = False
3232

3333
win: labelme.app.MainWindow = labelme.app.MainWindow(
3434
config_file=config_file,

0 commit comments

Comments
 (0)