kleinkram 0.21.8.dev20240920104547__tar.gz → 0.21.10__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.
Potentially problematic release.
This version of kleinkram might be problematic. Click here for more details.
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/PKG-INFO +1 -1
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/pyproject.toml +1 -1
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/endpoint/endpoint.py +3 -1
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/helper.py +44 -5
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/main.py +40 -50
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/.gitignore +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/LICENSE +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/README.md +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/deploy.sh +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/dev.sh +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/requirements.txt +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/klein.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/__init__.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/api_client.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/auth/auth.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/consts.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/error_handling.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/file/file.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/mission/mission.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/project/project.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/queue/queue.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/tag/tag.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/topic/topic.py +0 -0
- {kleinkram-0.21.8.dev20240920104547 → kleinkram-0.21.10}/src/kleinkram/user/user.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: kleinkram
|
|
3
|
-
Version: 0.21.
|
|
3
|
+
Version: 0.21.10
|
|
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
|
|
@@ -32,7 +32,9 @@ def set_endpoint(endpoint: str = typer.Argument(None, help="API endpoint to use"
|
|
|
32
32
|
print()
|
|
33
33
|
print("Endpoint set to: " + endpoint)
|
|
34
34
|
if tokenfile.endpoint not in tokenfile.tokens:
|
|
35
|
-
print(
|
|
35
|
+
print(
|
|
36
|
+
"Not authenticated on this endpoint, please execute 'klein login' to authenticate."
|
|
37
|
+
)
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
@endpoint.command("get")
|
|
@@ -2,8 +2,10 @@ import glob
|
|
|
2
2
|
import os
|
|
3
3
|
import queue
|
|
4
4
|
import threading
|
|
5
|
+
from datetime import datetime
|
|
5
6
|
from functools import partial
|
|
6
7
|
|
|
8
|
+
import typer
|
|
7
9
|
from botocore.config import Config
|
|
8
10
|
from typing_extensions import Dict
|
|
9
11
|
import boto3
|
|
@@ -117,10 +119,7 @@ def uploadFiles(files: Dict[str, str], credentials: Dict[str, str], nrThreads: i
|
|
|
117
119
|
else:
|
|
118
120
|
minio_endpoint = api_endpoint.replace("api", "minio")
|
|
119
121
|
|
|
120
|
-
config = Config(retries
|
|
121
|
-
'max_attempts': 10,
|
|
122
|
-
'mode': 'standard'
|
|
123
|
-
})
|
|
122
|
+
config = Config(retries={"max_attempts": 10, "mode": "standard"})
|
|
124
123
|
s3 = session.resource("s3", endpoint_url=minio_endpoint, config=config)
|
|
125
124
|
|
|
126
125
|
_queue = queue.Queue()
|
|
@@ -168,15 +167,55 @@ def uploadFile(_queue: queue.Queue, s3: BaseClient, transferCallback: TransferCa
|
|
|
168
167
|
print(f"Error uploading {filename}: {e}")
|
|
169
168
|
_queue.task_done()
|
|
170
169
|
|
|
170
|
+
|
|
171
171
|
def canUploadMission(client: AuthenticatedClient, project_uuid: str):
|
|
172
172
|
permissions = client.get("/user/permissions")
|
|
173
173
|
permissions.raise_for_status()
|
|
174
174
|
permissions_json = permissions.json()
|
|
175
|
-
for_project = filter(
|
|
175
|
+
for_project = filter(
|
|
176
|
+
lambda x: x["uuid"] == project_uuid, permissions_json["projects"]
|
|
177
|
+
)
|
|
176
178
|
max_for_project = max(map(lambda x: x["access"], for_project))
|
|
177
179
|
return max_for_project >= 10
|
|
178
180
|
|
|
179
181
|
|
|
182
|
+
def promptForTags(setTags: Dict[str, str], requiredTags: Dict[str, str]):
|
|
183
|
+
for required_tag in requiredTags:
|
|
184
|
+
if required_tag["name"] not in setTags:
|
|
185
|
+
while True:
|
|
186
|
+
if required_tag["datatype"] in ["LOCATION", "STRING", "LINK"]:
|
|
187
|
+
tag_value = typer.prompt(
|
|
188
|
+
"Provide value for required tag " + required_tag["name"]
|
|
189
|
+
)
|
|
190
|
+
if tag_value != "":
|
|
191
|
+
break
|
|
192
|
+
elif required_tag["datatype"] == "BOOLEAN":
|
|
193
|
+
tag_value = typer.confirm(
|
|
194
|
+
"Provide (y/N) for required tag " + required_tag["name"]
|
|
195
|
+
)
|
|
196
|
+
break
|
|
197
|
+
elif required_tag["datatype"] == "NUMBER":
|
|
198
|
+
tag_value = typer.prompt(
|
|
199
|
+
"Provide number for required tag " + required_tag["name"]
|
|
200
|
+
)
|
|
201
|
+
try:
|
|
202
|
+
tag_value = float(tag_value)
|
|
203
|
+
break
|
|
204
|
+
except ValueError:
|
|
205
|
+
typer.echo("Invalid number format. Please provide a number.")
|
|
206
|
+
elif required_tag["datatype"] == "DATE":
|
|
207
|
+
tag_value = typer.prompt(
|
|
208
|
+
"Provide date for required tag " + required_tag["name"]
|
|
209
|
+
)
|
|
210
|
+
try:
|
|
211
|
+
tag_value = datetime.strptime(tag_value, "%Y-%m-%d %H:%M:%S")
|
|
212
|
+
break
|
|
213
|
+
except ValueError:
|
|
214
|
+
print("Invalid date format. Please use 'YYYY-MM-DD HH:MM:SS'")
|
|
215
|
+
|
|
216
|
+
setTags[required_tag["uuid"]] = tag_value
|
|
217
|
+
|
|
218
|
+
|
|
180
219
|
if __name__ == "__main__":
|
|
181
220
|
res = expand_and_match(
|
|
182
221
|
"~/Downloads/dodo_mission_2024_02_08-20240408T074313Z-003/**.bag"
|
|
@@ -22,7 +22,7 @@ from kleinkram.queue.queue import queue
|
|
|
22
22
|
from kleinkram.tag.tag import tag
|
|
23
23
|
from kleinkram.topic.topic import topic
|
|
24
24
|
from kleinkram.user.user import user
|
|
25
|
-
from .helper import uploadFiles, expand_and_match, canUploadMission
|
|
25
|
+
from .helper import uploadFiles, expand_and_match, canUploadMission, promptForTags
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
class CommandPanel(str, Enum):
|
|
@@ -75,14 +75,14 @@ app = ErrorHandledTyper(
|
|
|
75
75
|
|
|
76
76
|
@app.callback()
|
|
77
77
|
def version(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
version: bool = typer.Option(
|
|
79
|
+
None,
|
|
80
|
+
"--version",
|
|
81
|
+
"-v",
|
|
82
|
+
callback=version_callback,
|
|
83
|
+
is_eager=True,
|
|
84
|
+
help="Print the version and exit",
|
|
85
|
+
)
|
|
86
86
|
):
|
|
87
87
|
pass
|
|
88
88
|
|
|
@@ -109,14 +109,17 @@ def download():
|
|
|
109
109
|
|
|
110
110
|
@app.command("upload", rich_help_panel=CommandPanel.CoreCommands)
|
|
111
111
|
def upload(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
path: Annotated[
|
|
113
|
+
str, typer.Option(prompt=True, help="Path to files to upload, Regex supported")
|
|
114
|
+
],
|
|
115
|
+
project: Annotated[str, typer.Option(prompt=True, help="Name of Project")],
|
|
116
|
+
mission: Annotated[
|
|
117
|
+
str, typer.Option(prompt=True, help="Name of Mission to create")
|
|
118
|
+
],
|
|
119
|
+
tags: Annotated[
|
|
120
|
+
Optional[List[str]],
|
|
121
|
+
typer.Option(prompt=False, help="Tags to add to the mission"),
|
|
122
|
+
] = None,
|
|
120
123
|
):
|
|
121
124
|
"""
|
|
122
125
|
Upload files matching the path to a mission in a project.
|
|
@@ -159,41 +162,18 @@ def upload(
|
|
|
159
162
|
print(f"Project not found: '{project}'")
|
|
160
163
|
return
|
|
161
164
|
|
|
162
|
-
can_upload = canUploadMission(client, project_json[
|
|
165
|
+
can_upload = canUploadMission(client, project_json["uuid"])
|
|
163
166
|
if not can_upload:
|
|
164
167
|
raise AccessDeniedException(
|
|
165
|
-
f"You do not have the required permissions to upload to project '{project}'\n",
|
|
168
|
+
f"You do not have the required permissions to upload to project '{project}'\n",
|
|
169
|
+
"Access Denied",
|
|
170
|
+
)
|
|
166
171
|
|
|
167
172
|
if not tags:
|
|
168
173
|
tags = []
|
|
169
174
|
tags_dict = {item.split(":")[0]: item.split(":")[1] for item in tags}
|
|
170
175
|
|
|
171
|
-
|
|
172
|
-
if required_tag["name"] not in tags_dict:
|
|
173
|
-
while True:
|
|
174
|
-
if required_tag["datatype"] in ["LOCATION", "STRING", "LINK"]:
|
|
175
|
-
tag_value = typer.prompt("Provide value for required tag " + required_tag["name"])
|
|
176
|
-
if tag_value != "":
|
|
177
|
-
break
|
|
178
|
-
elif required_tag["datatype"] == "BOOLEAN":
|
|
179
|
-
tag_value = typer.confirm("Provide (y/N) for required tag " + required_tag["name"])
|
|
180
|
-
break
|
|
181
|
-
elif required_tag["datatype"] == "NUMBER":
|
|
182
|
-
tag_value = typer.prompt("Provide number for required tag " + required_tag["name"])
|
|
183
|
-
try:
|
|
184
|
-
tag_value = float(tag_value)
|
|
185
|
-
break
|
|
186
|
-
except ValueError:
|
|
187
|
-
typer.echo("Invalid number format. Please provide a number.")
|
|
188
|
-
elif required_tag["datatype"] == "DATE":
|
|
189
|
-
tag_value = typer.prompt("Provide date for required tag " + required_tag["name"])
|
|
190
|
-
try:
|
|
191
|
-
tag_value = datetime.strptime(tag_value, "%Y-%m-%d %H:%M:%S")
|
|
192
|
-
break
|
|
193
|
-
except ValueError:
|
|
194
|
-
print("Invalid date format. Please use 'YYYY-MM-DD HH:MM:SS'")
|
|
195
|
-
|
|
196
|
-
tags_dict[required_tag["uuid"]] = tag_value
|
|
176
|
+
promptForTags(tags_dict, project_json["requiredTags"])
|
|
197
177
|
|
|
198
178
|
get_mission_url = "/mission/byName"
|
|
199
179
|
mission_response = client.get(get_mission_url, params={"name": mission})
|
|
@@ -210,12 +190,19 @@ def upload(
|
|
|
210
190
|
create_mission_url = "/mission/create"
|
|
211
191
|
new_mission = client.post(
|
|
212
192
|
create_mission_url,
|
|
213
|
-
json={
|
|
193
|
+
json={
|
|
194
|
+
"name": mission,
|
|
195
|
+
"projectUUID": project_json["uuid"],
|
|
196
|
+
"tags": tags_dict,
|
|
197
|
+
},
|
|
214
198
|
)
|
|
215
199
|
if new_mission.status_code >= 400:
|
|
216
200
|
raise ValueError(
|
|
217
|
-
"Failed to create mission. Status Code: "
|
|
218
|
-
|
|
201
|
+
"Failed to create mission. Status Code: "
|
|
202
|
+
+ str(new_mission.status_code)
|
|
203
|
+
+ "\n"
|
|
204
|
+
+ new_mission.json()["message"]
|
|
205
|
+
)
|
|
219
206
|
new_mission_data = new_mission.json()
|
|
220
207
|
|
|
221
208
|
get_temporary_credentials = "/file/temporaryAccess"
|
|
@@ -225,8 +212,11 @@ def upload(
|
|
|
225
212
|
)
|
|
226
213
|
if response_2.status_code >= 400:
|
|
227
214
|
raise ValueError(
|
|
228
|
-
"Failed to get temporary credentials. Status Code: "
|
|
229
|
-
|
|
215
|
+
"Failed to get temporary credentials. Status Code: "
|
|
216
|
+
+ str(response_2.status_code)
|
|
217
|
+
+ "\n"
|
|
218
|
+
+ response_2.json()["message"]
|
|
219
|
+
)
|
|
230
220
|
temp_credentials = response_2.json()
|
|
231
221
|
credential = temp_credentials["credentials"]
|
|
232
222
|
confirmed_files = temp_credentials["files"]
|
|
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
|
|
File without changes
|
|
File without changes
|