accli 2.1.0__tar.gz → 2.1.2__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 (35) hide show
  1. {accli-2.1.0 → accli-2.1.2}/PKG-INFO +10 -10
  2. {accli-2.1.0 → accli-2.1.2}/README.md +8 -8
  3. {accli-2.1.0 → accli-2.1.2}/accli/_version.py +1 -1
  4. {accli-2.1.0 → accli-2.1.2}/accli/cli.py +71 -67
  5. {accli-2.1.0 → accli-2.1.2}/accli/gui.py +5 -4
  6. {accli-2.1.0 → accli-2.1.2}/accli/job_views.py +3 -3
  7. {accli-2.1.0 → accli-2.1.2}/accli/setup-nfs.ps1 +12 -1
  8. {accli-2.1.0 → accli-2.1.2}/accli.egg-info/PKG-INFO +10 -10
  9. {accli-2.1.0 → accli-2.1.2}/accli.egg-info/SOURCES.txt +2 -1
  10. {accli-2.1.0 → accli-2.1.2}/pyproject.toml +1 -1
  11. {accli-2.1.0 → accli-2.1.2}/tests/test_jobs_commands.py +33 -13
  12. {accli-2.1.0 → accli-2.1.2}/tests/test_logs_command.py +3 -1
  13. accli-2.1.2/tests/test_update_check.py +151 -0
  14. {accli-2.1.0 → accli-2.1.2}/LICENSE +0 -0
  15. {accli-2.1.0 → accli-2.1.2}/accli/AcceleratorJobProjectService.py +0 -0
  16. {accli-2.1.0 → accli-2.1.2}/accli/AcceleratorTaskDispatcher.py +0 -0
  17. {accli-2.1.0 → accli-2.1.2}/accli/AcceleratorTerminalCliProjectService.py +0 -0
  18. {accli-2.1.0 → accli-2.1.2}/accli/CsvRegionalTimeseriesValidator.py +0 -0
  19. {accli-2.1.0 → accli-2.1.2}/accli/__init__.py +0 -0
  20. {accli-2.1.0 → accli-2.1.2}/accli/__main__.py +0 -0
  21. {accli-2.1.0 → accli-2.1.2}/accli/cleanup-nfs.ps1 +0 -0
  22. {accli-2.1.0 → accli-2.1.2}/accli/common.py +0 -0
  23. {accli-2.1.0 → accli-2.1.2}/accli/log_timeline.py +0 -0
  24. {accli-2.1.0 → accli-2.1.2}/accli/mount_downloader.py +0 -0
  25. {accli-2.1.0 → accli-2.1.2}/accli/nfs_watcher.py +0 -0
  26. {accli-2.1.0 → accli-2.1.2}/accli/refresh_explorer.ps1 +0 -0
  27. {accli-2.1.0 → accli-2.1.2}/accli/token.py +0 -0
  28. {accli-2.1.0 → accli-2.1.2}/accli/version_checker.py +0 -0
  29. {accli-2.1.0 → accli-2.1.2}/accli.egg-info/dependency_links.txt +0 -0
  30. {accli-2.1.0 → accli-2.1.2}/accli.egg-info/entry_points.txt +0 -0
  31. {accli-2.1.0 → accli-2.1.2}/accli.egg-info/requires.txt +0 -0
  32. {accli-2.1.0 → accli-2.1.2}/accli.egg-info/top_level.txt +0 -0
  33. {accli-2.1.0 → accli-2.1.2}/setup.cfg +0 -0
  34. {accli-2.1.0 → accli-2.1.2}/tests/test_log_timeline.py +0 -0
  35. {accli-2.1.0 → accli-2.1.2}/tests/test_mount_lifecycle.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accli
3
- Version: 2.1.0
3
+ Version: 2.1.2
4
4
  Summary: IIASA Accelerator Client
5
5
  Author-email: Wrufesh S <wrufesh@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -29,7 +29,7 @@ Project-URL: Bug Tracker, https://github.com/iiasa/accli/issues
29
29
  Classifier: Programming Language :: Python :: 3
30
30
  Classifier: License :: OSI Approved :: MIT License
31
31
  Classifier: Operating System :: OS Independent
32
- Requires-Python: >=3.7
32
+ Requires-Python: >=3.8
33
33
  Description-Content-Type: text/markdown
34
34
  License-File: LICENSE
35
35
  Requires-Dist: urllib3>=1.26.5
@@ -70,7 +70,7 @@ This client uses **device authentication** via Auth0.
70
70
 
71
71
  ### ✅ Requirements
72
72
 
73
- - Python >= 3.7.17
73
+ - Python >= 3.8
74
74
 
75
75
  ### 📦 Installation
76
76
 
@@ -137,19 +137,19 @@ Usage: accli [OPTIONS] COMMAND [ARGS]...
137
137
  List root jobs, newest first, with each job's type (`standalone`, `children`, `callback` or `children+callback`), its own status and the status of its whole graph:
138
138
 
139
139
  ```bash
140
- accli jobs # latest 10 in the last project used
141
- accli jobs -p my-project -n 50
142
- accli jobs -s failed # graphs with a failed job
143
- accli jobs -s processing,error --all
140
+ accli jobs my-project # latest 10
141
+ accli jobs my-project -n 50
142
+ accli jobs my-project -s failed # graphs with a failed job
143
+ accli jobs my-project -s processing,error
144
144
  ```
145
145
 
146
146
  `--status` filters on the graph status: `processing` (or `active`), `error` (or `failed`) and `done`. A standalone job counts by its own status.
147
147
 
