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

@@ -23,7 +23,9 @@ from malevich_coretools.batch import Batcher
23
23
  from malevich_coretools.funcs.checks import check_profile_mode
24
24
  from malevich_coretools.funcs.funcs import (
25
25
  post_collections_data,
26
+ post_collections_data_async,
26
27
  post_collections_data_id,
28
+ post_collections_data_id_async,
27
29
  )
28
30
  from malevich_coretools.secondary import Config, to_json
29
31
 
@@ -98,6 +100,7 @@ def create_collection_from_df(
98
100
  name: Optional[str],
99
101
  metadata: Optional[Union[Dict[str, Any], str]],
100
102
  batcher: Optional[Batcher] = None,
103
+ is_async: bool = False,
101
104
  *args,
102
105
  **kwargs
103
106
  ) -> Alias.Id:
@@ -106,6 +109,8 @@ def create_collection_from_df(
106
109
  data = raw_collection_from_df(data, name, metadata)
107
110
  if batcher is not None:
108
111
  return batcher.add("postCollectionByDocs", data=data)
112
+ if is_async:
113
+ return post_collections_data_async(data, *args, **kwargs)
109
114
  return post_collections_data(data, *args, **kwargs)
110
115
 
111
116
 
@@ -115,6 +120,7 @@ def update_collection_from_df(
115
120
  name: Optional[str],
116
121
  metadata: Optional[Union[Dict[str, Any], str]],
117
122
  batcher: Optional[Batcher] = None,
123
+ is_async: bool = False,
118
124
  *args,
119
125
  **kwargs
120
126
  ) -> Alias.Id:
@@ -123,6 +129,8 @@ def update_collection_from_df(
123
129
  data = raw_collection_from_df(data, name, metadata)
124
130
  if batcher is not None:
125
131
  return batcher.add("postCollectionByDocsAndId", data=data, vars={"id": id})
132
+ if is_async:
133
+ return post_collections_data_id_async(id, data, *args, **kwargs)
126
134
  return post_collections_data_id(id, data, *args, **kwargs)
127
135
 
128
136
 
@@ -30,6 +30,8 @@ def with_key_values(url: str, key_values: Dict[str, Optional[str]]) -> str:
30
30
  value = urllib.parse.quote(str(value), safe='')
31
31
  elif isinstance(value, str):
32
32
  value = urllib.parse.quote(value, safe='')
33
+ elif isinstance(value, bool):
34
+ value = bool_to_str(value)
33
35
  url = f"{url}{sep}{key}={value}"
34
36
  if sep == "?":
35
37
  sep = "&"
@@ -216,6 +218,13 @@ WS_APPS = lambda only_active, full: with_key_values(f"{WS_APPS_MAIN}/", {"onlyAc
216
218
  WS_APPS_ = lambda only_not_active, wait: with_key_values(f"{WS_APPS_MAIN}/", {"onlyNotActive": only_not_active, "wait": wait})
217
219
  WS_APPS_ID = lambda id, wait: with_wait(f"{WS_APPS_MAIN}/{id}", wait)
218
220
 
221
+ ## McpToolController
222
+ MCP_TOOLS_MAIN = f"{API_VERSION}/tools"
223
+ MCP_TOOLS = lambda id, name, wait: with_key_values(f"{MCP_TOOLS_MAIN}/", {"id": id, "name": name, "wait": wait})
224
+ MCP_TOOLS_ALL = lambda wait: with_wait(f"{MCP_TOOLS_MAIN}/all", wait)
225
+ MCP_TOOLS_LIST = f"{MCP_TOOLS_MAIN}/list"
226
+ MCP_TOOLS_CALL = f"{MCP_TOOLS_MAIN}/call"
227
+
219
228
  ### Kafka
220
229
  KAFKA_SEND = f"{MANAGER_MAIN}/kafkaMsg"
221
230
 
@@ -35,11 +35,17 @@ def to_json(data: Union[Dict[str, Any], Alias.Json], condition_and_msg: Tuple[Ca
35
35
  return res
36
36
 
37
37
 
38
- def model_from_json(data: Union[Dict[str, Any], Alias.Json], model: BaseModel): # noqa: ANN201
38
+ def model_from_json(data: Union[Dict[str, Any], Alias.Json], model: BaseModel, is_list: Optional[bool] = False): # noqa: ANN201
39
39
  if isinstance(data, Alias.Json):
40
40
  data = json.loads(data)
41
- assert isinstance(data, dict), data
42
- return model.parse_obj(data)
41
+ if is_list is None:
42
+ is_list = isinstance(data, list)
43
+ if is_list:
44
+ assert isinstance(data, list), data
45
+ return [model.model_validate(item) for item in data]
46
+ else:
47
+ assert isinstance(data, dict), data
48
+ return model.model_validate(data)
43
49
 
44
50
 
45
51
  def rand_str(size: int = 10, chars=string.ascii_letters) -> str: