kleinkram 0.13.2.dev20240830095132__py3-none-any.whl → 0.13.2.dev20240830095727__py3-none-any.whl
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.
Potentially problematic release.
This version of kleinkram might be problematic. Click here for more details.
- kleinkram/helper.py +32 -19
- kleinkram/main.py +1 -1
- {kleinkram-0.13.2.dev20240830095132.dist-info → kleinkram-0.13.2.dev20240830095727.dist-info}/METADATA +1 -1
- {kleinkram-0.13.2.dev20240830095132.dist-info → kleinkram-0.13.2.dev20240830095727.dist-info}/RECORD +7 -7
- {kleinkram-0.13.2.dev20240830095132.dist-info → kleinkram-0.13.2.dev20240830095727.dist-info}/WHEEL +0 -0
- {kleinkram-0.13.2.dev20240830095132.dist-info → kleinkram-0.13.2.dev20240830095727.dist-info}/entry_points.txt +0 -0
- {kleinkram-0.13.2.dev20240830095132.dist-info → kleinkram-0.13.2.dev20240830095727.dist-info}/licenses/LICENSE +0 -0
kleinkram/helper.py
CHANGED
|
@@ -6,7 +6,6 @@ from functools import partial
|
|
|
6
6
|
from typing import Dict
|
|
7
7
|
import boto3
|
|
8
8
|
|
|
9
|
-
import httpx
|
|
10
9
|
import tqdm
|
|
11
10
|
from boto3.s3.transfer import TransferConfig
|
|
12
11
|
from botocore.client import BaseClient
|
|
@@ -14,6 +13,7 @@ from rich import print
|
|
|
14
13
|
|
|
15
14
|
from kleinkram.api_client import AuthenticatedClient
|
|
16
15
|
|
|
16
|
+
|
|
17
17
|
class TransferCallback:
|
|
18
18
|
"""
|
|
19
19
|
Handle callbacks from the transfer manager.
|
|
@@ -40,10 +40,15 @@ class TransferCallback:
|
|
|
40
40
|
:param target_size: The total size of the file being transferred.
|
|
41
41
|
"""
|
|
42
42
|
with self._lock:
|
|
43
|
-
tqdm_instance = tqdm.tqdm(
|
|
43
|
+
tqdm_instance = tqdm.tqdm(
|
|
44
|
+
total=target_size,
|
|
45
|
+
unit="B",
|
|
46
|
+
unit_scale=True,
|
|
47
|
+
desc=f"Uploading {file_id}",
|
|
48
|
+
)
|
|
44
49
|
self.file_progress[file_id] = {
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
"tqdm": tqdm_instance,
|
|
51
|
+
"total_transferred": 0,
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
def __call__(self, file_id, bytes_transferred):
|
|
@@ -60,16 +65,18 @@ class TransferCallback:
|
|
|
60
65
|
with self._lock:
|
|
61
66
|
if file_id in self.file_progress:
|
|
62
67
|
progress = self.file_progress[file_id]
|
|
63
|
-
progress[
|
|
68
|
+
progress["total_transferred"] += bytes_transferred
|
|
64
69
|
|
|
65
70
|
# Update tqdm progress bar
|
|
66
|
-
progress[
|
|
71
|
+
progress["tqdm"].update(bytes_transferred)
|
|
67
72
|
|
|
68
73
|
def close(self):
|
|
69
74
|
"""Close all tqdm progress bars."""
|
|
70
75
|
with self._lock:
|
|
71
76
|
for progress in self.file_progress.values():
|
|
72
|
-
progress[
|
|
77
|
+
progress["tqdm"].close()
|
|
78
|
+
|
|
79
|
+
|
|
73
80
|
def create_transfer_callback(callback_instance, file_id):
|
|
74
81
|
"""
|
|
75
82
|
Factory function to create a partial function for TransferCallback.
|
|
@@ -79,6 +86,7 @@ def create_transfer_callback(callback_instance, file_id):
|
|
|
79
86
|
"""
|
|
80
87
|
return partial(callback_instance.__call__, file_id)
|
|
81
88
|
|
|
89
|
+
|
|
82
90
|
def expand_and_match(path_pattern):
|
|
83
91
|
expanded_path = os.path.expanduser(path_pattern)
|
|
84
92
|
expanded_path = os.path.expandvars(expanded_path)
|
|
@@ -99,10 +107,11 @@ def uploadFiles(files: Dict[str, str], credentials: Dict[str, str], nrThreads: i
|
|
|
99
107
|
session = boto3.Session(
|
|
100
108
|
aws_access_key_id=credentials["accessKey"],
|
|
101
109
|
aws_secret_access_key=credentials["secretKey"],
|
|
102
|
-
aws_session_token=credentials["sessionToken"]
|
|
110
|
+
aws_session_token=credentials["sessionToken"],
|
|
111
|
+
)
|
|
103
112
|
api_endpoint = client.tokenfile.endpoint
|
|
104
|
-
if api_endpoint ==
|
|
105
|
-
minio_endpoint =
|
|
113
|
+
if api_endpoint == "http://localhost:3000":
|
|
114
|
+
minio_endpoint = "http://localhost:9000"
|
|
106
115
|
else:
|
|
107
116
|
minio_endpoint = api_endpoint.replace("api", "minio")
|
|
108
117
|
s3 = session.resource("s3", endpoint_url=minio_endpoint)
|
|
@@ -114,7 +123,9 @@ def uploadFiles(files: Dict[str, str], credentials: Dict[str, str], nrThreads: i
|
|
|
114
123
|
transferCallback = TransferCallback()
|
|
115
124
|
|
|
116
125
|
for i in range(nrThreads):
|
|
117
|
-
thread = threading.Thread(
|
|
126
|
+
thread = threading.Thread(
|
|
127
|
+
target=uploadFile, args=(_queue, s3, transferCallback)
|
|
128
|
+
)
|
|
118
129
|
thread.start()
|
|
119
130
|
threads.append(thread)
|
|
120
131
|
for thread in threads:
|
|
@@ -125,16 +136,20 @@ def uploadFile(_queue: queue.Queue, s3: BaseClient, transferCallback: TransferCa
|
|
|
125
136
|
while True:
|
|
126
137
|
try:
|
|
127
138
|
filename, _file = _queue.get(timeout=3)
|
|
128
|
-
queueUUID = _file[
|
|
129
|
-
filepath = _file[
|
|
130
|
-
bucket = _file[
|
|
131
|
-
target_location = _file[
|
|
132
|
-
config = TransferConfig(
|
|
139
|
+
queueUUID = _file["queueUUID"]
|
|
140
|
+
filepath = _file["filepath"]
|
|
141
|
+
bucket = _file["bucket"]
|
|
142
|
+
target_location = _file["location"]
|
|
143
|
+
config = TransferConfig(
|
|
144
|
+
multipart_chunksize=10 * 1024 * 1024, max_concurrency=5
|
|
145
|
+
)
|
|
133
146
|
with open(filepath, "rb") as f:
|
|
134
147
|
size = os.path.getsize(filepath)
|
|
135
148
|
transferCallback.add_file(filename, size)
|
|
136
149
|
callback_function = create_transfer_callback(transferCallback, filename)
|
|
137
|
-
s3.Bucket(bucket).upload_file(
|
|
150
|
+
s3.Bucket(bucket).upload_file(
|
|
151
|
+
filepath, target_location, Config=config, Callback=callback_function
|
|
152
|
+
)
|
|
138
153
|
|
|
139
154
|
client = AuthenticatedClient()
|
|
140
155
|
res = client.post("/queue/confirmUpload", json={"uuid": queueUUID})
|
|
@@ -147,8 +162,6 @@ def uploadFile(_queue: queue.Queue, s3: BaseClient, transferCallback: TransferCa
|
|
|
147
162
|
_queue.task_done()
|
|
148
163
|
|
|
149
164
|
|
|
150
|
-
|
|
151
|
-
|
|
152
165
|
if __name__ == "__main__":
|
|
153
166
|
res = expand_and_match(
|
|
154
167
|
"~/Downloads/dodo_mission_2024_02_08-20240408T074313Z-003/**.bag"
|
kleinkram/main.py
CHANGED
|
@@ -195,7 +195,7 @@ def upload(
|
|
|
195
195
|
raise Exception(
|
|
196
196
|
"Could not upload File '" + file + "'. Is the filename unique? "
|
|
197
197
|
)
|
|
198
|
-
confirmed_files[_file][
|
|
198
|
+
confirmed_files[_file]["filepath"] = filepaths[_file]
|
|
199
199
|
if len(confirmed_files.keys()) > 0:
|
|
200
200
|
uploadFiles(confirmed_files, credential, 4)
|
|
201
201
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: kleinkram
|
|
3
|
-
Version: 0.13.2.
|
|
3
|
+
Version: 0.13.2.dev20240830095727
|
|
4
4
|
Summary: A CLI for the ETH project kleinkram
|
|
5
5
|
Project-URL: Homepage, https://github.com/leggedrobotics/kleinkram
|
|
6
6
|
Project-URL: Issues, https://github.com/leggedrobotics/kleinkram/issues
|
{kleinkram-0.13.2.dev20240830095132.dist-info → kleinkram-0.13.2.dev20240830095727.dist-info}/RECORD
RENAMED
|
@@ -2,8 +2,8 @@ kleinkram/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
2
2
|
kleinkram/api_client.py,sha256=1GPsM-XFbPYEKP7RfWmzMTwxRqnVh4wtHVuW25KT8kA,2264
|
|
3
3
|
kleinkram/consts.py,sha256=pm_6OuQcO-tYcRhwauTtyRRsuYY0y0yb6EGuIl49LnI,50
|
|
4
4
|
kleinkram/error_handling.py,sha256=Nm3tUtc4blQylJLNChSLgkDLFDHg3Xza0CghRrd_SYE,4015
|
|
5
|
-
kleinkram/helper.py,sha256=
|
|
6
|
-
kleinkram/main.py,sha256=
|
|
5
|
+
kleinkram/helper.py,sha256=PNx6h7eTFZ10Ul7BqK2PTMXlKjHMKkQtANsceNZmAe8,5579
|
|
6
|
+
kleinkram/main.py,sha256=ofSs0hFmi05A5gwa5t_ioVS6-aI0h27J8I1ENIxkZKk,8118
|
|
7
7
|
kleinkram/auth/auth.py,sha256=bROptCsE0r5D416_7l1lfw52IX_mSVEnjaKiU2_b1Ms,4980
|
|
8
8
|
kleinkram/endpoint/endpoint.py,sha256=KAYQgK8J6Et8V_ho2wBUIAdg25Mps6l_glCfC1vvC2g,1372
|
|
9
9
|
kleinkram/file/file.py,sha256=HsKzg8xn-AHJJIF11H6c0Gy61cRX3MyTMYdcyypUxWo,3195
|
|
@@ -13,8 +13,8 @@ kleinkram/queue/queue.py,sha256=MaLBjAu8asi9BkPvbbT-5AobCcpy3ex5rxM1kHpRINA,181
|
|
|
13
13
|
kleinkram/tag/tag.py,sha256=TZHh1GIV4LhwhqEGKdTJkM5mCIoLXAopBgWdLX1AEz8,1819
|
|
14
14
|
kleinkram/topic/topic.py,sha256=qit-DECI19QocXEkkkBC0FAlzpZnotAtX8mylA9zqAA,1630
|
|
15
15
|
kleinkram/user/user.py,sha256=i_QfsctjhImvKKjuDPfOIyDr322SXgV-KxJo-a7qNZw,1368
|
|
16
|
-
kleinkram-0.13.2.
|
|
17
|
-
kleinkram-0.13.2.
|
|
18
|
-
kleinkram-0.13.2.
|
|
19
|
-
kleinkram-0.13.2.
|
|
20
|
-
kleinkram-0.13.2.
|
|
16
|
+
kleinkram-0.13.2.dev20240830095727.dist-info/METADATA,sha256=WamGxFgx3QZgcnxoHaqDOslHBqNfuXLsV7qtrfuD5pA,774
|
|
17
|
+
kleinkram-0.13.2.dev20240830095727.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
18
|
+
kleinkram-0.13.2.dev20240830095727.dist-info/entry_points.txt,sha256=RHXtRzcreVHImatgjhQwZQ6GdJThElYjHEWcR1BPXUI,45
|
|
19
|
+
kleinkram-0.13.2.dev20240830095727.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
|
|
20
|
+
kleinkram-0.13.2.dev20240830095727.dist-info/RECORD,,
|
{kleinkram-0.13.2.dev20240830095132.dist-info → kleinkram-0.13.2.dev20240830095727.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|