accli 1.1.2__tar.gz → 1.1.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.
- {accli-1.1.2 → accli-1.1.4}/PKG-INFO +1 -1
- {accli-1.1.2 → accli-1.1.4}/accli/AcceleratorTerminalCliProjectService.py +42 -19
- {accli-1.1.2 → accli-1.1.4}/accli/_version.py +1 -1
- {accli-1.1.2 → accli-1.1.4}/accli.egg-info/PKG-INFO +1 -1
- {accli-1.1.2 → accli-1.1.4}/LICENSE +0 -0
- {accli-1.1.2 → accli-1.1.4}/README.md +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli/AcceleratorJobProjectService.py +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli/AcceleratorTaskDispatcher.py +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli/CsvRegionalTimeseriesValidator.py +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli/__init__.py +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli/__main__.py +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli/cli.py +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli/common.py +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli/token.py +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli.egg-info/SOURCES.txt +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli.egg-info/dependency_links.txt +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli.egg-info/entry_points.txt +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli.egg-info/requires.txt +0 -0
- {accli-1.1.2 → accli-1.1.4}/accli.egg-info/top_level.txt +0 -0
- {accli-1.1.2 → accli-1.1.4}/pyproject.toml +0 -0
- {accli-1.1.2 → accli-1.1.4}/setup.cfg +0 -0
|
@@ -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(
|
|
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
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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,
|
|
@@ -281,7 +294,7 @@ class AcceleratorTerminalCliProjectService:
|
|
|
281
294
|
headers = dict()
|
|
282
295
|
headers["Content-Type"] = "application/octet-stream"
|
|
283
296
|
|
|
284
|
-
part_size, part_count =
|
|
297
|
+
part_size, part_count = 50 * 1024 ** 2, -1
|
|
285
298
|
|
|
286
299
|
upload_id = None
|
|
287
300
|
app_bucket_id = None
|
|
@@ -294,13 +307,21 @@ class AcceleratorTerminalCliProjectService:
|
|
|
294
307
|
uploaded_size = 0
|
|
295
308
|
put_presigned_url = None
|
|
296
309
|
|
|
297
|
-
futures = []
|
|
298
|
-
|
|
299
310
|
try:
|
|
300
311
|
|
|
301
312
|
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
|
|
302
313
|
|
|
314
|
+
active_futures = set()
|
|
315
|
+
|
|
303
316
|
while not stop:
|
|
317
|
+
if len(active_futures) >= max_workers:
|
|
318
|
+
done, active_futures = concurrent.futures.wait(
|
|
319
|
+
active_futures,
|
|
320
|
+
return_when=concurrent.futures.FIRST_COMPLETED
|
|
321
|
+
)
|
|
322
|
+
for f in done:
|
|
323
|
+
parts.append(f.result())
|
|
324
|
+
|
|
304
325
|
part_number += 1
|
|
305
326
|
part_data = self.read_part_data(
|
|
306
327
|
file_stream,
|
|
@@ -331,14 +352,16 @@ class AcceleratorTerminalCliProjectService:
|
|
|
331
352
|
# headers=headers
|
|
332
353
|
)
|
|
333
354
|
|
|
334
|
-
future = executor.submit(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
futures_results = concurrent.futures.wait(futures, return_when=concurrent.futures.ALL_COMPLETED)
|
|
355
|
+
future = executor.submit(
|
|
356
|
+
self.put_part, project_slug, app_bucket_id, uniqified_filename,
|
|
357
|
+
upload_id, part_number, part_data, progress, task
|
|
358
|
+
)
|
|
359
|
+
active_futures.add(future)
|
|
340
360
|
|
|
341
|
-
|
|
361
|
+
if active_futures:
|
|
362
|
+
done, _ = concurrent.futures.wait(active_futures, return_when=concurrent.futures.ALL_COMPLETED)
|
|
363
|
+
for f in done:
|
|
364
|
+
parts.append(f.result())
|
|
342
365
|
|
|
343
366
|
parts.sort(key=lambda x: x[0])
|
|
344
367
|
|
|
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
|