malevich-coretools 0.2.9__py3-none-any.whl → 0.2.11__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 malevich-coretools might be problematic. Click here for more details.

@@ -211,6 +211,11 @@ class ResultIds(BaseModel):
211
211
  ids: List[Alias.Id]
212
212
 
213
213
 
214
+ class FilesDirs(BaseModel):
215
+ files: List[str]
216
+ directories: List[str]
217
+
218
+
214
219
  class ResultDoc(BaseModel):
215
220
  data: Alias.Json
216
221
  name: str
@@ -424,5 +429,5 @@ class OperationOrNone(BaseModel):
424
429
 
425
430
 
426
431
  class AdminStopOperation(BaseModel):
427
- operationId: Optional[Alias.Id]
432
+ operationId: Optional[Alias.Id] = None
428
433
  withLogs: bool
@@ -17,8 +17,8 @@ def admin_get_run_info(
17
17
  auth: Optional[AUTH] = None,
18
18
  conn_url: Optional[str] = None,
19
19
  ) -> Alias.Info:
20
- """return run info by operation \"id\""""
21
- data = OperationOrNone(id)
20
+ """return run info by operation `id`"""
21
+ data = OperationOrNone(operationId=id)
22
22
  return f.get_admin_runs_info(data, auth=auth, conn_url=conn_url)
23
23
 
24
24
 
@@ -39,7 +39,7 @@ def admin_delete_run(
39
39
  auth: Optional[AUTH] = None,
40
40
  conn_url: Optional[str] = None,
41
41
  ) -> Alias.Json:
42
- """delete run by operation \"id\""""
42
+ """delete run by operation `id`"""
43
43
  data = AdminStopOperation(operationId=id, withLogs=withLogs)
44
44
  return f.delete_admin_runs(data, auth=auth, conn_url=conn_url)
45
45
 
@@ -51,5 +51,5 @@ def admin_delete_runs(
51
51
  conn_url: Optional[str] = None,
52
52
  ) -> Alias.Json:
53
53
  """delete all runs"""
54
- data = AdminStopOperation(operationId=None, withLogs=withLogs)
54
+ data = AdminStopOperation(withLogs=withLogs)
55
55
  return f.delete_admin_runs(data, auth=auth, conn_url=conn_url)
@@ -121,6 +121,29 @@ def delete_collections_id_s3(key: str, wait: bool, *args, **kwargs) -> Alias.Inf
121
121
  def delete_collections_id_del(id: str, data: DocsCollectionChange, wait: bool, *args, **kwargs) -> Alias.Info:
122
122
  return send_to_core_modify(COLLECTIONS_ID_DEL(id, wait), data, *args, **kwargs, is_post=False)
123
123
 
124
+ # CollectionObjectsController
125
+
126
+
127
+ def get_collection_objects(path: Optional[str], recursive: Optional[str], *args, **kwargs) -> FilesDirs:
128
+ return model_from_json(send_to_core_get(COLLECTION_OBJECTS_ALL_GET(path, recursive), *args, **kwargs), FilesDirs)
129
+
130
+
131
+ def get_collection_object(path: str, *args, **kwargs) -> bytes:
132
+ return send_to_core_get(COLLECTION_OBJECTS_PATH(path, None), is_text=None, *args, **kwargs)
133
+
134
+
135
+ def post_collections_object(path: str, data: bytes, wait: bool, *args, **kwargs) -> Alias.Info:
136
+ return send_to_core_modify_raw(COLLECTION_OBJECTS_PATH(path, wait), data, *args, **kwargs)
137
+
138
+
139
+ def delete_collection_objects(wait: bool, *args, **kwargs) -> Alias.Info:
140
+ return send_to_core_modify(COLLECTION_OBJECTS_ALL(wait), *args, **kwargs, is_post=False)
141
+
142
+
143
+ def delete_collection_object(path: str, wait: bool, *args, **kwargs) -> Alias.Info:
144
+ return send_to_core_modify(COLLECTION_OBJECTS_PATH(path, wait), *args, **kwargs, is_post=False)
145
+
146
+
124
147
  # SchemeController
125
148
 
126
149
 
