kleinkram 0.34.2.dev20241029064830__py3-none-any.whl → 0.34.2.dev20241029082227__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/file/file.py CHANGED
@@ -86,8 +86,8 @@ def list_files(
86
86
  Can list files of a project, mission, or with specific topics (Logical AND).
87
87
  Examples:\n
88
88
  - 'klein filelist'\n
89
- - 'klein file list --project "Project 1"'\n
90
- - 'klein file list --mission "Mission 1"'\n
89
+ - 'klein file list --project "Project_1"'\n
90
+ - 'klein file list --mission "Mission_1"'\n
91
91
  - 'klein file list --topics "/elevation_mapping/semantic_map,/elevation_mapping/elevation_map_raw"'\n
92
92
  - 'klein file list --topics "/elevation_mapping/semantic_map,/elevation_mapping/elevation_map_raw" --mission "Mission A"'
93
93
  """
kleinkram/main.py CHANGED
@@ -26,11 +26,11 @@ from kleinkram.tag.tag import tag
26
26
  from kleinkram.topic.topic import topic
27
27
  from kleinkram.user.user import user
28
28
  from .helper import (
29
- uploadFiles,
30
- expand_and_match,
29
+ is_valid_UUIDv4,
31
30
  canUploadMission,
32
31
  promptForTags,
33
- is_valid_UUIDv4,
32
+ expand_and_match,
33
+ uploadFiles,
34
34
  )
35
35
 
36
36
 
@@ -148,6 +148,22 @@ def upload(
148
148
  bool,
149
149
  typer.Option(help="Allows adding files to an existing mission"),
150
150
  ] = False,
151
+ overwrite: Annotated[
152
+ bool,
153
+ typer.Option(
154
+ help="Overwrite files with the same name.\n\n*WARNING:* This cannot be undone! This command will NOT delete"
155
+ "converted files, i.g. if the file is of type 'some-name.bag' the converted 'some-name.mcap' file will not "
156
+ "be deleted."
157
+ ),
158
+ ] = False,
159
+ overwrite_all: Annotated[
160
+ bool,
161
+ typer.Option(
162
+ help="Overwrite files with the same name.\n\n*WARNING:* This cannot be undone! This command WILL "
163
+ "automatically delete converted files, i.g. if the file is of type 'some-name.bag' the converted "
164
+ "'some-name.mcap' file will be deleted."
165
+ ),
166
+ ] = False,
151
167
  ):
152
168
  """
153
169
  Upload files matching the path to a mission in a project.
@@ -155,7 +171,7 @@ def upload(
155
171
  The mission name must be unique within the project and not yet created.\n
156
172
  Multiple paths can be given by using the option multiple times.\n
157
173
  Examples:\n
158
- - 'klein upload --path "~/data/**/*.bag" --project "Project 1" --mission "Mission 1" --tags "0700946d-1d6a-4520-b263-0e177f49c35b:LEE-H" --tags "1565118d-593c-4517-8c2d-9658452d9319:Dodo"'\n
174
+ - 'klein upload --path "~/data/**/*.bag" --project "Project_1" --mission "Mission_1" --tags "0700946d-1d6a-4520-b263-0e177f49c35b:LEE-H" --tags "1565118d-593c-4517-8c2d-9658452d9319:Dodo"'\n
159
175
 
160
176
  """
161
177
 
@@ -197,10 +213,11 @@ def upload(
197
213
  },
198
214
  )
199
215
  if project_response.status_code >= 400:
216
+ msg = str(project_response.json()["message"])
200
217
  raise ValueError(
201
218
  f"Failed to create project. Status Code: "
202
219
  f"{str(project_response.status_code)}\n"
203
- f"{project_response.json()['message'][0]}"
220
+ f"{msg}"
204
221
  )
205
222
  print("Project created successfully.")
206
223
 
@@ -321,6 +338,85 @@ def upload(
321
338
  "multiple files with the same name in different directories or use the '--fix-filenames' option."
322
339
  )
323
340
 
341
+ # check if files already exist
342
+ get_files_url = "/file/ofMission"
343
+ response = client.get(
344
+ get_files_url,
345
+ params={"uuid": mission_json["uuid"]},
346
+ )
347
+ if response.status_code >= 400:
348
+ raise ValueError(
349
+ "Failed to check for existing files. Status Code: "
350
+ + str(response.status_code)
351
+ + "\n"
352
+ + response.json()["message"]
353
+ )
354
+
355
+ existing_files = response.json()[0]
356
+ conflicting_files = [
357
+ file for file in existing_files if file["filename"] in filenames
358
+ ]
359
+
360
+ if conflicting_files and len(conflicting_files):
361
+ print("The following files already exist in the mission:")
362
+ for file in conflicting_files:
363
+ typer.secho(f" - {file['filename']}", fg=typer.colors.RED, nl=False)
364
+ if overwrite or overwrite_all:
365
+ # delete existing files
366
+ delete_files_url = f"/file/{file['uuid']}"
367
+ response = client.delete(delete_files_url)
368
+ if response.status_code >= 400:
369
+ raise ValueError(
370
+ "Failed to delete existing files. Status Code: "
371
+ + str(response.status_code)
372
+ + "\n"
373
+ + response.json()["message"]
374
+ )
375
+ print(" » deleted")
376
+
377
+ # check if converted files exist
378
+ mcap_file = file["filename"].replace(".bag", ".mcap")
379
+
380
+ if mcap_file == file["filename"]:
381
+ continue
382
+
383
+ mcap_uuid = next(
384
+ (
385
+ file["uuid"]
386
+ for file in existing_files
387
+ if file["filename"] == mcap_file
388
+ ),
389
+ None,
390
+ )
391
+
392
+ if mcap_uuid and overwrite_all:
393
+ typer.secho(f" {mcap_file}", fg=typer.colors.RED, nl=False)
394
+ delete_files_url = f"/file/{mcap_uuid}"
395
+ response = client.delete(delete_files_url)
396
+ if response.status_code >= 400:
397
+ raise ValueError(
398
+ "Failed to delete existing files. Status Code: "
399
+ + str(response.status_code)
400
+ + "\n"
401
+ + response.json()["message"]
402
+ )
403
+ print(" » deleted")
404
+ elif mcap_uuid and not overwrite_all:
405
+ print(
406
+ f" {mcap_file} » skipped (consider using '--overwrite-all' to delete this file)"
407
+ )
408
+ else:
409
+ print(" » not found")
410
+
411
+ else:
412
+ print("")
413
+
414
+ if not overwrite and not overwrite_all:
415
+ print(
416
+ "\nYou may use the '--overwrite' or '--overwrite-all' flag to overwrite existing files."
417
+ )
418
+ print("")
419
+
324
420
  get_temporary_credentials = "/file/temporaryAccess"
325
421
  response = client.post(
326
422
  get_temporary_credentials,
@@ -328,7 +424,7 @@ def upload(
328
424
  )
329
425
  if response.status_code >= 400:
330
426
  raise ValueError(
331
- "Failed to get temporary credentials. Status Code: "
427
+ "Failed to upload data. Status Code: "
332
428
  + str(response.status_code)
333
429
  + "\n"
334
430
  + response.json()["message"][0]
@@ -49,8 +49,8 @@ def addTag(
49
49
  @missionCommands.command("list")
50
50
  def list_missions(
51
51
  project: Optional[str] = typer.Option(None, help="Name of Project"),
52
- verbose: Optional[bool] = typer.Option(
53
- False, help="Outputs a table with more information"
52
+ table: Optional[bool] = typer.Option(
53
+ True, help="Outputs a table with more information"
54
54
  ),
55
55
  ):
56
56
  """
@@ -93,20 +93,28 @@ def list_missions(
93
93
  return
94
94
 
95
95
  print("missions by Project:")
96
- if not verbose:
96
+ if not table:
97
97
  for project_uuid, missions in missions_by_project_uuid.items():
98
98
  print(f"* {missions_by_project_uuid[project_uuid][0]['project']['name']}")
99
99
  for mission in missions:
100
100
  print(f" - {mission['name']}")
101
101
 
102
102
  else:
103
- table = Table("UUID", "name", "project", "creator", "createdAt")
103
+ table = Table(
104
+ "project",
105
+ "name",
106
+ "UUID",
107
+ "creator",
108
+ "createdAt",
109
+ title="Missions",
110
+ expand=True,
111
+ )
104
112
  for project_uuid, missions in missions_by_project_uuid.items():
105
113
  for mission in missions:
106
114
  table.add_row(
107
- mission["uuid"],
108
- mission["name"],
109
115
  mission["project"]["name"],
116
+ mission["name"],
117
+ mission["uuid"],
110
118
  mission["creator"]["name"],
111
119
  mission["createdAt"],
112
120
  )
@@ -261,7 +269,7 @@ def upload(
261
269
  Multiple paths can be given by using the option multiple times.\n
262
270
  \n
263
271
  Examples:\n
264
- - 'klein upload --path "~/data/**/*.bag" --project "Project 1" --mission "2518cfc2-07f2-41a5-b74c-fdedb1b97f88" '\n
272
+ - 'klein upload --path "~/data/**/*.bag" --project "Project_1" --mission "2518cfc2-07f2-41a5-b74c-fdedb1b97f88" '\n
265
273
 
266
274
  """
267
275
  files = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: kleinkram
3
- Version: 0.34.2.dev20241029064830
3
+ Version: 0.34.2.dev20241029082227
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
@@ -3,18 +3,18 @@ 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=vvNtXSOnXs4b-aYEUIA0GVQWXLRW5I5FtNE1PZPHEPc,4704
5
5
  kleinkram/helper.py,sha256=ELvs-p7zpJUP_rtTIVpcUCTz0D4WegoUZQ11UqUrUkg,9288
6
- kleinkram/main.py,sha256=Ew4KViP1GkqUZYRtFbZ3HRxlU1TMGnfWJq8dBr0Y8_A,13615
6
+ kleinkram/main.py,sha256=WCdZk8PLmSi5dTRPgrKAsp0EljNXFZVD1Ce8fdKSZNs,17348
7
7
  kleinkram/auth/auth.py,sha256=w3-TsxWxURzLQ3_p43zgV4Rlh4dVL_WqI6HG2aes-b4,4991
8
8
  kleinkram/endpoint/endpoint.py,sha256=WmHUH10_OSZUMrovh2yBeth9dBcn0yE7PxnnD4yPW-Y,1582
9
- kleinkram/file/file.py,sha256=gLCZDHHgQWq25OmeG-lwkIh4aRZaLK12xxLkbhZ_m-g,5390
10
- kleinkram/mission/mission.py,sha256=SkTjauagLamwZaQTWTeGmXAJ9YgUrBdh_3EbjYNZfZM,10082
9
+ kleinkram/file/file.py,sha256=1IRXTxGGH5tIvvmMoee5jvmN4QGyIJSJ2xtHraHGFHE,5390
10
+ kleinkram/mission/mission.py,sha256=1nBF8TX76JqY-Gi50cRWe7WZhAYsrHP5gXtLOLH_XLs,10203
11
11
  kleinkram/project/project.py,sha256=4BOT3iOZZnMrZuALzBxQ5r-8dC8eZkel1OjxUFzK0w4,4336
12
12
  kleinkram/queue/queue.py,sha256=MaLBjAu8asi9BkPvbbT-5AobCcpy3ex5rxM1kHpRINA,181
13
13
  kleinkram/tag/tag.py,sha256=JSHbDPVfsvP34MuQhw__DPQk-Bah5G9BgwYsj_K_JGc,1805
14
14
  kleinkram/topic/topic.py,sha256=IaXhrIHcJ3FSIr0WC-N7u9fkz-lAvSBgQklTX67t0Yc,1641
15
15
  kleinkram/user/user.py,sha256=SzUM-CTTmC3TYCNt4Crizc7n3Rpf2ObJeNWEeEmMfpo,1893
16
- kleinkram-0.34.2.dev20241029064830.dist-info/METADATA,sha256=bp5-b98UU3UKQrUcY2EreuybRL2yJ_zxAnKMzFztc9o,845
17
- kleinkram-0.34.2.dev20241029064830.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
18
- kleinkram-0.34.2.dev20241029064830.dist-info/entry_points.txt,sha256=RHXtRzcreVHImatgjhQwZQ6GdJThElYjHEWcR1BPXUI,45
19
- kleinkram-0.34.2.dev20241029064830.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
20
- kleinkram-0.34.2.dev20241029064830.dist-info/RECORD,,
16
+ kleinkram-0.34.2.dev20241029082227.dist-info/METADATA,sha256=v3CpNCO_bfMbldYfdxlw9RBcHBN7sqeaahDxuwyUx7Y,845
17
+ kleinkram-0.34.2.dev20241029082227.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
18
+ kleinkram-0.34.2.dev20241029082227.dist-info/entry_points.txt,sha256=RHXtRzcreVHImatgjhQwZQ6GdJThElYjHEWcR1BPXUI,45
19
+ kleinkram-0.34.2.dev20241029082227.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
20
+ kleinkram-0.34.2.dev20241029082227.dist-info/RECORD,,