148
- Show a job's status and details. For a job holding children or callbacks, Graph status covers the jobs below it (the same as GRAPH in `accli jobs`) and each one is listed; any job also links to the pipeline it is part of. Read a job's output with `accli logs <job>`:
148
+ Show a job's status and details. For a job holding children or callbacks, Graph status covers the jobs below it (the same as GRAPH in `accli jobs`) and each one is listed; any job also links to the pipeline it is part of. Read a job's output with `accli logs <project> <job>`:
149
149
 
150
150
  ```bash
151
- accli job 1234
152
- accli job 1234 --json
151
+ accli job my-project 1234
152
+ accli job my-project 1234 --json
153
153
  ```
154
154
 
155
155
  ---
@@ -26,7 +26,7 @@ This client uses **device authentication** via Auth0.
26
26
 
27
27
  ### ✅ Requirements
28
28
 
29
- - Python >= 3.7.17
29
+ - Python >= 3.8
30
30
 
31
31
  ### 📦 Installation
32
32
 
@@ -93,19 +93,19 @@ Usage: accli [OPTIONS] COMMAND [ARGS]...
93
93
  List root jobs, newest first, with each job's type (`standalone`, `children`, `callback` or `children+callback`), its own status and the status of its whole graph:
94
94
 
95
95
  ```bash
96
- accli jobs # latest 10 in the last project used
97
- accli jobs -p my-project -n 50
98
- accli jobs -s failed # graphs with a failed job
99
- accli jobs -s processing,error --all
96
+ accli jobs my-project # latest 10
97
+ accli jobs my-project -n 50
98
+ accli jobs my-project -s failed # graphs with a failed job
99
+ accli jobs my-project -s processing,error
100
100
  ```
101
101
 
102
102
  `--status` filters on the graph status: `processing` (or `active`), `error` (or `failed`) and `done`. A standalone job counts by its own status.
103
103
 
104
- Show a job's status and details. For a job holding children or callbacks, Graph status covers the jobs below it (the same as GRAPH in `accli jobs`) and each one is listed; any job also links to the pipeline it is part of. Read a job's output with `accli logs <job>`:
104
+ Show a job's status and details. For a job holding children or callbacks, Graph status covers the jobs below it (the same as GRAPH in `accli jobs`) and each one is listed; any job also links to the pipeline it is part of. Read a job's output with `accli logs <project> <job>`:
105
105
 
106
106
  ```bash
107
- accli job 1234
108
- accli job 1234 --json
107
+ accli job my-project 1234
108
+ accli job my-project 1234 --json
109
109
  ```
110
110
 
111
111
  ---
@@ -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.0"
3
+ VERSION = "v2.1.2"
@@ -36,27 +36,20 @@ ACCLI_DEBUG = os.environ.get('ACCLI_DEBUG', False)
36
36
  app = typer.Typer(
37
37
  add_completion=False,
38
38
  pretty_exceptions_show_locals=False,
39
- no_args_is_help=True,
40
39
  context_settings={"help_option_names": ["-h", "--help"]}
41
40
  )
42
41
 
43
42
 
44
- def version_callback(value: bool):
45
- if value:
46
- print(f"[bold cyan]accli version: {VERSION}[/bold cyan]")
47
- update_avail, latest = check_for_updates()
48
- if update_avail:
49
- instruction = get_upgrade_instruction()
50
- print(f"[bold yellow]🔔 A new version of accli is available: {latest} (Current: {VERSION})[/bold yellow]")
51
- print(f"[yellow]{instruction}[/yellow]\n")
52
- raise typer.Exit()
53
-
54
-
55
- @app.callback()
43
+ @app.callback(invoke_without_command=True)
56
44
  def main_callback(
45
+ ctx: typer.Context,
57
46
  version: Annotated[
58
47
  bool,
59
- typer.Option("--version", "-v", callback=version_callback, is_eager=True, help="Show the version and exit.")
48
+ typer.Option("--version", "-v", help="Show the version and exit.")
49
+ ] = False,
50
+ help: Annotated[
51
+ bool,
52
+ typer.Option("--help", "-h", help="Show this message and exit.")
60
53
  ] = False,
61
54
  ):
62
55
  update_avail, latest = check_for_updates()