@@ -599,7 +622,7 @@ def __check_response(path: str, response: Response, show_func: Optional[Callable
599
622
  response.raise_for_status()
600
623
 
601
624
 
602
- def send_to_core_get(path: str, with_auth=True, show_func: Optional[Callable]=None, is_text=False, auth: Optional[AUTH]=None, conn_url: Optional[str]=None) -> Optional[str]:
625
+ def send_to_core_get(path: str, with_auth=True, show_func: Optional[Callable]=None, is_text=False, auth: Optional[AUTH]=None, conn_url: Optional[str]=None) -> Optional[Union[str, bytes]]:
603
626
  host = Config.HOST_PORT if conn_url is None else conn_url
604
627
  assert host is not None, "host port not set"
605
628
  if auth is None or not with_auth:
@@ -608,10 +631,12 @@ def send_to_core_get(path: str, with_auth=True, show_func: Optional[Callable]=No
608
631
  __check_response(f"{host}{path}", response, show_func)
609
632
  if response.status_code == HTTPStatus.NO_CONTENT:
610
633
  return None
611
- if is_text:
634
+ if is_text is True:
612
635
  return response.text
613
- else:
636
+ elif is_text is False:
614
637
  return response.json()
638
+ else:
639
+ return response.content
615
640
 
616
641
 
617
642
  def send_to_core_modify(path: str, operation: Optional[Any] = None, with_auth: bool=True, with_show: Optional[bool]=None, show_func: Optional[Callable]=None, is_post: bool=True, auth: Optional[AUTH]=None, conn_url: Optional[str]=None) -> str: # noqa: ANN401
@@ -640,6 +665,30 @@ def send_to_core_modify(path: str, operation: Optional[Any] = None, with_auth: b
640
665
  return result
641
666
 
642
667
 
668
+ def send_to_core_modify_raw(path: str, data: bytes, with_auth: bool=True, with_show: Optional[bool]=None, show_func: Optional[Callable]=None, is_post: bool=True, auth: Optional[AUTH]=None, conn_url: Optional[str]=None) -> str: # noqa: ANN401
669
+ """modify: post by default, else - delete"""
670
+ host = Config.HOST_PORT if conn_url is None else conn_url
671
+ assert host is not None, "host port not set"
672
+ if auth is None:
673
+ auth = (Config.CORE_USERNAME, Config.CORE_PASSWORD)
674
+ if is_post:
675
+ response = requests.post(f"{host}{path}", data=data, headers=HEADERS_RAW, auth=auth if with_auth else None)
676
+ else: # delete
677
+ response = requests.delete(f"{host}{path}", data=data, headers=HEADERS_RAW, auth=auth if with_auth else None)
678
+ __check_response(f"{host}{path}", response, show_func=show_func)
679
+ if response.status_code == HTTPStatus.NO_CONTENT:
680
+ return ""
681
+ result = response.text
682
+ if with_show is None:
683
+ with_show = Config.VERBOSE
684
+ if with_show:
685
+ if show_func is None:
686
+ Config.logger.info(result)
687
+ else:
688
+ show_func(result)
689
+ return result
690
+
691
+
643
692
  async def send_to_core_post_async(path: str, operation: Optional[str] = None, with_auth=True, with_show=True, show_func: Optional[Callable]=None, auth: Optional[AUTH]=None, conn_url: Optional[str]=None) -> str:
644
693
  host = Config.HOST_PORT if conn_url is None else conn_url
645
694
  assert host is not None, "host port not set"
@@ -7,6 +7,7 @@ from malevich_coretools.secondary.helpers import bool_to_str
7
7
  # const
8
8
  API_VERSION = "api/v1"
9
9
  HEADERS = {'Content-type': 'application/json', 'Accept': 'application/json', 'User-Agent': 'malevich user agent'}
10
+ HEADERS_RAW = {'Content-type': 'text/plain; base64', 'Accept': 'application/json', 'User-Agent': 'malevich user agent'}
10
11
  SLEEP_TIME = 0.1
11
12
  LONG_SLEEP_TIME = 1 # second
12
13
  WAIT_RESULT_TIMEOUT = 60 * 60 # hour
@@ -52,6 +53,12 @@ COLLECTIONS_FIX_SCHEME = lambda id, wait: with_wait(f"{COLLECTIONS_MAIN}/{id}/fi
52
53
  COLLECTIONS_UNFIX_SCHEME = lambda id, wait: with_wait(f"{COLLECTIONS_MAIN}/{id}/unfixScheme", wait)
53
54
  COLLECTIONS_METADATA = lambda id, wait: with_wait(f"{COLLECTIONS_MAIN}/{id}/metadata", wait)
54
55
 
56
+ ## CollectionObjectsController
57
+ COLLECTION_OBJECTS_MAIN = f"{API_VERSION}/collectionObjects"
58
+ COLLECTION_OBJECTS_ALL_GET = lambda path, recursive: with_key_values(f"{COLLECTION_OBJECTS_MAIN}/all", {"path": path, "recursive": recursive})
59
+ COLLECTION_OBJECTS_ALL = lambda wait: with_wait(f"{COLLECTION_OBJECTS_MAIN}/all", wait)
60
+ COLLECTION_OBJECTS_PATH = lambda path, wait: with_key_values(f"{COLLECTION_OBJECTS_MAIN}/", {"path": path, "wait": None if wait is None else bool_to_str(wait)})
61
+
55
62
  ## SchemeController
56
63
  SCHEMES_MAIN = f"{API_VERSION}/schemes"
57
64
  SCHEMES = lambda wait: with_wait(f"{SCHEMES_MAIN}/", wait)
@@ -46,7 +46,7 @@ def __show_logs_result(res: LogsResult): # noqa: ANN202
46
46
  print(res.data)
47
47
  for run_id, logs in res.logs.items():
48
48
  print(f"------- {run_id}:")
49
- userLogs = res.userLogs[run_id]
49
+ userLogs = res.userLogs.get(run_id, "")
50
50
  if len(userLogs) > 0:
51
51
  print(userLogs)
52
52
  print("-------")
@@ -447,6 +447,60 @@ def delete_from_collection(
447
447
  )
448
448
 
449
449
 
450
+ # CollectionObjects
451
+
452
+
453
+ def get_collection_objects(
454
+ path: Optional[str] = None,
455
+ recursive: Optional[str] = None,
456
+ *, auth: Optional[AUTH] = None, conn_url: Optional[str] = None
457
+ ) -> FilesDirs:
458
+ """return struct with list of paths: directories and files: walk if `recursive` else ls"""
459
+ return f.get_collection_objects(path, recursive, auth=auth, conn_url=conn_url)
460
+
461
+
462
+ def get_collection_object(
463
+ path: str,
464
+ *,
465
+ auth: Optional[AUTH] = None,
466
+ conn_url: Optional[str] = None,
467
+ ) -> bytes:
468
+ """return collection object bytes by `path`"""
469
+ return f.get_collection_object(
470
+ path, auth=auth, conn_url=conn_url
471
+ )
472
+
473
+
474
+ def update_collection_object(
475
+ path: str,
476
+ data: bytes,
477
+ wait: bool = True,
478
+ *,
479
+ auth: Optional[AUTH] = None,
480
+ conn_url: Optional[str] = None,
481
+ ) -> Alias.Info:
482
+ """update collection object with `path` by `data` """
483
+ return f.post_collections_object(path, data, wait=wait, auth=auth, conn_url=conn_url)
484
+
485
+
486
+ def delete_collection_objects(
487
+ wait: bool = True, *, auth: Optional[AUTH] = None, conn_url: Optional[str] = None
488
+ ) -> Alias.Info:
489
+ """delete all collection objects"""
490
+ return f.delete_collection_objects(wait=wait, auth=auth, conn_url=conn_url)
491
+
492
+
493
+ def delete_collection_object(
494
+ path: str,
495
+ wait: bool = True,
496
+ *,
497
+ auth: Optional[AUTH] = None,
498
+ conn_url: Optional[str] = None,
499
+ ) -> Alias.Info:
500
+ """delete collection object with `path` (or directory with them) """
501
+ return f.delete_collection_object(path, wait=wait, auth=auth, conn_url=conn_url)
502
+
503
+
450
504
  # Scheme
451
505
 
452
506
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: malevich-coretools
3
- Version: 0.2.9
3
+ Version: 0.2.11
4
4
  Author: Andrew Pogrebnoj
5
5
  Author-email: andrew@onjulius.co
6
6
  License-File: LICENSE
@@ -0,0 +1,20 @@
1
+ malevich_coretools/__init__.py,sha256=88IRvwNti4YOMJc6RaVRutwurJzP23g30D-rgo04Fgc,82
2
+ malevich_coretools/utils.py,sha256=TGUMBqUy2TghICobolUWrE4JiFPDRhSH3np9YTBsAt4,62026
3
+ malevich_coretools/abstract/__init__.py,sha256=ZWtP4gFLpNVFXzlMKXEK4iMnUqqMg07pL8yKGSJd6QI,38
4
+ malevich_coretools/abstract/abstract.py,sha256=uV1FiH4X8F-36CiYsHNloFFA_u29iuwa_6U_G8CCCck,8950
5
+ malevich_coretools/admin/__init__.py,sha256=zdIcHs3T_NZ8HYWts-O7OpBEWHIu779QDZMGF5HRCLg,35
6
+ malevich_coretools/admin/utils.py,sha256=NE0Mw_Tytsi0PLD62_sI8tUVZNQaRrtUaa4oFwfUt84,1497
7
+ malevich_coretools/funcs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ malevich_coretools/funcs/funcs.py,sha256=coGZ-OsOnKoxHeP-AjK-Ms9paWYvNlwP1XU_Fih7TI4,30458
9
+ malevich_coretools/funcs/helpers.py,sha256=Y8v6uyawYl2_G0XmhmiVLqGIUzvxnkpKF0ODA9vrB3Y,1276
10
+ malevich_coretools/secondary/__init__.py,sha256=048HqvG36_1WdDVZK_RuECmaf14Iq2fviUysG1inlaE,78
11
+ malevich_coretools/secondary/config.py,sha256=b7RysQTkPKib8FEhfm3uU7TPvz8vgWLlqakvZN5NFs4,391
12
+ malevich_coretools/secondary/const.py,sha256=VFt8nZWnts9rMCJ8R65wE6l0VAZHprq8IR7zOZcyDxQ,8631
13
+ malevich_coretools/secondary/helpers.py,sha256=lcWN1ctfVQa5KFqh5mXdp_16hA3TXhJGe4mtNdQHnUA,3072
14
+ malevich_coretools/tools/__init__.py,sha256=jDxlCa5Dr6Y43qlI7JwsRAlBkKmFeTHTEnjNUvu-0iw,46
15
+ malevich_coretools/tools/vast.py,sha256=u1cnfylSgq3nYfonXbTy1zwor3OPkhD3vRf2OnqlMZY,12504
16
+ malevich_coretools-0.2.11.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ malevich_coretools-0.2.11.dist-info/METADATA,sha256=2A3WfOJ8bHcdiuJxIEEFyWEcsphqn8hPZIjdrxOLDf8,237
18
+ malevich_coretools-0.2.11.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
+ malevich_coretools-0.2.11.dist-info/top_level.txt,sha256=wDX3s1Tso0otBPNrFRfXqyNpm48W4Bp5v6JfbITO2Z8,19
20
+ malevich_coretools-0.2.11.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- malevich_coretools/__init__.py,sha256=88IRvwNti4YOMJc6RaVRutwurJzP23g30D-rgo04Fgc,82
2
- malevich_coretools/utils.py,sha256=X_4SK2a8SOPAfWKLj1or391WtqMlEXhGtBrY2EV82tg,60471
3
- malevich_coretools/abstract/__init__.py,sha256=ZWtP4gFLpNVFXzlMKXEK4iMnUqqMg07pL8yKGSJd6QI,38
4
- malevich_coretools/abstract/abstract.py,sha256=gqqsd7sbLYnkTZsjcHHMl6RPJUpZ6QMJ29M6iD_91EQ,8865
5
- malevich_coretools/admin/__init__.py,sha256=zdIcHs3T_NZ8HYWts-O7OpBEWHIu779QDZMGF5HRCLg,35
6
- malevich_coretools/admin/utils.py,sha256=P1RmYfc_n6plBayfOhVuwVV33vMxw1yuS11NmKD4Hto,1507
7
- malevich_coretools/funcs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- malevich_coretools/funcs/funcs.py,sha256=gD3Ybb5puXQQOmGnhhQS2IgdArbUEMbRgnOw0tgnMTw,28275
9
- malevich_coretools/funcs/helpers.py,sha256=Y8v6uyawYl2_G0XmhmiVLqGIUzvxnkpKF0ODA9vrB3Y,1276
10
- malevich_coretools/secondary/__init__.py,sha256=048HqvG36_1WdDVZK_RuECmaf14Iq2fviUysG1inlaE,78
11
- malevich_coretools/secondary/config.py,sha256=b7RysQTkPKib8FEhfm3uU7TPvz8vgWLlqakvZN5NFs4,391
12
- malevich_coretools/secondary/const.py,sha256=cRFOMVZXofIce9OECKmgcg5AFTcoWT-wfDFsta6_b3A,8026
13
- malevich_coretools/secondary/helpers.py,sha256=si5WM8OXc8j35cwHBVH0HPTMmZ1QyQePq81Ct-KIoSI,3064
14
- malevich_coretools/tools/__init__.py,sha256=jDxlCa5Dr6Y43qlI7JwsRAlBkKmFeTHTEnjNUvu-0iw,46
15
- malevich_coretools/tools/vast.py,sha256=u1cnfylSgq3nYfonXbTy1zwor3OPkhD3vRf2OnqlMZY,12504
16
- malevich_coretools-0.2.9.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
- malevich_coretools-0.2.9.dist-info/METADATA,sha256=KLD4XcCgysBtfb_FcUKO_svCCE4ggoI_Uq1-eEMS3pU,236
18
- malevich_coretools-0.2.9.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
19
- malevich_coretools-0.2.9.dist-info/top_level.txt,sha256=wDX3s1Tso0otBPNrFRfXqyNpm48W4Bp5v6JfbITO2Z8,19
20
- malevich_coretools-0.2.9.dist-info/RECORD,,