accli 2.1.5__tar.gz → 2.1.6__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.
Files changed (37) hide show
  1. {accli-2.1.5 → accli-2.1.6}/PKG-INFO +1 -1
  2. {accli-2.1.5 → accli-2.1.6}/accli/_version.py +1 -1
  3. {accli-2.1.5 → accli-2.1.6}/accli/cli.py +56 -3
  4. {accli-2.1.5 → accli-2.1.6}/accli/mount_downloader.py +1 -1
  5. {accli-2.1.5 → accli-2.1.6}/accli/nfs_watcher.py +21 -2
  6. {accli-2.1.5 → accli-2.1.6}/accli.egg-info/PKG-INFO +1 -1
  7. {accli-2.1.5 → accli-2.1.6}/LICENSE +0 -0
  8. {accli-2.1.5 → accli-2.1.6}/README.md +0 -0
  9. {accli-2.1.5 → accli-2.1.6}/accli/AcceleratorJobProjectService.py +0 -0
  10. {accli-2.1.5 → accli-2.1.6}/accli/AcceleratorTaskDispatcher.py +0 -0
  11. {accli-2.1.5 → accli-2.1.6}/accli/AcceleratorTerminalCliProjectService.py +0 -0
  12. {accli-2.1.5 → accli-2.1.6}/accli/CsvRegionalTimeseriesValidator.py +0 -0
  13. {accli-2.1.5 → accli-2.1.6}/accli/__init__.py +0 -0
  14. {accli-2.1.5 → accli-2.1.6}/accli/__main__.py +0 -0
  15. {accli-2.1.5 → accli-2.1.6}/accli/acc_logo.ico +0 -0
  16. {accli-2.1.5 → accli-2.1.6}/accli/acc_logo.png +0 -0
  17. {accli-2.1.5 → accli-2.1.6}/accli/cleanup-nfs.ps1 +0 -0
  18. {accli-2.1.5 → accli-2.1.6}/accli/common.py +0 -0
  19. {accli-2.1.5 → accli-2.1.6}/accli/gui.py +0 -0
  20. {accli-2.1.5 → accli-2.1.6}/accli/job_views.py +0 -0
  21. {accli-2.1.5 → accli-2.1.6}/accli/log_timeline.py +0 -0
  22. {accli-2.1.5 → accli-2.1.6}/accli/refresh_explorer.ps1 +0 -0
  23. {accli-2.1.5 → accli-2.1.6}/accli/setup-nfs.ps1 +0 -0
  24. {accli-2.1.5 → accli-2.1.6}/accli/token.py +0 -0
  25. {accli-2.1.5 → accli-2.1.6}/accli/version_checker.py +0 -0
  26. {accli-2.1.5 → accli-2.1.6}/accli.egg-info/SOURCES.txt +0 -0
  27. {accli-2.1.5 → accli-2.1.6}/accli.egg-info/dependency_links.txt +0 -0
  28. {accli-2.1.5 → accli-2.1.6}/accli.egg-info/entry_points.txt +0 -0
  29. {accli-2.1.5 → accli-2.1.6}/accli.egg-info/requires.txt +0 -0
  30. {accli-2.1.5 → accli-2.1.6}/accli.egg-info/top_level.txt +0 -0
  31. {accli-2.1.5 → accli-2.1.6}/pyproject.toml +0 -0
  32. {accli-2.1.5 → accli-2.1.6}/setup.cfg +0 -0
  33. {accli-2.1.5 → accli-2.1.6}/tests/test_jobs_commands.py +0 -0
  34. {accli-2.1.5 → accli-2.1.6}/tests/test_log_timeline.py +0 -0
  35. {accli-2.1.5 → accli-2.1.6}/tests/test_logs_command.py +0 -0
  36. {accli-2.1.5 → accli-2.1.6}/tests/test_mount_lifecycle.py +0 -0
  37. {accli-2.1.5 → accli-2.1.6}/tests/test_update_check.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accli