@@ -65,6 +58,14 @@ def main_callback(
65
58
  print(f"[bold yellow]🔔 Update available: accli {latest} (current: {VERSION})[/bold yellow]")
66
59
  print(f"[yellow]{instruction}[/yellow]\n")
67
60
 
61
+ if version:
62
+ print(f"[bold cyan]accli version: {VERSION}[/bold cyan]")
63
+ raise typer.Exit()
64
+
65
+ if help or ctx.invoked_subcommand is None:
66
+ typer.echo(ctx.get_help())
67
+ raise typer.Exit()
68
+
68
69
 
69
70
  def get_size(path):
70
71
  size = 0
@@ -93,11 +94,6 @@ def about():
93
94
  print("[bold cyan]Feature requests & suggestions: https://github.com/iiasa/accli/issues[/bold cyan]")
94
95
  print("[bold cyan]License: The MIT License (MIT)[/bold cyan]")
95
96
  print(f"[bold cyan]Version: {VERSION}[/bold cyan]")
96
- update_avail, latest = check_for_updates()
97
- if update_avail:
98
- instruction = get_upgrade_instruction()
99
- print(f"[bold yellow]🔔 A new version of accli is available: {latest} (Current: {VERSION})[/bold yellow]")
100
- print(f"[yellow]{instruction}[/yellow]\n")
101
97
 
102
98
 
103
99
  @app.command()
@@ -228,9 +224,8 @@ LOG_POLL_SECONDS = 5
228
224
 
229
225
  @app.command()
230
226
  def logs(
227
+ project_slug: Annotated[str, typer.Argument(help="Unique Accelerator project slug.")],
231
228
  job_id: Annotated[int, typer.Argument(help="Job ID.")],
232
- project_slug: Annotated[
233
- str, typer.Option(..., '-p', help="Project slug. Defaults to the last project used.")] = None,
234
229
  follow: Annotated[
235
230
  bool, typer.Option(..., '--follow', '-f', help="Keep printing new lines until the job finishes.")] = False,
236
231
  source: Annotated[
@@ -241,17 +236,7 @@ def logs(
241
236
  show_time: Annotated[bool, typer.Option('--time/--no-time', help="Show the time of each line.")] = True,
242
237
  ):
243
238
  """Print a job's merged log: executor output, scheduler output and cluster events."""
244
- project_slug = project_slug or get_project_slug()
245
- if not project_slug:
246
- print("[bold red]ERROR: No project selected. Pass one with -p.[/bold red]")
247
- raise typer.Exit(1)
248
-
249
- _, access_token, _ = exchange_refresh_token(project_slug)
250
- service = AcceleratorTerminalCliProjectService(
251
- user_token=access_token,
252
- server_url=get_server_url(),
253
- verify_cert=(not ACCLI_DEBUG)
254
- )
239
+ service = _cli_service_for(project_slug)
255
240
  sources = ",".join(source) if source else None
256
241
  limit = 100 if whole else None
257
242
 
@@ -297,19 +282,16 @@ def logs(
297
282
 
298
283
 
299
284
  def _cli_service_for(project_slug):
300
- """Resolve the project (or the last one used) and return (slug, service)."""
301
- project_slug = project_slug or get_project_slug()
302
- if not project_slug:
303
- print("[bold red]ERROR: No project selected. Pass one with -p.[/bold red]")
304
- raise typer.Exit(1)
305
-
285
+ """Check the project exists and is accessible (as `mount` does), then return a CLI service for it."""
286
+ server_url = get_server_url()
287
+ validate_project_slug(server_url, project_slug)
288
+ # The token from validation is cached in memory, so this exchange makes no extra request.
306
289
  _, access_token, _ = exchange_refresh_token(project_slug)
307
- service = AcceleratorTerminalCliProjectService(
290
+ return AcceleratorTerminalCliProjectService(
308
291
  user_token=access_token,
309
- server_url=get_server_url(),
292
+ server_url=server_url,
310
293
  verify_cert=(not ACCLI_DEBUG)
311
294
  )
312
- return project_slug, service
313
295
 
314
296
 
315
297
  def _api_error_detail(err):
@@ -321,8 +303,7 @@ def _api_error_detail(err):
321
303
 
322
304
  @app.command()
323
305
  def jobs(
324
- project_slug: Annotated[
325
- str, typer.Option(..., '-p', help="Project slug. Defaults to the last project used.")] = None,
306
+ project_slug: Annotated[str, typer.Argument(help="Unique Accelerator project slug.")],
326
307
  status: Annotated[
327
308
  List[str], typer.Option(
328
309
  ..., '--status', '-s',
@@ -330,35 +311,25 @@ def jobs(
330
311
  "Only jobs whose graph has this status: processing (or active), error (or failed), done. "
331
312
  "A standalone job counts by its own status. Repeatable or comma separated."
332
313
  ))] = None,
333
- limit: Annotated[int, typer.Option(..., '--limit', '-n', help="How many jobs to show.")] = 10,
334
- whole: Annotated[bool, typer.Option(..., '--all', help="Show every matching job, not only the latest.")] = False,
314
+ limit: Annotated[
315
+ int, typer.Option(..., '--limit', '-n', min=1, max=200, help="How many jobs to show, up to 200.")] = 10,
335
316
  as_json: Annotated[bool, typer.Option(..., '--json', help="Print the raw JSON.")] = False,
336
317
  ):
337
318
  """List root jobs (newest first) with their type and status.
338
319
 
339
320
  TYPE is standalone, children, callback or children+callback. GRAPH is the status
340
321
  of everything below the root job, and what --status filters on. See a job's
341
- status and everything it holds with `accli job <job>`.
322
+ status and everything it holds with `accli job <project> <job>`.
342
323
  """
343
- project_slug, service = _cli_service_for(project_slug)
324
+ service = _cli_service_for(project_slug)
344
325
  status_filter = ",".join(t.strip() for s in (status or []) for t in s.split(",") if t.strip()) or None
345
- page_size = 10 if whole else min(limit, 200)
346
326
 
347
- results, count, cursor = [], 0, None
348
327
  try:
349
- while True:
350
- page = service.list_root_jobs(project_slug, limit=page_size, cursor=cursor, status=status_filter)
351
- results += page["results"]
352
- count = page["count"]
353
- cursor = page.get("next_cursor")
354
- if not cursor or (not whole and len(results) >= limit):
355
- break
328
+ page = service.list_root_jobs(project_slug, limit=limit, status=status_filter)
356
329
  except AccAPIError as err:
357
330
  print(f"[bold red]ERROR: {_api_error_detail(err)}[/bold red]")
358
331
  raise typer.Exit(1)
359
-
360
- if not whole:
361
- results = results[:limit]
332
+ results, count = page["results"], page["count"]
362
333
 
363
334
  if as_json:
364
335
  typer.echo(json.dumps(dict(count=count, results=results), indent=2, default=str))
@@ -370,22 +341,21 @@ def jobs(
370
341
 
371
342
  print(job_views.root_jobs_table(results))
372
343
  if count > len(results):
373
- print(f"[dim]Showing {len(results)} of {count} jobs. Use -n or --all to see more.[/dim]")
344
+ print(f"[dim]Showing {len(results)} of {count} jobs. Use -n to see more.[/dim]")
374
345
 
375
346
 
376
347
  @app.command()
377
348
  def job(
349
+ project_slug: Annotated[str, typer.Argument(help="Unique Accelerator project slug.")],
378
350
  job_id: Annotated[int, typer.Argument(help="Job ID: a single job, or one holding children and callbacks.")],
379
- project_slug: Annotated[
380
- str, typer.Option(..., '-p', help="Project slug. Defaults to the last project used.")] = None,
381
351
  as_json: Annotated[bool, typer.Option(..., '--json', help="Print the raw JSON.")] = False,
382
352
  ):
383
353
  """Show a job's status and details. For a job holding children or callbacks, Graph status
384
354
  covers the jobs below it, the same as GRAPH in `accli jobs`, and each one is listed.
385
355
 
386
- See a job's output with `accli logs <job>`.
356
+ See a job's output with `accli logs <project> <job>`.
387
357
  """
388
- project_slug, service = _cli_service_for(project_slug)
358
+ service = _cli_service_for(project_slug)
389
359
  try:
390
360
  job_graph = service.get_job_graph(project_slug, job_id)
391
361
  except AccAPIError as err:
@@ -396,7 +366,7 @@ def job(
396
366
  typer.echo(json.dumps(job_graph, indent=2, default=str))
397
367
  return
398
368
 
399
- title, details = job_views.job_details(job_graph, job_id)
369
+ title, details = job_views.job_details(job_graph, job_id, project_slug)
400
370
  print(title)
401
371
  print(details)
402
372
  if len(job_views.subtree(job_graph, job_id)) > 1:
@@ -1133,7 +1103,7 @@ def map_windows_network_drive(mount_point_abs, max_attempts: int) -> tuple[bool,
1133
1103
  if res.returncode == 0:
1134
1104
  # Confirm drive is actually mounted and directory listing is populated and queryable
1135
1105
  drive_ready = False
1136
- for _ in range(30):
1106
+ for _ in range(10):
1137
1107
  try:
1138
1108
  if os.path.exists(drive_root):
1139
1109
  entries = os.listdir(drive_root)
@@ -1145,8 +1115,15 @@ def map_windows_network_drive(mount_point_abs, max_attempts: int) -> tuple[bool,
1145
1115
  time.sleep(0.5)
1146
1116
  if not drive_ready:
1147
1117
  last_err = f"mount.exe reported success but drive {drive_root} was empty or not accessible"
1148
- # Clean up the stale mount connection so next attempt can remount fresh
1118
+ # Clean up the stale mount connection and reset NfsRdr kernel cache so next attempt can remount fresh
1149
1119
  subprocess.run(["net", "use", target_str, "/delete", "/y"], capture_output=True)
1120
+ subprocess.run(["schtasks", "/run", "/tn", "accli-umount-nfs"], capture_output=True)
1121
+ for _ in range(16):
1122
+ time.sleep(0.5)
1123
+ umount_check = subprocess.run(["schtasks", "/query", "/tn", "accli-umount-nfs"], capture_output=True, text=True, errors="replace")
1124
+ clnt_check = subprocess.run(["sc.exe", "query", "NfsClnt"], capture_output=True, text=True, errors="replace")
1125
+ if (not umount_check.stdout or "Running" not in umount_check.stdout) and (clnt_check.stdout and "RUNNING" in clnt_check.stdout):
1126
+ break
1150
1127
  else:
1151
1128
  last_err = (res.stderr or res.stdout or "").strip()
1152
1129
  if "85" in last_err or "already in use" in last_err.lower():
@@ -1257,6 +1234,25 @@ def enable_windows_nfs_features():
1257
1234
  reg_ok = reg_ok and anon_ok and cache_ok
1258
1235
 
1259
1236
  if nfs_ok and reg_ok and task_ok:
1237
+ # Ensure run-umount-helper.ps1 includes the NfsRdr/NfsClnt kernel cache flush
1238
+ try:
1239
+ umount_helper = Path("C:/ProgramData/accli/run-umount-helper.ps1")
1240
+ if umount_helper.is_file():
1241
+ content = umount_helper.read_text(encoding="utf-8", errors="ignore")
1242
+ if "Stop-Service -Name \"NfsRdr\"" not in content:
1243
+ umount_helper.write_text(
1244
+ content.rstrip()
1245
+ + "\n\n# Synchronously stop NfsClnt & NfsRdr, then start NfsRdr & NfsClnt to flush stale kernel V_NET_ROOT cache\n"
1246
+ + "try {\n"
1247
+ + " Stop-Service -Name \"NfsClnt\" -Force -ErrorAction SilentlyContinue\n"
1248
+ + " Stop-Service -Name \"NfsRdr\" -Force -ErrorAction SilentlyContinue\n"
1249
+ + " Start-Service -Name \"NfsRdr\" -ErrorAction SilentlyContinue\n"
1250
+ + " Start-Service -Name \"NfsClnt\" -ErrorAction SilentlyContinue\n"
1251
+ + "} catch {}\n",
1252
+ encoding="utf-8",
1253
+ )
1254
+ except Exception:
1255
+ pass
1260
1256
  print("[bold green][OK] Windows NFS client features, registry policies, and Task Scheduler gateway are already configured.[/bold green]")
1261
1257
  return
1262
1258
 
@@ -1872,6 +1868,14 @@ def mount_stop(
1872
1868
  break
1873
1869
  time.sleep(0.5)
1874
1870
 
1871
+ # Wait for accli-umount-nfs to finish restarting NfsRdr/NfsClnt
1872
+ for _ in range(16):
1873
+ umount_check = subprocess.run(["schtasks", "/query", "/tn", "accli-umount-nfs"], capture_output=True, text=True, errors="replace")
1874
+ clnt_check = subprocess.run(["sc.exe", "query", "NfsClnt"], capture_output=True, text=True, errors="replace")
1875
+ if (not umount_check.stdout or "Running" not in umount_check.stdout) and (clnt_check.stdout and "RUNNING" in clnt_check.stdout):
1876
+ break
1877
+ time.sleep(0.5)
1878
+
1875
1879
  # Wait until drive letter is released from Windows namespace
1876
1880
  for _ in range(10):
1877
1881
  if not is_windows_drive_mapped(target_str):
@@ -126,12 +126,12 @@ class AccliGuiApp(tk.Tk):
126
126
  if update_avail:
127
127
  instruction = get_upgrade_instruction()
128
128
  def show_notice():
129
- self.status_bar_val.set(f"Update available: {latest} (current: {VERSION})")
130
- self.append_log(f"\n🔔 [NOTICE] A new version of accli ({latest}) is available! Current version: {VERSION}\n{instruction}\n\n")
129
+ self.status_bar_val.set(f"Update available: accli {latest} (current: {VERSION})")
130
+ self.append_log(f"\n🔔 Update available: accli {latest} (current: {VERSION})\n{instruction}\n\n")
131
131
  # Also show subtle info notification
132
132
  messagebox.showinfo(
133
133
  "Update Available",
134
- f"A new version of accli is available: {latest}\n(Currently installed: {VERSION})\n\n{instruction}"
134
+ f"Update available: accli {latest} (current: {VERSION})\n\n{instruction}"
135
135
  )
136
136
  self.after(0, show_notice)
137
137
  threading.Thread(target=worker, daemon=True).start()
@@ -272,11 +272,12 @@ class AccliGuiApp(tk.Tk):
272
272
  self.server_entry.configure(state=tk.NORMAL)
273
273
  self.status_bar_val.set("Session Status: Disconnected")
274
274
 
275
+ debug_status = "Enabled ($env:ACCLI_DEBUG='1')" if os.environ.get("ACCLI_DEBUG") else "Disabled"
275
276
  details = [
276
277
  f"Server URL: {server_url}",
277
278
  f"Session Status: {'Connected / Logged In' if logged_in else 'Not Logged In'}",
278
279
  f"Token DB Path: {db_path}",
279
- f"Debug Mode: {'Enabled ($env:ACCLI_DEBUG=\"1\")' if os.environ.get('ACCLI_DEBUG') else 'Disabled'}"
280
+ f"Debug Mode: {debug_status}"
280
281
  ]
281
282
  self.conn_details_txt.configure(state=tk.NORMAL)
282
283
  self.conn_details_txt.delete("1.0", tk.END)
@@ -170,7 +170,7 @@ def _own_status(job):
170
170
  return text
171
171
 
172
172
 
173
- def job_details(graph, job_id):
173
+ def job_details(graph, job_id, project_slug):
174
174
  """Key/value block for one job. Graph status covers the jobs below it, when it has any."""
175
175
  job = next(j for j in graph["jobs"] if j["id"] == job_id)
176
176
  jobs = subtree(graph, job_id)
@@ -199,10 +199,10 @@ def job_details(graph, job_id):
199
199
  part_of.append(" ")
200
200
  part_of.append_text(status_text(graph["graph_status"]))
201
201
  part_of.append(f" {len(graph['jobs'])} jobs ", style="dim")
202
- part_of.append(f"accli job {root['id']}", style="cyan")
202
+ part_of.append(f"accli job {project_slug} {root['id']}", style="cyan")
203
203
  table.add_row("Part of", part_of)
204
204
 
205
- table.add_row("Logs", Text(f"accli logs {job['id']}", style="cyan"))
205
+ table.add_row("Logs", Text(f"accli logs {project_slug} {job['id']}", style="cyan"))
206
206
 
207
207
  title = Text()
208
208
  title.append(f"Job #{job['id']}", style="bold")
@@ -152,8 +152,11 @@ if ($cfg.skip_auto_mount) {
152
152
  $env:HF_MOUNT_SKIP_AUTO_MOUNT = "1"
153
153
  }
154
154
 
155
- # Ensure NfsClnt service is started before attempting mount
155
+ # Ensure NfsRdr and NfsClnt services are started before attempting mount
156
156
  try {
157
+ if ((Get-Service -Name "NfsRdr" -ErrorAction SilentlyContinue).Status -ne 'Running') {
158
+ Start-Service -Name "NfsRdr" -ErrorAction SilentlyContinue
159
+ }
157
160
  if ((Get-Service -Name "NfsClnt" -ErrorAction SilentlyContinue).Status -ne 'Running') {
158
161
  Start-Service -Name "NfsClnt" -ErrorAction SilentlyContinue
159
162
  }
@@ -218,6 +221,14 @@ try {
218
221
  Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue | Out-Null
219
222
  }
220
223
  } catch {}
224
+
225
+ # Synchronously stop NfsClnt & NfsRdr, then start NfsRdr & NfsClnt to flush stale kernel V_NET_ROOT cache
226
+ try {
227
+ Stop-Service -Name "NfsClnt" -Force -ErrorAction SilentlyContinue
228
+ Stop-Service -Name "NfsRdr" -Force -ErrorAction SilentlyContinue
229
+ Start-Service -Name "NfsRdr" -ErrorAction SilentlyContinue
230
+ Start-Service -Name "NfsClnt" -ErrorAction SilentlyContinue
231
+ } catch {}
221
232
  '@
222
233
 
223
234
  $helperUmountScriptPath = "C:\ProgramData\accli\run-umount-helper.ps1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: accli
3
- Version: 2.1.0
3
+ Version: 2.1.2
4
4
  Summary: IIASA Accelerator Client
5
5
  Author-email: Wrufesh S <wrufesh@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -29,7 +29,7 @@ Project-URL: Bug Tracker, https://github.com/iiasa/accli/issues
29
29
  Classifier: Programming Language :: Python :: 3
30
30
  Classifier: License :: OSI Approved :: MIT License
31
31
  Classifier: Operating System :: OS Independent
32
- Requires-Python: >=3.7
32
+ Requires-Python: >=3.8
33
33
  Description-Content-Type: text/markdown
34
34
  License-File: LICENSE
35
35
  Requires-Dist: urllib3>=1.26.5
@@ -70,7 +70,7 @@ This client uses **device authentication** via Auth0.
70
70
 
71
71
  ### ✅ Requirements
72
72
 
73
- - Python >= 3.7.17
73
+ - Python >= 3.8
74
74
 
75
75
  ### 📦 Installation
76
76
 
@@ -137,19 +137,19 @@ Usage: accli [OPTIONS] COMMAND [ARGS]...
137
137
  List root jobs, newest first, with each job's type (`standalone`, `children`, `callback` or `children+callback`), its own status and the status of its whole graph:
138
138
 
139
139
  ```bash
140
- accli jobs # latest 10 in the last project used
141
- accli jobs -p my-project -n 50
142
- accli jobs -s failed # graphs with a failed job
143
- accli jobs -s processing,error --all
140
+ accli jobs my-project # latest 10
141
+ accli jobs my-project -n 50
142
+ accli jobs my-project -s failed # graphs with a failed job
143
+ accli jobs my-project -s processing,error
144
144
  ```
145
145
 
146
146
  `--status` filters on the graph status: `processing` (or `active`), `error` (or `failed`) and `done`. A standalone job counts by its own status.
147
147
 
148
- Show a job's status and details. For a job holding children or callbacks, Graph status covers the jobs below it (the same as GRAPH in `accli jobs`) and each one is listed; any job also links to the pipeline it is part of. Read a job's output with `accli logs <job>`:
148
+ Show a job's status and details. For a job holding children or callbacks, Graph status covers the jobs below it (the same as GRAPH in `accli jobs`) and each one is listed; any job also links to the pipeline it is part of. Read a job's output with `accli logs <project> <job>`:
149
149
 
150
150
  ```bash
151
- accli job 1234
152
- accli job 1234 --json
151
+ accli job my-project 1234
152
+ accli job my-project 1234 --json
153
153
  ```
154
154
 
155
155
  ---
@@ -29,4 +29,5 @@ accli.egg-info/top_level.txt
29
29
  tests/test_jobs_commands.py
30
30
  tests/test_log_timeline.py
31
31
  tests/test_logs_command.py
32
- tests/test_mount_lifecycle.py
32
+ tests/test_mount_lifecycle.py
33
+ tests/test_update_check.py
@@ -11,7 +11,7 @@ authors = [
11
11
  description = "IIASA Accelerator Client"
12
12
  readme = "README.md"
13
13
  license = {file = "LICENSE"}
14
- requires-python = ">=3.7"
14
+ requires-python = ">=3.8"
15
15
  dependencies = [
16
16
  "urllib3>=1.26.5", # 2.0.7 is recent, but 1.26.5+ is widely compatible
17
17
  "typer[all]>=0.4.0", # 0.4.0+ is stable and has most features
@@ -1,6 +1,8 @@
1
1
  """`accli jobs` and `accli job` against a fake API."""
2
2
  import json
3
3
 
4
+ import pytest
5
+
4
6
  from typer.testing import CliRunner
5
7
 
6
8
  from accli import cli
@@ -31,11 +33,12 @@ class FakeService:
31
33
  return self.graph
32
34
 
33
35
 
34
- def run(monkeypatch, service, *args, exit_code=0):
36
+ def run(monkeypatch, service, command, *args, exit_code=0):
35
37
  monkeypatch.setattr(cli, "exchange_refresh_token", lambda slug: ("", "token", 0))
38
+ monkeypatch.setattr(cli, "validate_project_slug", lambda server_url, slug: None)
36
39
  monkeypatch.setattr(cli, "get_server_url", lambda: "https://acc.example")
37
40
  monkeypatch.setattr(cli, "AcceleratorTerminalCliProjectService", lambda **kw: service)
38
- result = CliRunner().invoke(cli.app, [*args, "-p", "demo"], env={"COLUMNS": "200"})
41
+ result = CliRunner().invoke(cli.app, [command, "demo", *args], env={"COLUMNS": "200"})
39
42
  assert result.exit_code == exit_code, result.output
40
43
  return result.output
41
44
 
@@ -48,7 +51,7 @@ def test_jobs_lists_types_and_joins_status_filters(monkeypatch):
48
51
  ])])
49
52
  output = run(monkeypatch, service, "jobs", "-s", "error,processing", "--status", "done", "-n", "3")
50
53
 
51
- assert service.calls == [dict(limit=3, cursor=None, status="error,processing,done")]
54
+ assert service.calls == [dict(limit=3, status="error,processing,done")]
52
55
  rows = {line.split()[0]: line for line in output.splitlines() if line.strip()[:1].isdigit()}
53
56
  assert "children+callback" in rows["3"] and "PROCESSING" in rows["3"]
54
57
  assert "standalone" in rows["2"] and "ERROR" in rows["2"]
@@ -56,15 +59,17 @@ def test_jobs_lists_types_and_joins_status_filters(monkeypatch):
56
59
  assert "Showing" not in output
57
60
 
58
61
 
59
- def test_jobs_all_follows_cursor(monkeypatch):
60
- service = FakeService([
61
- dict(count=2, next_cursor="c1", results=[job(2, "b")]),
62
- dict(count=2, next_cursor=None, results=[job(1, "a")]),
63
- ])
64
- output = json.loads(run(monkeypatch, service, "jobs", "--all", "--json"))
62
+ def test_jobs_fetches_one_page_and_points_to_n(monkeypatch):
63
+ service = FakeService([dict(count=25, next_cursor="c1", results=[job(2, "b"), job(1, "a")])])
64
+ output = run(monkeypatch, service, "jobs")
65
+
66
+ assert service.calls == [dict(limit=10, status=None)]
67
+ assert "Showing 2 of 25 jobs. Use -n to see more." in output
65
68
 
66
- assert [j["id"] for j in output["results"]] == [2, 1]
67
- assert service.calls[1]["cursor"] == "c1"
69
+
70
+ def test_jobs_requires_project(monkeypatch):
71
+ result = CliRunner().invoke(cli.app, ["jobs"])
72
+ assert result.exit_code != 0 and "Missing argument 'project_slug'" in result.output
68
73
 
69
74
 
70
75
  def test_jobs_shows_api_error(monkeypatch):
@@ -96,8 +101,8 @@ def test_leaf_job_shows_only_its_own_status(monkeypatch):
96
101
  assert output.startswith("Job #13 after a")
97
102
  assert "Status DONE" in output and "Graph status" not in output
98
103
  assert "callback after #11" in output
99
- assert "Part of #10 root ERROR 5 jobs accli job 10" in output
100
- assert "accli logs 13" in output
104
+ assert "Part of #10 root ERROR 5 jobs accli job demo 10" in output
105
+ assert "accli logs demo 13" in output
101
106
  assert "Jobs in" not in output
102
107
 
103
108
 
@@ -138,3 +143,18 @@ def test_graph_status_leaves_out_the_job_itself(monkeypatch):
138
143
  output = run(monkeypatch, FakeService(graph=graph), "job", "1")
139
144
  assert "Status KILLED" in output
140
145
  assert "Graph status DONE 1 jobs below: 1 DONE" in output
146
+
147
+
148
+ def test_commands_validate_the_project_first(monkeypatch):
149
+ checked = []
150
+
151
+ def validate(server_url, slug):
152
+ checked.append((server_url, slug))
153
+ raise cli.typer.Exit(1)
154
+
155
+ monkeypatch.setattr(cli, "get_server_url", lambda: "https://acc.example")
156
+ monkeypatch.setattr(cli, "validate_project_slug", validate)
157
+ monkeypatch.setattr(cli, "AcceleratorTerminalCliProjectService", lambda **kw: pytest.fail("API called"))
158
+ for args in (["jobs", "nope"], ["job", "nope", "1"], ["logs", "nope", "1"]):
159
+ assert CliRunner().invoke(cli.app, args).exit_code == 1
160
+ assert checked == [("https://acc.example", "nope")] * 3
@@ -36,10 +36,11 @@ def chunk(seq, url, end):
36
36
  def run(monkeypatch, pages, *args):
37
37
  service = FakeService(pages)
38
38
  monkeypatch.setattr(cli, "exchange_refresh_token", lambda slug: ("", "token", 0))
39
+ monkeypatch.setattr(cli, "validate_project_slug", lambda server_url, slug: None)
39
40
  monkeypatch.setattr(cli, "get_server_url", lambda: "https://acc.example")
40
41
  monkeypatch.setattr(cli, "AcceleratorTerminalCliProjectService", lambda **kw: service)
41
42
  monkeypatch.setattr(cli.time, "sleep", lambda s: None)
42
- result = CliRunner().invoke(cli.app, ["logs", "42", "-p", "demo", "--no-time", *args])
43
+ result = CliRunner().invoke(cli.app, ["logs", "demo", "42", "--no-time", *args])
43
44
  assert result.exit_code == 0, result.output
44
45
  return result.output.splitlines(), service
45
46
 
@@ -65,3 +66,4 @@ def test_without_follow_prints_partial_line_once(monkeypatch):
65
66
 
66
67
  assert [line.split(None, 1)[1] for line in output] == ["starting", "downloading 4"]
67
68
  assert len(service.calls) == 1
69
+
@@ -0,0 +1,151 @@
1
+ """Verify that `check_for_updates` runs via the root callback for all CLI commands with a unified design."""
2
+ import unittest
3
+ from unittest.mock import patch
4
+
5
+ from typer.testing import CliRunner
6
+
7
+ from accli import cli
8
+ from accli._version import VERSION
9
+
10
+
11
+ class _FakeService:
12
+ def get_job_logs(self, *args, **kwargs):
13
+ return dict(chunks=[], events=[], after=None, before=None, has_more_before=False, job_completed=True)
14
+
15
+ def list_root_jobs(self, *args, **kwargs):
16
+ return dict(results=[], count=0)
17
+
18
+ def get_job_graph(self, *args, **kwargs):
19
+ return dict(
20
+ root_job_id=1,
21
+ graph_status="DONE",
22
+ jobs=[
23
+ dict(
24
+ id=1,
25
+ name="root",
26
+ job_executor_id="WKUBE",
27
+ job_entry_location="main.py",
28
+ status="DONE",
29
+ parent_job_id=None,
30
+ predecessor_job_id=None,
31
+ status_at=None,
32
+ created_at=None,
33
+ )
34
+ ],
35
+ )
36
+
37
+
38
+ ALL_COMMAND_INVOCATIONS = [
39
+ [],
40
+ ["-h"],
41
+ ["--help"],
42
+ ["--version"],
43
+ ["-v"],
44
+ ["about"],
45
+ ["gui"],
46
+ ["login"],
47
+ ["validate", "demo", "tmpl", "file.csv"],
48
+ ["dispatch", "demo", "root_task", "-f", "nonexistent_wkube.py"],
49
+ ["logs", "demo", "1"],
50
+ ["jobs", "demo"],
51
+ ["job", "demo", "1"],
52
+ ["copy", "local_a", "local_b"],
53
+ ["mount", "start", "demo", "--mode", "invalid"],
54
+ ["mount", "stop", "invalid_drive"],
55
+ ["mount", "status"],
56
+ ]
57
+
58
+
59
+ class TestUpdateCheckAllCommands(unittest.TestCase):
60
+ def setUp(self):
61
+ import accli.gui
62
+
63
+ class _FakeResp:
64
+ status_code = 200
65
+
66
+ @staticmethod
67
+ def json():
68
+ return {"access_token": "tok", "refresh_token": "ref"}
69
+
70
+ self.patches = [
71
+ patch.object(accli.gui, "main", lambda: None),
72
+ patch.object(cli.typer, "prompt", lambda *a, **kw: "fake-code"),
73
+ patch.object(cli.requests, "post", lambda *a, **kw: _FakeResp()),
74
+ patch.object(cli, "save_token_details", lambda *a, **kw: None),
75
+ patch.object(cli, "AcceleratorTerminalCliProjectService", lambda **kw: _FakeService()),
76
+ patch.object(cli, "CsvRegionalTimeseriesValidator", lambda **kw: (lambda: None)),
77
+ patch.object(cli, "_cli_service_for", lambda slug: _FakeService()),
78
+ patch.object(cli, "get_token", lambda: ""),
79
+ patch.object(cli, "get_server_url", lambda: "https://acc.example"),
80
+ patch.object(cli, "set_project_slug", lambda slug: None),
81
+ patch.object(cli, "exchange_refresh_token", lambda slug: ("", "token", 0)),
82
+ patch("platform.system", lambda: "Windows"),
83
+ patch.object(cli, "is_nfs_daemon_running", lambda: False),
84
+ patch.object(cli, "stop_nfs_watcher", lambda *a, **kw: None),
85
+ patch.object(cli, "is_windows_drive_mapped", lambda *a, **kw: False),
86
+ patch.object(cli, "cleanup_stuck_windows_mount_processes", lambda: None),
87
+ ]
88
+ for p in self.patches:
89
+ p.start()
90
+
91
+ def tearDown(self):
92
+ for p in reversed(self.patches):
93
+ p.stop()
94
+
95
+ def test_all_registered_commands_are_covered(self):
96
+ """Ensure every command registered on `app` and `mount_app` is included in ALL_COMMAND_INVOCATIONS."""
97
+ root_commands = {cmd.name or cmd.callback.__name__ for cmd in cli.app.registered_commands}
98
+ mount_commands = {cmd.name or cmd.callback.__name__ for cmd in cli.mount_app.registered_commands}
99
+
100
+ tested_root = {args[0] for args in ALL_COMMAND_INVOCATIONS if args and not args[0].startswith("-")}
101
+ tested_mount = {args[1] for args in ALL_COMMAND_INVOCATIONS if args[:1] == ["mount"] and len(args) > 1}
102
+
103
+ self.assertTrue(root_commands <= tested_root, f"Missing root commands: {root_commands - tested_root}")
104
+ self.assertTrue(mount_commands <= tested_mount, f"Missing mount commands: {mount_commands - tested_mount}")
105
+
106
+ def test_update_notice_shown_once_on_every_command(self):
107
+ runner = CliRunner()
108
+ expected_banner = f"🔔 Update available: accli 99.0.0 (current: {VERSION})"
109
+ expected_instruction = "To update, run: pip install -U accli"
110
+
111
+ for args in ALL_COMMAND_INVOCATIONS:
112
+ with self.subTest(command=" ".join(args)):
113
+ calls = []
114
+
115
+ def fake_check():
116
+ calls.append(1)
117
+ return True, "99.0.0"
118
+
119
+ with patch.object(cli, "check_for_updates", fake_check), patch.object(
120
+ cli, "get_upgrade_instruction", lambda: expected_instruction
121
+ ):
122
+ result = runner.invoke(cli.app, args, env={"COLUMNS": "200"})
123
+
124
+ self.assertEqual(
125
+ len(calls),
126
+ 1,
127
+ f"Expected check_for_updates to be called once for {args}, got {len(calls)}",
128
+ )
129
+ self.assertEqual(result.output.count(expected_banner), 1, result.output)
130
+ self.assertEqual(result.output.count(expected_instruction), 1, result.output)
131
+
132
+ def test_no_update_notice_when_up_to_date_on_every_command(self):
133
+ runner = CliRunner()
134
+
135
+ for args in ALL_COMMAND_INVOCATIONS:
136
+ with self.subTest(command=" ".join(args)):
137
+ calls = []
138
+
139
+ def fake_check():
140
+ calls.append(1)
141
+ return False, None
142
+
143
+ with patch.object(cli, "check_for_updates", fake_check):
144
+ result = runner.invoke(cli.app, args, env={"COLUMNS": "200"})
145
+
146
+ self.assertEqual(len(calls), 1, f"Expected check_for_updates to be called once for {args}")
147
+ self.assertNotIn("Update available:", result.output)
148
+
149
+
150
+ if __name__ == "__main__":
151
+ unittest.main()
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