accli 0.4.1__tar.gz → 0.5__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.
- {accli-0.4.1/accli.egg-info → accli-0.5}/PKG-INFO +1 -1
- {accli-0.4.1 → accli-0.5}/README.md +0 -0
- {accli-0.4.1 → accli-0.5}/accli/AcceleratorJobProjectService.py +47 -6
- {accli-0.4.1 → accli-0.5}/accli/AcceleratorTaskDispatcher.py +3 -1
- {accli-0.4.1 → accli-0.5}/accli/AcceleratorTerminalCliProjectService.py +22 -4
- {accli-0.4.1 → accli-0.5}/accli/_version.py +1 -1
- {accli-0.4.1 → accli-0.5/accli.egg-info}/PKG-INFO +1 -1
- {accli-0.4.1 → accli-0.5}/accli.egg-info/SOURCES.txt +0 -3
- {accli-0.4.1 → accli-0.5}/accli.egg-info/requires.txt +1 -1
- {accli-0.4.1 → accli-0.5}/pyproject.toml +1 -1
- accli-0.4.1/.gitignore +0 -6
- accli-0.4.1/Dockerfile.dev +0 -2
- accli-0.4.1/requirements.txt +0 -8
- {accli-0.4.1 → accli-0.5}/LICENSE +0 -0
- {accli-0.4.1 → accli-0.5}/accli/CsvRegionalTimeseriesValidator.py +0 -0
- {accli-0.4.1 → accli-0.5}/accli/__init__.py +0 -0
- {accli-0.4.1 → accli-0.5}/accli/__main__.py +0 -0
- {accli-0.4.1 → accli-0.5}/accli/cli.py +0 -0
- {accli-0.4.1 → accli-0.5}/accli/token.py +0 -0
- {accli-0.4.1 → accli-0.5}/accli.egg-info/dependency_links.txt +0 -0
- {accli-0.4.1 → accli-0.5}/accli.egg-info/entry_points.txt +0 -0
- {accli-0.4.1 → accli-0.5}/accli.egg-info/top_level.txt +0 -0
- {accli-0.4.1 → accli-0.5}/setup.cfg +0 -0
|
File without changes
|
|
@@ -16,6 +16,16 @@ class AccAPIError(Exception):
|
|
|
16
16
|
# self.response_data = kwargs.pop('response_data')
|
|
17
17
|
# super().__init__(*args, **kwargs)
|
|
18
18
|
|
|
19
|
+
retries = urllib3.util.Retry(total=10, backoff_factor=1)
|
|
20
|
+
|
|
21
|
+
http_client = urllib3.poolmanager.PoolManager(
|
|
22
|
+
num_pools=20, retries=retries
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
http_client_wo_cert_verification = urllib3.poolmanager.PoolManager(
|
|
26
|
+
cert_reqs="CERT_NONE", num_pools=20, retries=retries
|
|
27
|
+
)
|
|
28
|
+
|
|
19
29
|
class AcceleratorJobProjectService:
|
|
20
30
|
def __init__(
|
|
21
31
|
self,
|
|
@@ -26,12 +36,10 @@ class AcceleratorJobProjectService:
|
|
|
26
36
|
|
|
27
37
|
self.user_token = user_token
|
|
28
38
|
|
|
29
|
-
retries = urllib3.util.Retry(total=10, backoff_factor=1)
|
|
30
|
-
|
|
31
39
|
if verify_cert:
|
|
32
|
-
self.http_client =
|
|
40
|
+
self.http_client = http_client
|
|
33
41
|
else:
|
|
34
|
-
self.http_client =
|
|
42
|
+
self.http_client = http_client_wo_cert_verification
|
|
35
43
|
|
|
36
44
|
self.cli_base_url = f"{server_url}/v1/ajob-cli"
|
|
37
45
|
self.common_request_headers = {
|
|
@@ -58,6 +66,16 @@ class AcceleratorJobProjectService:
|
|
|
58
66
|
)
|
|
59
67
|
return res.json()
|
|
60
68
|
|
|
69
|
+
def get_file_url_from_repo(self, filename):
|
|
70
|
+
project_slug = filename.split('/')[0]
|
|
71
|
+
res = self.http_client_request(
|
|
72
|
+
"GET",
|
|
73
|
+
f"{self.cli_base_url}/{project_slug}/get-file-download-url/?filename={filename}",
|
|
74
|
+
headers=self.common_request_headers
|
|
75
|
+
)
|
|
76
|
+
if res.data:
|
|
77
|
+
return res.json()
|
|
78
|
+
|
|
61
79
|
def get_dataset_type(self, *args, **kwargs):
|
|
62
80
|
return self.get_bucket_object_validation_type(*args, **kwargs)
|
|
63
81
|
|
|
@@ -100,13 +118,14 @@ class AcceleratorJobProjectService:
|
|
|
100
118
|
def add_log_file(self, data: bytes, filename):
|
|
101
119
|
res = self.http_client_request(
|
|
102
120
|
"GET",
|
|
103
|
-
f"{self.cli_base_url}/presigned-upload-url/?filename={filename}",
|
|
121
|
+
f"{self.cli_base_url}/presigned-log-upload-url/?filename={filename}",
|
|
104
122
|
headers=self.common_request_headers
|
|
105
123
|
).json()
|
|
106
124
|
|
|
107
125
|
upload_url = res['upload_url']
|
|
108
126
|
app_bucket_id = res['app_bucket_id']
|
|
109
127
|
res_filename = res['filename']
|
|
128
|
+
is_healthy = res['is_healthy']
|
|
110
129
|
|
|
111
130
|
requests.put(
|
|
112
131
|
upload_url,
|
|
@@ -125,6 +144,9 @@ class AcceleratorJobProjectService:
|
|
|
125
144
|
headers=self.common_request_headers
|
|
126
145
|
)
|
|
127
146
|
|
|
147
|
+
if not is_healthy:
|
|
148
|
+
os.Exit(1)
|
|
149
|
+
|
|
128
150
|
|
|
129
151
|
|
|
130
152
|
def get_multipart_put_create_signed_url(
|
|
@@ -532,10 +554,29 @@ class Fs:
|
|
|
532
554
|
file.write(filestream.getvalue())
|
|
533
555
|
|
|
534
556
|
@staticmethod
|
|
535
|
-
def
|
|
557
|
+
def get_file_url(remote_filepath):
|
|
536
558
|
user_token = os.environ.get("ACC_JOB_JOB_TOKEN", None)
|
|
537
559
|
server_url = os.environ.get("ACC_JOB_GATEWAY_SERVER", None)
|
|
538
560
|
|
|
561
|
+
if not (user_token and server_url):
|
|
562
|
+
raise ValueError("Remote data repository credentials not found.")
|
|
563
|
+
|
|
564
|
+
accelerator_job_service = AcceleratorJobProjectService(
|
|
565
|
+
user_token,
|
|
566
|
+
server_url=server_url,
|
|
567
|
+
verify_cert=True
|
|
568
|
+
)
|
|
569
|
+
|
|
570
|
+
return accelerator_job_service.get_file_url_from_repo(
|
|
571
|
+
remote_filepath
|
|
572
|
+
)
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
@staticmethod
|
|
576
|
+
def write_file(source: typing.Union[str, io.BytesIO], dest_filepath):
|
|
577
|
+
user_token = os.environ.get("ACC_JOB_TOKEN", None)
|
|
578
|
+
server_url = os.environ.get("ACC_JOB_GATEWAY_SERVER", None)
|
|
579
|
+
|
|
539
580
|
if isinstance(source, io.BytesIO):
|
|
540
581
|
if (user_token and server_url):
|
|
541
582
|
Fs.write_stream_remote(source, dest_filepath, user_token, server_url)
|
|
@@ -4,7 +4,7 @@ import hashlib
|
|
|
4
4
|
import shutil
|
|
5
5
|
import tempfile
|
|
6
6
|
from typing import Optional, List, Dict
|
|
7
|
-
from pydantic import BaseModel, root_validator
|
|
7
|
+
from pydantic.v1 import BaseModel, root_validator
|
|
8
8
|
|
|
9
9
|
from accli.token import get_github_app_token
|
|
10
10
|
|
|
@@ -139,6 +139,8 @@ class WKubeTaskKwargs(BaseModel):
|
|
|
139
139
|
|
|
140
140
|
conf: Dict[str,str] = {}
|
|
141
141
|
|
|
142
|
+
build_timeout: Optional[int]
|
|
143
|
+
|
|
142
144
|
def dict(self, *args, **kwargs):
|
|
143
145
|
result = super().dict(*args, **kwargs)
|
|
144
146
|
if 'job_folder' in result:
|
|
@@ -18,6 +18,16 @@ class AccAPIError(Exception):
|
|
|
18
18
|
self.response = response
|
|
19
19
|
self.status_code = status_code
|
|
20
20
|
|
|
21
|
+
retries = urllib3.util.Retry(total=10, backoff_factor=1)
|
|
22
|
+
|
|
23
|
+
http_client = urllib3.poolmanager.PoolManager(
|
|
24
|
+
num_pools=20, retries=retries
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
http_client_wo_cert_verification = urllib3.poolmanager.PoolManager(
|
|
28
|
+
cert_reqs="CERT_NONE", num_pools=20, retries=retries
|
|
29
|
+
)
|
|
30
|
+
|
|
21
31
|
class AcceleratorTerminalCliProjectService:
|
|
22
32
|
def __init__(
|
|
23
33
|
self,
|
|
@@ -28,12 +38,10 @@ class AcceleratorTerminalCliProjectService:
|
|
|
28
38
|
|
|
29
39
|
self.user_token = user_token
|
|
30
40
|
|
|
31
|
-
retries = urllib3.util.Retry(total=10, backoff_factor=1)
|
|
32
|
-
|
|
33
41
|
if verify_cert:
|
|
34
|
-
self.http_client =
|
|
42
|
+
self.http_client = http_client
|
|
35
43
|
else:
|
|
36
|
-
self.http_client =
|
|
44
|
+
self.http_client = http_client_wo_cert_verification
|
|
37
45
|
|
|
38
46
|
self.server_url = server_url
|
|
39
47
|
self.cli_base_url = f"{self.server_url}/v1/aterm-cli"
|
|
@@ -70,6 +78,16 @@ class AcceleratorTerminalCliProjectService:
|
|
|
70
78
|
|
|
71
79
|
return res.json()
|
|
72
80
|
|
|
81
|
+
def get_file_url_from_repo(self, filename):
|
|
82
|
+
project_slug = filename.split('/')[0]
|
|
83
|
+
res = self.http_client_request(
|
|
84
|
+
"GET",
|
|
85
|
+
f"{self.cli_base_url}/{project_slug}/get-file-download-url/?filename={filename}",
|
|
86
|
+
headers=self.common_request_headers
|
|
87
|
+
)
|
|
88
|
+
if res.data:
|
|
89
|
+
return res.json()
|
|
90
|
+
|
|
73
91
|
def get_github_app_token(self, project_slug):
|
|
74
92
|
|
|
75
93
|
res = self.http_client_request(
|
|
@@ -12,7 +12,7 @@ description = "IIASA Accelerator Client"
|
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
license = {file = "LICENSE"}
|
|
14
14
|
requires-python = ">=3.7.17"
|
|
15
|
-
dependencies = ['urllib3', 'typer[all]', 'tinydb', 'requests', 'jsonschema', 'pydantic
|
|
15
|
+
dependencies = ['urllib3', 'typer[all]', 'tinydb', 'requests', 'jsonschema', 'pydantic', 'gitpython']
|
|
16
16
|
classifiers = [
|
|
17
17
|
"Programming Language :: Python :: 3",
|
|
18
18
|
"License :: OSI Approved :: MIT License",
|
accli-0.4.1/.gitignore
DELETED
accli-0.4.1/Dockerfile.dev
DELETED
accli-0.4.1/requirements.txt
DELETED
|
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
|