accli 0.7__tar.gz → 0.7.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.
- {accli-0.7 → accli-0.7.2}/PKG-INFO +1 -1
- {accli-0.7 → accli-0.7.2}/accli/AcceleratorJobProjectService.py +94 -1
- {accli-0.7 → accli-0.7.2}/accli/_version.py +1 -1
- {accli-0.7 → accli-0.7.2}/accli.egg-info/PKG-INFO +1 -1
- {accli-0.7 → accli-0.7.2}/LICENSE +0 -0
- {accli-0.7 → accli-0.7.2}/README.md +0 -0
- {accli-0.7 → accli-0.7.2}/accli/AcceleratorTaskDispatcher.py +0 -0
- {accli-0.7 → accli-0.7.2}/accli/AcceleratorTerminalCliProjectService.py +0 -0
- {accli-0.7 → accli-0.7.2}/accli/CsvRegionalTimeseriesValidator.py +0 -0
- {accli-0.7 → accli-0.7.2}/accli/__init__.py +0 -0
- {accli-0.7 → accli-0.7.2}/accli/__main__.py +0 -0
- {accli-0.7 → accli-0.7.2}/accli/cli.py +0 -0
- {accli-0.7 → accli-0.7.2}/accli/common.py +0 -0
- {accli-0.7 → accli-0.7.2}/accli/token.py +0 -0
- {accli-0.7 → accli-0.7.2}/accli.egg-info/SOURCES.txt +0 -0
- {accli-0.7 → accli-0.7.2}/accli.egg-info/dependency_links.txt +0 -0
- {accli-0.7 → accli-0.7.2}/accli.egg-info/entry_points.txt +0 -0
- {accli-0.7 → accli-0.7.2}/accli.egg-info/requires.txt +0 -0
- {accli-0.7 → accli-0.7.2}/accli.egg-info/top_level.txt +0 -0
- {accli-0.7 → accli-0.7.2}/pyproject.toml +0 -0
- {accli-0.7 → accli-0.7.2}/setup.cfg +0 -0
|
@@ -6,6 +6,7 @@ import requests
|
|
|
6
6
|
import json
|
|
7
7
|
import base64
|
|
8
8
|
import urllib3
|
|
9
|
+
from urllib.parse import quote
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
from typing import List, Tuple
|
|
11
12
|
|
|
@@ -245,9 +246,23 @@ class AcceleratorJobProjectService:
|
|
|
245
246
|
return todict(res.data)
|
|
246
247
|
|
|
247
248
|
def get_put_create_multipart_upload_id(self, filename):
|
|
249
|
+
encoded_filename = quote(filename)
|
|
248
250
|
res = self.http_client_request(
|
|
249
251
|
"GET",
|
|
250
|
-
f"{self.cli_base_url}/
|
|
252
|
+
f"{self.cli_base_url}/multipart-upload-id/?filename={encoded_filename}",
|
|
253
|
+
headers=self.common_request_headers
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
data = todict(res.data)
|
|
257
|
+
|
|
258
|
+
return data['upload_id'], data['app_bucket_id'], data['uniqified_filename']
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def get_validator_create_multipart_upload_id(self, filename):
|
|
262
|
+
encoded_filename = quote(filename)
|
|
263
|
+
res = self.http_client_request(
|
|
264
|
+
"GET",
|
|
265
|
+
f"{self.cli_base_url}/validator-multipart-upload-id/?filename={encoded_filename}",
|
|
251
266
|
headers=self.common_request_headers
|
|
252
267
|
)
|
|
253
268
|
|
|
@@ -570,6 +585,84 @@ class AcceleratorJobProjectService:
|
|
|
570
585
|
|
|
571
586
|
raise err
|
|
572
587
|
|
|
588
|
+
|
|
589
|
+
def add_filestream_as_validation_supporter(self, filename, file_stream, is_log_file=False):
|
|
590
|
+
headers = dict()
|
|
591
|
+
headers["Content-Type"] = "application/octet-stream"
|
|
592
|
+
|
|
593
|
+
part_size, part_count = 50 * 1024**2, -1
|
|
594
|
+
|
|
595
|
+
upload_id = None
|
|
596
|
+
app_bucket_id = None
|
|
597
|
+
uniqified_filename = None
|
|
598
|
+
|
|
599
|
+
one_byte = b""
|
|
600
|
+
stop = False
|
|
601
|
+
part_number = 0
|
|
602
|
+
parts = []
|
|
603
|
+
uploaded_size = 0
|
|
604
|
+
put_presigned_url = None
|
|
605
|
+
|
|
606
|
+
try:
|
|
607
|
+
while not stop:
|
|
608
|
+
part_number += 1
|
|
609
|
+
part_data = self.read_part_data(
|
|
610
|
+
file_stream,
|
|
611
|
+
part_size + 1,
|
|
612
|
+
one_byte,
|
|
613
|
+
progress=None,
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
# If part_data_size is less or equal to part_size,
|
|
617
|
+
# then we have reached last part.
|
|
618
|
+
if len(part_data) <= part_size:
|
|
619
|
+
part_count = part_number
|
|
620
|
+
stop = True
|
|
621
|
+
else:
|
|
622
|
+
one_byte = part_data[-1:]
|
|
623
|
+
part_data = part_data[:-1]
|
|
624
|
+
|
|
625
|
+
uploaded_size += len(part_data)
|
|
626
|
+
|
|
627
|
+
if not upload_id:
|
|
628
|
+
(
|
|
629
|
+
upload_id,
|
|
630
|
+
app_bucket_id,
|
|
631
|
+
uniqified_filename,
|
|
632
|
+
) = self.get_put_create_multipart_upload_id(
|
|
633
|
+
filename,
|
|
634
|
+
# headers=headers
|
|
635
|
+
)
|
|
636
|
+
|
|
637
|
+
put_presigned_url = self.get_validator_create_multipart_upload_id(
|
|
638
|
+
app_bucket_id, uniqified_filename, upload_id, part_number
|
|
639
|
+
)
|
|
640
|
+
|
|
641
|
+
part_upload_response = requests.put(
|
|
642
|
+
put_presigned_url,
|
|
643
|
+
data=part_data,
|
|
644
|
+
# headers=headers,
|
|
645
|
+
verify=False,
|
|
646
|
+
)
|
|
647
|
+
|
|
648
|
+
etag = part_upload_response.headers.get("etag").replace('"', "")
|
|
649
|
+
parts.append((part_number, etag))
|
|
650
|
+
|
|
651
|
+
created_bucket_object_id = self.complete_job_multipart_upload(
|
|
652
|
+
app_bucket_id, uniqified_filename, upload_id, parts, is_log_file=is_log_file
|
|
653
|
+
)
|
|
654
|
+
return created_bucket_object_id
|
|
655
|
+
|
|
656
|
+
except Exception as err:
|
|
657
|
+
# Cancel if any error
|
|
658
|
+
if upload_id:
|
|
659
|
+
self.abort_create_multipart_upload(
|
|
660
|
+
app_bucket_id,
|
|
661
|
+
uniqified_filename,
|
|
662
|
+
upload_id,
|
|
663
|
+
)
|
|
664
|
+
raise err
|
|
665
|
+
|
|
573
666
|
def update_job_status(self, status):
|
|
574
667
|
headers = {
|
|
575
668
|
# "Content-Type": "application/json"
|
|
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
|