accli 1.1.3__tar.gz → 2.0.0__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.4
2
2
  Name: accli
3
- Version: 1.1.3
3
+ Version: 2.0.0
4
4
  Summary: IIASA Accelerator Client
5
5
  Author-email: Wrufesh S <wrufesh@gmail.com>
6
6
  License: The MIT License (MIT)
@@ -39,9 +39,9 @@ Requires-Dist: requests>=2.25.1
39
39
  Requires-Dist: jsonschema>=4.5.1
40
40
  Requires-Dist: pydantic>=2.0
41
41
  Requires-Dist: GitPython
42
+ Requires-Dist: hf-xet==1.5.2
42
43
  Dynamic: license-file
43
44
 
44
-
45
45
  # Accelerator Terminal Client and Python API
46
46
 
47
47
  This package provides:
@@ -49,7 +49,8 @@ This package provides:
49
49
  - A **command-line client** (`accli`) for interacting with the **Accelerator**.
50
50
  - A **Python API** via the `accli` package.
51
51
 
52
- Both interfaces communicate with the Accelerator’s REST API, implemented in the [Control Services Backend](https://github.com/iiasa/control_services_backend).
52
+ Both interfaces communicate with the Accelerator’s REST API, implemented in
53
+ the [Control Services Backend](https://github.com/iiasa/control_services_backend).
53
54
 
54
55
  ---
55
56
 
@@ -57,10 +58,11 @@ Both interfaces communicate with the Accelerator’s REST API, implemented in th
57
58
 
58
59
  This client uses **device authentication** via Auth0.
59
60
 
60
- - **OAuth Flow**: [Device Authorization Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow)
61
- - **Token Validity**: 7 days
62
- - **Access Control**: Role-Based Access Control (RBAC) with stateless tokens
63
- - **Grants**: Limited and scoped
61
+ - **OAuth Flow
62
+ **: [Device Authorization Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow)
63
+ - **Token Validity**: 7 days
64
+ - **Access Control**: Role-Based Access Control (RBAC) with stateless tokens
65
+ - **Grants**: Limited and scoped
64
66
 
65
67
  ---
66
68
 
@@ -77,11 +79,13 @@ This client uses **device authentication** via Auth0.
77
79
  No Python install required. Run the appropriate command for your system:
78
80
 
79
81
  **Linux / macOS:**
82
+
80
83
  ```bash
81
84
  curl -fsSL https://raw.githubusercontent.com/iiasa/accli/master/scripts/install.sh | bash
82
85
  ```
83
86
 
84
87
  **Windows (PowerShell):**
88
+
85
89
  ```powershell
86
90
  irm https://raw.githubusercontent.com/iiasa/accli/master/scripts/install.ps1 | iex
87
91
  ```
@@ -132,6 +136,17 @@ Usage: accli [OPTIONS] COMMAND [ARGS]...
132
136
 
133
137
  ## 👩‍💻 Developer Guide
134
138
 
139
+ ### Handling self-signed certificates
140
+
141
+ 1. Copy and paste certificates from `<control_services_backend>/certs/ca.crt` as
142
+ `./certs/dev-backend.crt` and `<accelerator_service>/minio_certs/ca.crt` as
143
+ `./certs/dev-minio-ca.crt`.
144
+ 2. Run
145
+ ```
146
+ cd scripts
147
+ import_certs_certutil.ps1
148
+ ```
149
+
135
150
  ### 🛠 Build & Upload
136
151
 
137
152
  Follow the official Python packaging tutorial:
@@ -1,4 +1,3 @@
1
-
2
1
  # Accelerator Terminal Client and Python API
3
2
 
4
3
  This package provides:
@@ -6,7 +5,8 @@ This package provides:
6
5
  - A **command-line client** (`accli`) for interacting with the **Accelerator**.
7
6
  - A **Python API** via the `accli` package.
8
7
 
9
- Both interfaces communicate with the Accelerator’s REST API, implemented in the [Control Services Backend](https://github.com/iiasa/control_services_backend).
8
+ Both interfaces communicate with the Accelerator’s REST API, implemented in
9
+ the [Control Services Backend](https://github.com/iiasa/control_services_backend).
10
10
 
11
11
  ---
12
12
 
@@ -14,10 +14,11 @@ Both interfaces communicate with the Accelerator’s REST API, implemented in th
14
14
 
15
15
  This client uses **device authentication** via Auth0.
16
16
 
17
- - **OAuth Flow**: [Device Authorization Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow)
18
- - **Token Validity**: 7 days
19
- - **Access Control**: Role-Based Access Control (RBAC) with stateless tokens
20
- - **Grants**: Limited and scoped
17
+ - **OAuth Flow
18
+ **: [Device Authorization Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow)
19
+ - **Token Validity**: 7 days
20
+ - **Access Control**: Role-Based Access Control (RBAC) with stateless tokens
21
+ - **Grants**: Limited and scoped
21
22
 
22
23
  ---
23
24
 
@@ -34,11 +35,13 @@ This client uses **device authentication** via Auth0.
34
35
  No Python install required. Run the appropriate command for your system:
35
36
 
36
37
  **Linux / macOS:**
38
+
37
39
  ```bash
38
40
  curl -fsSL https://raw.githubusercontent.com/iiasa/accli/master/scripts/install.sh | bash
39
41
  ```
40
42
 
41
43
  **Windows (PowerShell):**
44
+
42
45
  ```powershell
43
46
  irm https://raw.githubusercontent.com/iiasa/accli/master/scripts/install.ps1 | iex
44
47
  ```
@@ -89,6 +92,17 @@ Usage: accli [OPTIONS] COMMAND [ARGS]...
89
92
 
90
93
  ## 👩‍💻 Developer Guide
91
94
 
95
+ ### Handling self-signed certificates
96
+
97
+ 1. Copy and paste certificates from `<control_services_backend>/certs/ca.crt` as
98
+ `./certs/dev-backend.crt` and `<accelerator_service>/minio_certs/ca.crt` as
99
+ `./certs/dev-minio-ca.crt`.
100
+ 2. Run
101
+ ```
102
+ cd scripts
103
+ import_certs_certutil.ps1
104
+ ```
105
+
92
106
  ### 🛠 Build & Upload
93
107
 
94
108
  Follow the official Python packaging tutorial:
@@ -446,6 +446,30 @@ class AcceleratorJobProjectService:
446
446
  headers=headers
447
447
  )
448
448
 
449
+ def register_validation_with_filename(
450
+ self,
451
+ validated_filename: str,
452
+ dataset_template_id: int,
453
+ validated_metadata: dict,
454
+ validation_supporting_filenames: List[str]
455
+ ):
456
+ headers = {"Content-Type": "application/json"}
457
+
458
+ headers.update(self.common_request_headers)
459
+
460
+ res = self.http_client_request(
461
+ "PUT",
462
+ f"{self.cli_base_url}/register-validation-with-filename/",
463
+ json=dict(
464
+ validated_filename=validated_filename,
465
+ dataset_template_id=dataset_template_id,
466
+ validated_metadata=validated_metadata,
467
+ validation_supporting_filenames=validation_supporting_filenames
468
+ ),
469
+ headers=headers
470
+ )
471
+
472
+
449
473
  def get_dataset_template_details(
450
474
  self,
451
475
  dataset_template_id
@@ -139,10 +139,10 @@ class JobDispatchModel(BaseModel):
139
139
  class WKubeTaskMeta(BaseModel):
140
140
  required_cores: float
141
141
  required_ram: float
142
- required_storage_local: float
142
+ required_storage_local: Optional[float] = None
143
143
 
144
144
  # is ignored if it is a callback and child of non-free node jobs
145
- required_storage_workflow: float
145
+ required_storage_workflow: Optional[float] = None
146
146
 
147
147
  job_secrets: Optional[dict] = {}
148
148
 
@@ -4,6 +4,7 @@ import json
4
4
  import os
5
5
 
6
6
  import requests
7
+ from requests.adapters import HTTPAdapter
7
8
  import urllib3
8
9
  from typing import List, Tuple
9
10
 
@@ -21,7 +22,12 @@ class AccAPIError(Exception):
21
22
  self.status_code = status_code
22
23
 
23
24
 
24
- retries = urllib3.util.Retry(total=10, backoff_factor=1)
25
+ retries = urllib3.util.Retry(
26
+ total=10,
27
+ backoff_factor=1,
28
+ status_forcelist=[408, 429, 500, 502, 503, 504],
29
+ allowed_methods=["HEAD", "GET", "OPTIONS", "PUT"]
30
+ )
25
31
 
26
32
  http_client = urllib3.poolmanager.PoolManager(
27
33
  num_pools=20, retries=retries, maxsize=2000, block=True
@@ -41,8 +47,9 @@ class AcceleratorTerminalCliProjectService:
41
47
  ):
42
48
 
43
49
  self.user_token = user_token
50
+ self.verify_cert = verify_cert
44
51
 
45
- if verify_cert:
52
+ if self.verify_cert:
46
53
  self.http_client = http_client
47
54
  else:
48
55
  self.http_client = http_client_wo_cert_verification
@@ -264,16 +271,22 @@ class AcceleratorTerminalCliProjectService:
264
271
  project_slug, app_bucket_id, uniqified_filename, upload_id, part_number
265
272
  )
266
273
 
267
- part_upload_response = requests.put(
268
- put_presigned_url,
269
- data=part_data,
270
- # headers=headers,
271
- verify=False,
272
- )
274
+ session = requests.Session()
275
+ adapter = HTTPAdapter(max_retries=retries)
276
+ session.mount("https://", adapter)
277
+ session.verify = self.verify_cert
278
+
279
+ with session.put(
280
+ put_presigned_url,
281
+ data=part_data,
282
+ timeout=120
283
+ ) as part_upload_response:
284
+ part_upload_response.raise_for_status()
285
+
286
+ etag = part_upload_response.headers.get("etag").replace('"', "")
273
287
 
274
288
  progress.update(task, advance=len(part_data))
275
289
 
276
- etag = part_upload_response.headers.get("etag").replace('"', "")
277
290
  return part_number, etag
278
291
 
279
292
  def upload_filestream_to_accelerator(self, project_slug, filename, file_stream, progress, task,
@@ -205,8 +205,8 @@ class CsvRegionalTimeseriesValidator:
205
205
  for key in self.errors:
206
206
  print(f"[bold red]Invalid data:[/bold red] {self.errors[key]}")
207
207
  print(f"[bold red]Error:[/bold red] {key}")
208
- print("[bold red]Data is not valid against selected template. ⚠️⚠️")
208
+ print("[bold red]Data is not valid against selected template.[/bold red]")
209
209
  typer.Exit(1)
210
210
  else:
211
- print("[bold green]Data validated against selected template.[/bold green] 🎉🎉")
211
+ print("[bold green]Data validated against selected template.[/bold green]")
212
212
  typer.Exit(0)
@@ -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 = "v1.1.3"
3
+ VERSION = "v2.0.0"
@@ -0,0 +1,57 @@
1
+ <#
2
+ .SYNOPSIS
3
+ Reverts all Windows NFS Client and Task Scheduler changes made by setup-nfs.ps1.
4
+ .DESCRIPTION
5
+ This script removes the scheduled task, registry keys, ProgramData configs, and disables
6
+ the native Windows NFS Client features. Useful for testing first-time accli setups.
7
+ .NOTES
8
+ Must be run in an elevated (Administrator) PowerShell window.
9
+ .EXAMPLE
10
+ # Open an Administrator PowerShell window and execute:
11
+ powershell -ExecutionPolicy Bypass -File .\accli\cleanup-nfs.ps1
12
+ #>
13
+
14
+ # Ensure running as Administrator
15
+ $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
16
+ if (-not $isAdmin) {
17
+ Write-Error "This script must be run as Administrator."
18
+ Write-Host "Please open PowerShell as Administrator and run:" -ForegroundColor Yellow
19
+ Write-Host " powershell -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -ForegroundColor Yellow
20
+ exit 1
21
+ }
22
+
23
+ Write-Host "=== Reverting accli Windows NFS Client Configuration ===" -ForegroundColor Cyan
24
+
25
+ # 1. Unregister Scheduled Tasks
26
+ Write-Host "Removing Scheduled Tasks..." -ForegroundColor Yellow
27
+ if (Get-Command Unregister-ScheduledTask -ErrorAction SilentlyContinue) {
28
+ Unregister-ScheduledTask -TaskName "accli-mount-nfs" -Confirm:$false -ErrorAction SilentlyContinue | Out-Null
29
+ Unregister-ScheduledTask -TaskName "accli-umount-nfs" -Confirm:$false -ErrorAction SilentlyContinue | Out-Null
30
+ } else {
31
+ schtasks /delete /tn "accli-mount-nfs" /f 2> $null | Out-Null
32
+ schtasks /delete /tn "accli-umount-nfs" /f 2> $null | Out-Null
33
+ }
34
+ Write-Host "[OK] Scheduled Tasks removed." -ForegroundColor Green
35
+
36
+ # 2. Delete Registry Policy Keys
37
+ Write-Host "Removing registry policies (EnableLinkedConnections, AnonymousUid, AnonymousGid)..." -ForegroundColor Yellow
38
+ Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLinkedConnections" -ErrorAction SilentlyContinue | Out-Null
39
+ Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" -Name "AnonymousUid" -ErrorAction SilentlyContinue | Out-Null
40
+ Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default" -Name "AnonymousGid" -ErrorAction SilentlyContinue | Out-Null
41
+ Write-Host "[OK] Registry policies removed." -ForegroundColor Green
42
+
43
+ # 3. Delete Config Folder & Helpers
44
+ Write-Host "Deleting ProgramData configurations..." -ForegroundColor Yellow
45
+ Remove-Item -Path "C:\ProgramData\accli" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
46
+ Write-Host "[OK] ProgramData folder removed." -ForegroundColor Green
47
+
48
+ # 4. Disable Windows NFS Client features
49
+ Write-Host "Disabling Windows Client for NFS features..." -ForegroundColor Yellow
50
+ if (Get-Command Disable-WindowsOptionalFeature -ErrorAction SilentlyContinue) {
51
+ Disable-WindowsOptionalFeature -Online -FeatureName ServicesForNFS-ClientOnly,ClientForNFS-Infrastructure -NoRestart | Out-Null
52
+ }
53
+ Write-Host "[OK] NFS Client features disabled." -ForegroundColor Green
54
+
55
+ Write-Host ""
56
+ Write-Host "Reversion completed successfully!" -ForegroundColor Green
57
+ Write-Host "⚠ Note: A Windows sign-out/sign-in or system restart is required for changes to take effect." -ForegroundColor Yellow