descriptron-gui 2.0.3__tar.gz → 2.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: descriptron-gui
3
- Version: 2.0.3
3
+ Version: 2.0.4
4
4
  Summary: The Descriptron annotation GUI: SAM2-assisted segmentation, keypoints and COCO export
5
5
  Project-URL: Homepage, https://github.com/alexrvandam/Descriptron
6
6
  Author: Alex R. Van Dam
@@ -14,8 +14,8 @@ Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Topic :: Scientific/Engineering :: Image Processing
16
16
  Requires-Python: >=3.9
17
- Requires-Dist: descriptron-core==2.0.3
18
- Requires-Dist: descriptron-vision==2.0.3
17
+ Requires-Dist: descriptron-core==2.0.4
18
+ Requires-Dist: descriptron-vision==2.0.4
19
19
  Provides-Extra: dev
20
20
  Requires-Dist: build>=1; extra == 'dev'
21
21
  Requires-Dist: pytest>=7; extra == 'dev'
@@ -0,0 +1,45 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "descriptron-gui"
7
+ version = "2.0.4"
8
+ description = "The Descriptron annotation GUI: SAM2-assisted segmentation, keypoints and COCO export"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "Apache-2.0" }
12
+ authors = [{ name = "Alex R. Van Dam" }]
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "Environment :: X11 Applications",
16
+ "Topic :: Scientific/Engineering :: Image Processing",
17
+ "Intended Audience :: Science/Research",
18
+ "License :: OSI Approved :: Apache Software License",
19
+ "Operating System :: OS Independent",
20
+ ]
21
+
22
+ # tkinter is part of the standard library and so is not listed here, but it is
23
+ # not always packaged with Python on Linux: `apt install python3-tk` if the GUI
24
+ # fails to start. The GUI drives the analysis scripts directly, so it needs core
25
+ # as well as vision — it is not a thin front end.
26
+ dependencies = [
27
+ "descriptron-core==2.0.4",
28
+ "descriptron-vision==2.0.4",
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ dev = ["pytest>=7", "build>=1", "twine>=5"]
33
+
34
+ [project.scripts]
35
+ descriptron-gui = "descriptron_gui.cli:main"
36
+
37
+ [project.gui-scripts]
38
+ # on Windows this launches without a console window behind it
39
+ descriptron-gui-app = "descriptron_gui.cli:main"
40
+
41
+ [project.urls]
42
+ Homepage = "https://github.com/alexrvandam/Descriptron"
43
+
44
+ [tool.hatch.build.targets.wheel]
45
+ packages = ["src/descriptron_gui"]
@@ -14461,6 +14461,10 @@ def open_biorag_popup():
14461
14461
  if not _sh.which("claude"):
14462
14462
  messagebox.showerror("Error", "Claude Code CLI ('claude') not found on PATH. Install and log in, or choose the 'api' backend.")
14463
14463
  return
14464
+ if llm_backend_var.get() == "api" and not _descriptron_key_gui("ANTHROPIC_API_KEY", parent=popup): # v2.0.4
14465
+ if not messagebox.askyesno("No API key", "No ANTHROPIC_API_KEY is set, so the species descriptions "
14466
+ "cannot be written. Run anyway (matrix, key and evidence sheets only)?"):
14467
+ return
14464
14468
 
14465
14469
  script = os.path.join(os.path.dirname(os.path.abspath(__file__)), "measure",
14466
14470
  "run_full_pipeline_v2.py" if workflow_var.get() == "v2" else "run_full_pipeline.py")
@@ -15492,6 +15496,45 @@ next_image_button.grid(row=2, column=13, padx=0, pady=0)
15492
15496
  DINOLAND_ENV = os.environ.get("DINOLAND_ENV", "biorag")
15493
15497
 
15494
15498
 
15499
+ def _descriptron_key_gui(name, parent=None, model_id=None):
15500
+ """v2.0.4: make sure `name` (ANTHROPIC_API_KEY or HF_TOKEN) is available to the programs this GUI
15501
+ launches: environment, then ~/.config/descriptron/credentials, then — first use only — a dialog.
15502
+ For HF_TOKEN nothing is asked when the DINOv3 weights are already cached (or cannot be checked).
15503
+ Switched off entirely by DESCRIPTRON_NO_KEY_PROMPT=1. Keys are never logged."""
15504
+ import sys as _sys
15505
+ here = os.path.dirname(os.path.abspath(__file__))
15506
+ if os.path.join(here, "measure") not in _sys.path:
15507
+ _sys.path.append(os.path.join(here, "measure"))
15508
+ try:
15509
+ import descriptron_credentials as _c
15510
+ except ImportError:
15511
+ try:
15512
+ from descriptron_core.cli import tools_dir as _td
15513
+ _sys.path.append(str(_td()))
15514
+ import descriptron_credentials as _c
15515
+ except Exception:
15516
+ return None
15517
+ _c.load_into_environment()
15518
+ if name == "HF_TOKEN":
15519
+ if not model_id or os.path.isdir(os.path.expanduser(model_id)) or os.environ.get("HF_HUB_OFFLINE") == "1":
15520
+ return None
15521
+ try:
15522
+ from huggingface_hub import try_to_load_from_cache
15523
+ if isinstance(try_to_load_from_cache(model_id, "config.json"), str):
15524
+ return None
15525
+ except Exception:
15526
+ return None
15527
+
15528
+ def _ask(n, purpose, where):
15529
+ from tkinter import simpledialog
15530
+ return simpledialog.askstring(
15531
+ "Descriptron: key needed",
15532
+ f"{n} is needed for {purpose}.\n\nGet one at:\n{where}\n\n"
15533
+ f"It is saved, readable by you only, in\n{_c.credentials_path()}\n"
15534
+ f"so you are asked only once. Leave empty to skip.", show="*", parent=parent)
15535
+ return _c.ensure_key(name, ask=_ask)
15536
+
15537
+
15495
15538
  def _dinoland_build_cmd(v, script_path, env=None):
15496
15539
  """Turn the DINOLand dialog values into the dinov3_landmark_transfer_v51.py command.
15497
15540
  Kept separate from the Tk code so it can be unit-tested without a display."""
@@ -15675,6 +15718,7 @@ def run_dinoland_script():
15675
15718
  if not dinoland_script.is_file():
15676
15719
  messagebox.showerror("Script Error", f"DINOLand script not found at: {dinoland_script}")
15677
15720
  return
15721
+ _descriptron_key_gui("HF_TOKEN", parent=input_window, model_id=v.get("model")) # v2.0.4
15678
15722
  cmd = _dinoland_build_cmd(v, dinoland_script)
15679
15723
  out_path = Path(v["outdir"]); out_path.mkdir(parents=True, exist_ok=True)
15680
15724
  log_path = out_path / "dinoland_run.log"
File without changes
File without changes