3
- Version: 2.1.5
3
+ Version: 2.1.6
4
4
  Summary: IIASA Accelerator Client
5
5
  Author-email: Wrufesh S <wrufesh@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -1,3 +1,3 @@
1
1
  # Please strictly put double quote to use this info for git tag
2
2
  # Read a developer guide for git tag command with regex
3
- VERSION = "v2.1.5"
3
+ VERSION = "v2.1.6"
@@ -1107,7 +1107,56 @@ def ensure_nfs_daemon_stable(timeout: float) -> bool:
1107
1107
  return wait_for_nfs_portmapper("127.0.0.1", 111, timeout)
1108
1108
 
1109
1109
 
1110
- def map_windows_network_drive(mount_point_abs, max_attempts: int) -> tuple[bool, str]:
1110
+ def configure_windows_nfs_drive_cache(drive_str: str):
1111
+ """
1112
+ Configure per-drive Windows Client for NFS registry settings in HKCU before mounting.
1113
+ Disables NfsRdr per-drive lookup/readdir/attribute caching so renamed or recreated
1114
+ directories do not serve stale NFS filehandles from the Windows kernel redirector cache.
1115
+ """
1116
+ letter = drive_str.strip().rstrip(":\\/").upper()
1117
+ if len(letter) != 1 or not letter.isalpha():
1118
+ return
1119
+ try:
1120
+ import winreg
1121
+ base_key_path = f"Software\\Microsoft\\ClientForNFS\\CurrentVersion\\Persistent\\{letter}"
1122
+ with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, base_key_path, 0, winreg.KEY_SET_VALUE) as k:
1123
+ winreg.SetValueEx(k, "NFSLookup", 0, winreg.REG_DWORD, 0)
1124
+ winreg.SetValueEx(k, "NFSReaddir", 0, winreg.REG_DWORD, 0)
1125
+ cache_key_path = f"{base_key_path}\\Cache"
1126
+ with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, cache_key_path, 0, winreg.KEY_SET_VALUE) as ck:
1127
+ winreg.SetValueEx(ck, "FileAttributeCache", 0, winreg.REG_DWORD, 0)
1128
+ winreg.SetValueEx(ck, "AttributeTimeDelta", 0, winreg.REG_DWORD, 1)
1129
+ winreg.SetValueEx(ck, "RemoteWriteCache", 0, winreg.REG_DWORD, 0)
1130
+ except Exception:
1131
+ pass
1132
+
1133
+
1134
+ def configure_windows_explorer_drive_label(drive_root: str, label: str = ""):
1135
+ r"""
1136
+ Set the Windows Explorer MountPoints2 label for \\127.0.0.1\! and broadcast shell notifications
1137
+ so Explorer displays the project/share name instead of a generic 'Network Drive (W:)'.
1138
+ """
1139
+ display_label = f"Accelerator ({label})" if label else "Accelerator"
1140
+ try:
1141
+ import winreg
1142
+ for subkey in ("##127.0.0.1#!", "##127.0.0.1#!#"):
1143
+ key_path = f"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\MountPoints2\\{subkey}"
1144
+ with winreg.CreateKeyEx(winreg.HKEY_CURRENT_USER, key_path, 0, winreg.KEY_SET_VALUE) as k:
1145
+ winreg.SetValueEx(k, "_LabelFromReg", 0, winreg.REG_SZ, display_label)
1146
+ except Exception:
1147
+ pass
1148
+ try:
1149
+ import ctypes
1150
+ # SHCNE_DRIVEADD (0x00000100), SHCNE_RENAMEFOLDER (0x00020000), SHCNE_UPDATEITEM (0x00002000)
1151
+ # SHCNF_PATHW | SHCNF_FLUSH (0x1005)
1152
+ ctypes.windll.shell32.SHChangeNotify(0x00000100, 0x1005, drive_root, None)
1153
+ ctypes.windll.shell32.SHChangeNotify(0x00020000, 0x1005, drive_root, None)
1154
+ ctypes.windll.shell32.SHChangeNotify(0x00002000, 0x1005, drive_root, None)
1155
+ except Exception:
1156
+ pass
1157
+
1158
+
1159
+ def map_windows_network_drive(mount_point_abs, max_attempts: int, label: str = "") -> tuple[bool, str]:
1111
1160
  """
1112
1161
  Attempt to map the NFS share to the requested drive letter using mount.exe.
1113
1162
  Retries with cleanup if Windows NFS client returns a transient error.
@@ -1117,6 +1166,7 @@ def map_windows_network_drive(mount_point_abs, max_attempts: int) -> tuple[bool,
1117
1166
  target_str = str(mount_point_abs).rstrip("\\/")
1118
1167
  if re.match(r"^[a-zA-Z]$", target_str):
1119
1168
  target_str += ":"
1169
+ configure_windows_nfs_drive_cache(target_str)
1120
1170
 
1121
1171
  mount_cmd = [
1122
1172
  "C:\\Windows\\System32\\mount.exe",
@@ -1133,6 +1183,7 @@ def map_windows_network_drive(mount_point_abs, max_attempts: int) -> tuple[bool,
1133
1183
 
1134
1184
  last_err = ""
1135
1185
  drive_root = str(mount_point_abs).rstrip("\\/") + "\\"
1186
+ configure_windows_explorer_drive_label(drive_root, label)
1136
1187
  for attempt in range(1, max_attempts + 1):
1137
1188
  cleanup_stuck_windows_mount_processes()
1138
1189
 
@@ -1160,6 +1211,7 @@ def map_windows_network_drive(mount_point_abs, max_attempts: int) -> tuple[bool,
1160
1211
  entries = os.listdir(drive_root)
1161
1212
  if len(entries) > 0:
1162
1213
  drive_ready = True
1214
+ configure_windows_explorer_drive_label(drive_root, label)
1163
1215
  return True, (res.stdout or "").strip()
1164
1216
  except OSError:
1165
1217
  pass
@@ -1640,7 +1692,7 @@ def mount_start(
1640
1692
  raise typer.Exit(1)
1641
1693
 
1642
1694
  # Map the network drive in the CURRENT user session (so it is visible in Explorer)
1643
- success, err_msg = map_windows_network_drive(mount_point_abs, 5)
1695
+ success, err_msg = map_windows_network_drive(mount_point_abs, 5, label=project_slug)
1644
1696
  if success:
1645
1697
  start_nfs_watcher(str(mount_point_abs), interval=30)
1646
1698
  print(f"[bold green][OK] NFS mount successfully mapped at [white]{mount_point_abs}[/white]![/bold green]")
@@ -1694,6 +1746,7 @@ def mount_start(
1694
1746
  print(f"[yellow]Please check the log file at {log_file_path} for more details.[/yellow]")
1695
1747
  raise typer.Exit(1)
1696
1748
 
1749
+ configure_windows_explorer_drive_label(str(mount_point_abs).rstrip("\\/") + "\\", label=project_slug)
1697
1750
  start_nfs_watcher(str(mount_point_abs), interval=30)
1698
1751
  print(f"[bold green][OK] NFS mount process spawned successfully (PID: {process.pid}).[/bold green]")
1699
1752
  print(f"[cyan]Use 'umount' or 'accli mount stop' to unmount the drive.[/cyan]")
@@ -1735,7 +1788,7 @@ def mount_start(
1735
1788
  raise typer.Exit(1)
1736
1789
 
1737
1790
  # Map the network drive in the CURRENT user session (so it is visible in Explorer)
1738
- success, err_msg = map_windows_network_drive(mount_point_abs, 5)
1791
+ success, err_msg = map_windows_network_drive(mount_point_abs, 5, label=project_slug)
1739
1792
  if success:
1740
1793
  start_nfs_watcher(str(mount_point_abs), interval=30)
1741
1794
  print(f"[bold green][OK] NFS mount successfully mapped at [white]{mount_point_abs}[/white]![/bold green]")
@@ -9,7 +9,7 @@ import typer
9
9
  from rich import print
10
10
  from rich.progress import Progress, TextColumn, BarColumn, TaskProgressColumn, TimeElapsedColumn
11
11
 
12
- DEFAULT_VERSION = "v0.6.5-acc-pr140-p6"
12
+ DEFAULT_VERSION = "v0.6.5-acc-pr140-p16"
13
13
  BINARY_DIR = Path.home() / ".accli" / "bin"
14
14
 
15
15
  # Regex to safely validate version strings to prevent URL manipulation or directory traversal
@@ -7,6 +7,8 @@ from pathlib import Path
7
7
  from datetime import datetime
8
8
 
9
9
  # Windows Shell Notification constants
10
+ SHCNE_MKDIR = 0x00000008
11
+ SHCNE_RMDIR = 0x00000010
10
12
  SHCNE_UPDATEDIR = 0x00001000
11
13
  SHCNF_PATHW = 0x0005
12
14
 
@@ -62,10 +64,18 @@ def get_open_explorer_paths(script_path: Path, mount_point: str) -> list[str]:
62
64
  return []
63
65
 
64
66
 
65
- def notify_explorer(script_path: Path, mount_point: str, path_str: str):
67
+ def notify_explorer(script_path: Path, mount_point: str, path_str: str, removed_dirs: list[str] | None = None, added_dirs: list[str] | None = None):
66
68
  """Notifies Windows Shell and refreshes Explorer windows for path_str."""
67
69
  log(f"Broadcasting SHChangeNotify on '{path_str}'...")
68
70
  try:
71
+ if removed_dirs:
72
+ for dname in removed_dirs:
73
+ child_dir = str(Path(path_str) / dname)
74
+ ctypes.windll.shell32.SHChangeNotify(SHCNE_RMDIR, SHCNF_PATHW, child_dir, None)
75
+ if added_dirs:
76
+ for dname in added_dirs:
77
+ child_dir = str(Path(path_str) / dname)
78
+ ctypes.windll.shell32.SHChangeNotify(SHCNE_MKDIR, SHCNF_PATHW, child_dir, None)
69
79
  ctypes.windll.shell32.SHChangeNotify(
70
80
  SHCNE_UPDATEDIR,
71
81
  SHCNF_PATHW,
@@ -191,14 +201,23 @@ def run_watcher(mount_point: str, interval: float):
191
201
  dpath = Path(dir_str)
192
202
  current_state = scan_directory_state(dpath)
193
203
  if current_state is None:
204
+ if dir_str in cached_states:
205
+ del cached_states[dir_str]
206
+ parent_str = str(dpath.parent)
207
+ log(f"Directory '{dir_str}' disappeared -> notifying shell and refreshing '{parent_str}'")
208
+ notify_explorer(script_path, mount_point, parent_str, removed_dirs=[dpath.name])
194
209
  continue
195
210
 
196
211
  last_state = cached_states.get(dir_str)
197
212
  if last_state is not None:
198
213
  if current_state != last_state:
214
+ old_keys = set(last_state.keys())
215
+ new_keys = set(current_state.keys())
216
+ removed_dirs = [k for k in (old_keys - new_keys) if last_state[k][0]]
217
+ added_dirs = [k for k in (new_keys - old_keys) if current_state[k][0]]
199
218
  diff_summary = describe_changes(last_state, current_state)
200
219
  log(f"Change detected in '{dir_str}' -> {diff_summary}")
201
- notify_explorer(script_path, mount_point, dir_str)
220
+ notify_explorer(script_path, mount_point, dir_str, removed_dirs=removed_dirs, added_dirs=added_dirs)
202
221
  cached_states[dir_str] = current_state
203
222
  else:
204
223
  cached_states[dir_str] = current_state
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accli
3
- Version: 2.1.5
3
+ Version: 2.1.6
4
4
  Summary: IIASA Accelerator Client
5
5
  Author-email: Wrufesh S <wrufesh@gmail.com>
6
6
  License: The MIT License (MIT)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes