malevich-coretools 0.3.20__py3-none-any.whl → 0.3.24__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.

@@ -422,6 +422,11 @@ class ProcessorFunctionInfo(FunctionInfo):
422
422
  contextClass: Optional[Dict[str, Any]] = None # model_json_schema
423
423
 
424
424
 
425
+ class ConditionFunctionInfo(FunctionInfo):
426
+ # contextClass: Optional[Dict[str, Any]] = None # model_json_schema
427
+ ...
428
+
429
+
425
430
  class OutputFunctionInfo(FunctionInfo):
426
431
  collectionOutNames: Optional[List[str]] = None
427
432
 
@@ -438,6 +443,7 @@ class InitInfo(BaseModel):
438
443
  class AppFunctionsInfo(BaseModel):
439
444
  inputs: Dict[Alias.Id, InputFunctionInfo] = dict()
440
445
  processors: Dict[Alias.Id, ProcessorFunctionInfo] = dict()
446
+ conditions: Dict[Alias.Id, ConditionFunctionInfo] = dict()
441
447
  outputs: Dict[Alias.Id, OutputFunctionInfo] = dict()
442
448
  schemes: Dict[Alias.Id, str] = dict()
443
449
  inits: Dict[Alias.Id, InitInfo] = dict()
@@ -30,6 +30,10 @@ def get_docs_id(id: str, *args, **kwargs) -> ResultDoc:
30
30
  return model_from_json(send_to_core_get(DOCS_ID(id, None), *args, **kwargs), ResultDoc)
31
31
 
32
32
 
33
+ def get_docs_name(name: str, *args, **kwargs) -> ResultDoc:
34
+ return model_from_json(send_to_core_get(DOCS_NAME(name, None), *args, **kwargs), ResultDoc)
35
+
36
+
33
37
  def post_docs(data: DocWithName, wait: bool, *args, **kwargs) -> Alias.Id:
34
38
  return send_to_core_modify(DOCS(wait), data, *args, **kwargs)
35
39
 
@@ -34,7 +34,10 @@ def create_collection_from_file_df(
34
34
  *args,
35
35
  **kwargs
36
36
  ) -> Alias.Id:
37
- data = pd.read_csv(file)
37
+ try:
38
+ data = pd.read_csv(file)
39
+ except pd.errors.EmptyDataError:
40
+ data = pd.DataFrame()
38
41
  if name is None:
39
42
  name = file
40
43
  return create_collection_from_df(data, name=file, metadata=metadata, *args, **kwargs)
@@ -63,7 +66,10 @@ def raw_collection_from_file(
63
66
  name: Optional[str] = None,
64
67
  metadata: Optional[Union[Dict[str, Any], str]] = None,
65
68
  ) -> DocsDataCollection:
66
- data = pd.read_csv(file)
69
+ try:
70
+ data = pd.read_csv(file)
71
+ except pd.errors.EmptyDataError:
72
+ data = pd.DataFrame()
67
73
  return raw_collection_from_df(data, name, metadata)
68
74
 
69
75
 
@@ -39,6 +39,7 @@ def with_key_values(url: str, key_values: Dict[str, Optional[str]]) -> str:
39
39
  DOCS_MAIN = f"{API_VERSION}/docs"
40
40
  DOCS = lambda wait: with_wait(f"{DOCS_MAIN}/", wait)
41
41
  DOCS_ID = lambda id, wait: with_wait(f"{DOCS_MAIN}/{id}", wait)
42
+ DOCS_NAME = lambda name, wait: with_wait(f"{DOCS_MAIN}/name/{name}", wait)
42
43
 
43
44
  ## CollectionsController
44
45
  COLLECTIONS_MAIN = f"{API_VERSION}/collections"
@@ -2,7 +2,7 @@ import json
2
2
  import os
3
3
  import re
4
4
  import subprocess
5
- from typing import Union
5
+ from typing import Type, Union
6
6
 
7
7
  import pandas as pd
8
8
 
@@ -148,8 +148,23 @@ def get_doc(
148
148
  return f.get_docs_id(id, auth=auth, conn_url=conn_url)
149
149
 
150
150
 
151
+ def get_doc_by_name(
152
+ name: str,
153
+ *,
154
+ auth: Optional[AUTH] = None,
155
+ conn_url: Optional[str] = None,
156
+ batcher: Optional[Batcher] = None,
157
+ ) -> ResultDoc:
158
+ """return doc by `name` """
159
+ if batcher is None:
160
+ batcher = Config.BATCHER
161
+ if batcher is not None:
162
+ return batcher.add("getDocByName", vars={"name": name}, result_model=ResultDoc)
163
+ return f.get_docs_name(name, auth=auth, conn_url=conn_url)
164
+
165
+
151
166
  def create_doc(
152
- data: Alias.Json,
167
+ data: Union[Alias.Json, Dict, Type[BaseModel]],
153
168
  name: Optional[str],
154
169
  wait: bool = True,
155
170
  *,
@@ -160,6 +175,10 @@ def create_doc(
160
175
  """save doc with `data` and `name`, return `id` """
161
176
  if batcher is None:
162
177
  batcher = Config.BATCHER
178
+ if isinstance(data, Dict):
179
+ data = json.dumps(data)
180
+ elif issubclass(data.__class__, BaseModel):
181
+ data = data.model_dump_json()
163
182
  data = DocWithName(data=data, name=name)
164
183
  if batcher is not None:
165
184
  return batcher.add("postDoc", data=data)
@@ -3267,6 +3286,23 @@ def get_collection_by_name_to_df(
3267
3286
  return pd.DataFrame.from_records(records)
3268
3287
 
3269
3288
 
3289
+ def create_doc_from_file(
3290
+ filename: str,
3291
+ name: Optional[str] = None,
3292
+ *,
3293
+ auth: Optional[AUTH] = None,
3294
+ conn_url: Optional[str] = None,
3295
+ batcher: Optional[Batcher] = None,
3296
+ ) -> Alias.Id:
3297
+ """create doc\n
3298
+ return doc id"""
3299
+ with open(filename) as f:
3300
+ data = json.load(f)
3301
+ return create_doc(
3302
+ data, name, auth=auth, conn_url=conn_url, batcher=batcher
3303
+ )
3304
+
3305
+
3270
3306
  def create_schemes_by_path(
3271
3307
  path: str,
3272
3308
  wait: bool = True,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: malevich-coretools
3
- Version: 0.3.20
3
+ Version: 0.3.24
4
4
  Author: Andrew Pogrebnoj
5
5
  Author-email: andrew@onjulius.co
6
6
  License-File: LICENSE
@@ -1,7 +1,7 @@
1
1
  malevich_coretools/__init__.py,sha256=DJtPESxkCZD2SbTZTrR_x0TKDQ4MJpmBqGw5YpKYidM,134
2
- malevich_coretools/utils.py,sha256=B43dLGRjEH-dtJJ6Vgjgb8uZEYhQG6VzdZWrxQPRzsU,105355
2
+ malevich_coretools/utils.py,sha256=1r6RlXHeTQhMsKt7Wc_vwxBKBib-8svw0Ells4RLsrQ,106380
3
3
  malevich_coretools/abstract/__init__.py,sha256=8AC5ZukRGkTtN-XP14DY5z2HrJqN5LLlnmcMqvWwtWU,76
4
- malevich_coretools/abstract/abstract.py,sha256=bnlFn-EbSRQa4QxqGE5Z-XKjqkJg8OXd1b0U6RTNZzQ,14100
4
+ malevich_coretools/abstract/abstract.py,sha256=6or8FPWQsycKDtK70vR4jKLIqLgg4c8GacdkQ533ZgI,14290
5
5
  malevich_coretools/abstract/pipeline.py,sha256=AdHQIpOMZMNJt6f17MK_s2k6FM2Kc_ImAn4LJuDbZAM,3279
6
6
  malevich_coretools/abstract/statuses.py,sha256=9ISSw_evsylBshLXoU44TCoFOrZm4bXIxyAFFDqdUWc,333
7
7
  malevich_coretools/admin/__init__.py,sha256=zdIcHs3T_NZ8HYWts-O7OpBEWHIu779QDZMGF5HRCLg,35
@@ -10,18 +10,18 @@ malevich_coretools/batch/__init__.py,sha256=taxyZl8YOZd2EBd3leN6slzMkejUtjQ64Na3
10
10
  malevich_coretools/batch/utils.py,sha256=cqX34sfh85dCwLv7qprxatzhYxxj7LqZwjhlmk_3GXQ,7705
11
11
  malevich_coretools/funcs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  malevich_coretools/funcs/checks.py,sha256=Q5pRtRevQrGv_-SMbn2GgYnulhclDLBXdRtbw2QOYKU,223
13
- malevich_coretools/funcs/funcs.py,sha256=VVw2gKy8LEdb4_dU9W1Orb6imZk_LYWJMu7OZFbnMwA,36506
14
- malevich_coretools/funcs/helpers.py,sha256=CZYza0uQ68ywcfeUE9rP7q0VjsfnLtBp4z0qQZbIkjY,9843
13
+ malevich_coretools/funcs/funcs.py,sha256=mYKcDOgmt4CVQ24EbhGxJXDMqQx4kFeSBziwGhTMz9Q,36664
14
+ malevich_coretools/funcs/helpers.py,sha256=-JU17yt19CS8IadZ0r5vN4hmXBrTjLUyRB07kBDhZL4,10003
15
15
  malevich_coretools/secondary/__init__.py,sha256=048HqvG36_1WdDVZK_RuECmaf14Iq2fviUysG1inlaE,78
16
16
  malevich_coretools/secondary/config.py,sha256=hRlSJuPQnhKyt1wmOAJX_XmcliaO0fPGbW94AE_Mazs,463
17
- malevich_coretools/secondary/const.py,sha256=W6GVTpPYsQgllmOUk5US7yzjq1GxyR_vEQog2KMv14w,12601
17
+ malevich_coretools/secondary/const.py,sha256=PlDlCbZ-AIOF88fEsT4lVQ1IxgUthUhleJLMkYLGsvU,12676
18
18
  malevich_coretools/secondary/helpers.py,sha256=t-W9g9t0O1EaAX8UOb1wxXFAMawbtDotDH47t0GdjG4,6142
19
19
  malevich_coretools/secondary/kafka_utils.py,sha256=SIUnBFyfwsquN6MAUrEkKCw-1l7979Znl7OTQSX2UKo,989
20
20
  malevich_coretools/tools/__init__.py,sha256=jDxlCa5Dr6Y43qlI7JwsRAlBkKmFeTHTEnjNUvu-0iw,46
21
21
  malevich_coretools/tools/abstract.py,sha256=B1RW1FeNHrQ6r1k-cQZ4k4noCRXkIGt-JUwVoXEDkAg,4466
22
22
  malevich_coretools/tools/vast.py,sha256=63tvy70qQV9vnK0eWytlgjBGSnfA7l3kSIDgACBbMMs,12893
23
- malevich_coretools-0.3.20.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
24
- malevich_coretools-0.3.20.dist-info/METADATA,sha256=2wNFKOTyLSII7sAxJQQGrH-1pMtAckGvLnZ49p11pow,265
25
- malevich_coretools-0.3.20.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
26
- malevich_coretools-0.3.20.dist-info/top_level.txt,sha256=wDX3s1Tso0otBPNrFRfXqyNpm48W4Bp5v6JfbITO2Z8,19
27
- malevich_coretools-0.3.20.dist-info/RECORD,,
23
+ malevich_coretools-0.3.24.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
24
+ malevich_coretools-0.3.24.dist-info/METADATA,sha256=0DpEbTBuQ78b7em65HrBdknWxJyuMYcigXlbg4YMptY,265
25
+ malevich_coretools-0.3.24.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
26
+ malevich_coretools-0.3.24.dist-info/top_level.txt,sha256=wDX3s1Tso0otBPNrFRfXqyNpm48W4Bp5v6JfbITO2Z8,19
27
+ malevich_coretools-0.3.24.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5