malevich-coretools 0.3.66__tar.gz → 0.3.68__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 malevich-coretools might be problematic. Click here for more details.

Files changed (40) hide show
  1. {malevich_coretools-0.3.66/malevich_coretools.egg-info → malevich_coretools-0.3.68}/PKG-INFO +1 -1
  2. malevich_coretools-0.3.68/VERSION +1 -0
  3. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/__init__.py +1 -0
  4. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/abstract/abstract.py +1 -0
  5. malevich_coretools-0.3.68/malevich_coretools/dm_utils.py +233 -0
  6. malevich_coretools-0.3.68/malevich_coretools/funcs/dm_funcs.py +162 -0
  7. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/funcs/funcs.py +18 -14
  8. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/secondary/config.py +1 -0
  9. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/secondary/const.py +8 -1
  10. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/utils.py +51 -8
  11. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68/malevich_coretools.egg-info}/PKG-INFO +1 -1
  12. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools.egg-info/SOURCES.txt +2 -0
  13. malevich_coretools-0.3.66/VERSION +0 -1
  14. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/LICENSE +0 -0
  15. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/MANIFEST.in +0 -0
  16. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/README.md +0 -0
  17. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/abstract/__init__.py +0 -0
  18. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/abstract/operations.py +0 -0
  19. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/abstract/pipeline.py +0 -0
  20. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/abstract/statuses.py +0 -0
  21. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/admin/__init__.py +0 -0
  22. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/admin/utils.py +0 -0
  23. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/batch/__init__.py +0 -0
  24. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/batch/utils.py +0 -0
  25. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/funcs/__init__.py +0 -0
  26. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/funcs/checks.py +0 -0
  27. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/funcs/helpers.py +0 -0
  28. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/secondary/__init__.py +0 -0
  29. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/secondary/helpers.py +0 -0
  30. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/secondary/kafka_utils.py +0 -0
  31. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/tools/__init__.py +0 -0
  32. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/tools/abstract.py +0 -0
  33. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools/tools/vast.py +0 -0
  34. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools.egg-info/dependency_links.txt +0 -0
  35. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools.egg-info/requires.txt +0 -0
  36. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/malevich_coretools.egg-info/top_level.txt +0 -0
  37. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/pyproject.toml +0 -0
  38. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/requirements.txt +0 -0
  39. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/setup.cfg +0 -0
  40. {malevich_coretools-0.3.66 → malevich_coretools-0.3.68}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: malevich-coretools
3
- Version: 0.3.66
3
+ Version: 0.3.68
4
4
  Author: Andrew Pogrebnoj
5
5
  Author-email: andrew@onjulius.co
6
6
  License-File: LICENSE
@@ -0,0 +1 @@
1
+ 0.3.68
@@ -1,3 +1,4 @@
1
+ from .dm_utils import * # noqa: F403
1
2
  from .secondary import logs_streaming # noqa: F401
2
3
  from .tools import vast_settings # noqa: F401
3
4
  from .utils import * # noqa: F403
@@ -400,6 +400,7 @@ class PipelineRunInfo(BaseModel):
400
400
 
401
401
  class AppLogs(BaseModel):
402
402
  operationId: Alias.Id
403
+ runId: Optional[Alias.Id] = None
403
404
  dagLogs: str = ""
404
405
  data: Dict[str, AppLog] = {}
405
406
  error: Optional[str] = None
@@ -0,0 +1,233 @@
1
+ from typing import (
2
+ Any,
3
+ AsyncIterable,
4
+ Coroutine,
5
+ Iterable,
6
+ List,
7
+ Literal,
8
+ Optional,
9
+ Union,
10
+ overload,
11
+ )
12
+
13
+ import malevich_coretools.funcs.dm_funcs as f
14
+
15
+
16
+ @overload
17
+ def dm_stream(
18
+ operation_id: str,
19
+ run_id: str,
20
+ bind_id: str,
21
+ *,
22
+ conn_url: Optional[str] = None,
23
+ is_async: Literal[False] = False,
24
+ ) -> Iterable:
25
+ pass
26
+
27
+
28
+ @overload
29
+ def dm_stream(
30
+ operation_id: str,
31
+ run_id: str,
32
+ bind_id: str,
33
+ *,
34
+ conn_url: Optional[str] = None,
35
+ is_async: Literal[True],
36
+ ) -> Coroutine[Any, Any, AsyncIterable]:
37
+ pass
38
+
39
+
40
+ def dm_stream(
41
+ operation_id: str,
42
+ run_id: str,
43
+ bind_id: str,
44
+ *,
45
+ conn_url: Optional[str] = None,
46
+ is_async: bool = False,
47
+ ) -> Union[Iterable, Coroutine[Any, Any, AsyncIterable]]:
48
+ if is_async:
49
+ return f.dm_stream_async(operation_id, run_id, bind_id, conn_url=conn_url)
50
+ return f.dm_stream(operation_id, run_id, bind_id, conn_url=conn_url)
51
+
52
+
53
+ @overload
54
+ def dm_continue(
55
+ operation_id: str,
56
+ run_id: str,
57
+ id: str,
58
+ data: Any,
59
+ *,
60
+ conn_url: Optional[str] = None,
61
+ is_async: Literal[False] = False,
62
+ ) -> None:
63
+ pass
64
+
65
+
66
+ @overload
67
+ def dm_continue(
68
+ operation_id: str,
69
+ run_id: str,
70
+ id: str,
71
+ data: Any,
72
+ *,
73
+ conn_url: Optional[str] = None,
74
+ is_async: Literal[True],
75
+ ) -> Coroutine[Any, Any, None]:
76
+ pass
77
+
78
+
79
+ def dm_continue(
80
+ operation_id: str,
81
+ run_id: str,
82
+ id: str,
83
+ data: Any,
84
+ *,
85
+ conn_url: Optional[str] = None,
86
+ is_async: bool = False,
87
+ ) -> Union[None, Coroutine[Any, Any, None]]:
88
+ if is_async:
89
+ return f.dm_continue_async(operation_id, run_id, id, data, conn_url=conn_url)
90
+ return f.dm_continue(operation_id, run_id, id, data, conn_url=conn_url)
91
+
92
+
93
+ @overload
94
+ def dm_state(
95
+ operation_id: str,
96
+ run_id: str,
97
+ bind_id: str,
98
+ key: Optional[str] = None,
99
+ index: Optional[int] = None,
100
+ *,
101
+ conn_url: Optional[str] = None,
102
+ is_async: Literal[False] = False,
103
+ ) -> Any:
104
+ pass
105
+
106
+
107
+ @overload
108
+ def dm_state(
109
+ operation_id: str,
110
+ run_id: str,
111
+ bind_id: str,
112
+ key: Optional[str] = None,
113
+ index: Optional[int] = None,
114
+ *,
115
+ conn_url: Optional[str] = None,
116
+ is_async: Literal[True],
117
+ ) -> Coroutine[Any, Any, Any]:
118
+ pass
119
+
120
+
121
+ def dm_state(
122
+ operation_id: str,
123
+ run_id: str,
124
+ bind_id: str,
125
+ key: Optional[str] = None,
126
+ index: Optional[int] = None,
127
+ *,
128
+ conn_url: Optional[str] = None,
129
+ is_async: bool = False,
130
+ ) -> Union[Any, Coroutine[Any, Any, Any]]:
131
+ if is_async:
132
+ return f.dm_state_async(operation_id, run_id, bind_id, key, index, conn_url=conn_url)
133
+ return f.dm_state(operation_id, run_id, bind_id, key, index, conn_url=conn_url)
134
+
135
+
136
+ @overload
137
+ def dm_journal_list(
138
+ operation_id: str,
139
+ run_id: str,
140
+ *,
141
+ conn_url: Optional[str] = None,
142
+ is_async: Literal[False] = False,
143
+ ) -> List[str]:
144
+ pass
145
+
146
+
147
+ @overload
148
+ def dm_journal_list(
149
+ operation_id: str,
150
+ run_id: str,
151
+ *,
152
+ conn_url: Optional[str] = None,
153
+ is_async: Literal[True],
154
+ ) -> Coroutine[Any, Any, List[str]]:
155
+ pass
156
+
157
+
158
+ def dm_journal_list(
159
+ operation_id: str,
160
+ run_id: str,
161
+ *,
162
+ conn_url: Optional[str] = None,
163
+ is_async: bool = False,
164
+ ) -> Union[List[str], Coroutine[Any, Any, List[str]]]:
165
+ if is_async:
166
+ return f.dm_journal_list_async(operation_id, run_id, conn_url=conn_url)
167
+ return f.dm_journal_list(operation_id, run_id, conn_url=conn_url)
168
+
169
+
170
+ @overload
171
+ def dm_journal(
172
+ operation_id: str,
173
+ run_id: str,
174
+ key: str,
175
+ is_stream: Literal[False] = False,
176
+ *,
177
+ conn_url: Optional[str] = None,
178
+ is_async: Literal[False] = False,
179
+ ) -> Any:
180
+ pass
181
+
182
+
183
+ @overload
184
+ def dm_journal(
185
+ operation_id: str,
186
+ run_id: str,
187
+ key: str,
188
+ is_stream: Literal[False] = False,
189
+ *,
190
+ conn_url: Optional[str] = None,
191
+ is_async: Literal[True],
192
+ ) -> Coroutine[Any, Any, Any]:
193
+ pass
194
+
195
+
196
+ @overload
197
+ def dm_journal(
198
+ operation_id: str,
199
+ run_id: str,
200
+ key: str,
201
+ is_stream: Literal[True],
202
+ *,
203
+ conn_url: Optional[str] = None,
204
+ is_async: Literal[False] = False,
205
+ ) -> Iterable:
206
+ pass
207
+
208
+
209
+ @overload
210
+ def dm_journal(
211
+ operation_id: str,
212
+ run_id: str,
213
+ key: str,
214
+ is_stream: Literal[True],
215
+ *,
216
+ conn_url: Optional[str] = None,
217
+ is_async: Literal[True],
218
+ ) -> Coroutine[Any, Any, AsyncIterable]:
219
+ pass
220
+
221
+
222
+ def dm_journal(
223
+ operation_id: str,
224
+ run_id: str,
225
+ key: str,
226
+ is_stream: bool = False,
227
+ *,
228
+ conn_url: Optional[str] = None,
229
+ is_async: bool = False,
230
+ ) -> Union[Any, Iterable, Coroutine[Any, Any, Union[Any, AsyncIterable]]]:
231
+ if is_async:
232
+ return f.dm_journal_async(operation_id, run_id, key, is_stream, conn_url=conn_url)
233
+ return f.dm_journal(operation_id, run_id, key, is_stream, conn_url=conn_url)
@@ -0,0 +1,162 @@
1
+ from http import HTTPStatus
2
+ from typing import Any, AsyncIterable, Iterable, List, Optional, Union
3
+
4
+ import aiohttp
5
+ import requests
6
+ from requests.models import Response
7
+
8
+ from malevich_coretools.secondary import Config
9
+ from malevich_coretools.secondary.const import * # noqa: F403
10
+
11
+
12
+ def dm_stream(operation_id: str, run_id: str, bind_id: str, conn_url: Optional[str]=None) -> Iterable:
13
+ return send_to_dm_stream(DM_STREAM(operation_id, run_id, bind_id), conn_url=conn_url)
14
+
15
+
16
+ async def dm_stream_async(operation_id: str, run_id: str, bind_id: str, conn_url: Optional[str]=None) -> AsyncIterable:
17
+ return await send_to_dm_stream_async(DM_STREAM(operation_id, run_id, bind_id), conn_url=conn_url)
18
+
19
+
20
+ def dm_continue(operation_id: str, run_id: str, id: str, data: Any, conn_url: Optional[str]=None) -> None:
21
+ return send_to_dm_post(DM_CONTINUE(operation_id, run_id, id), data, conn_url=conn_url)
22
+
23
+
24
+ async def dm_continue_async(operation_id: str, run_id: str, id: str, data: Any, conn_url: Optional[str]=None) -> None:
25
+ return await send_to_dm_post_async(DM_CONTINUE(operation_id, run_id, id), data, conn_url=conn_url)
26
+
27
+
28
+ def dm_state(operation_id: str, run_id: str, bind_id: str, key: Optional[str] = None, index: Optional[int] = None, conn_url: Optional[str]=None) -> Any:
29
+ return send_to_dm_get(DM_STATE(operation_id, run_id, bind_id, key, index), conn_url=conn_url)
30
+
31
+
32
+ async def dm_state_async(operation_id: str, run_id: str, bind_id: str, key: Optional[str] = None, index: Optional[int] = None, conn_url: Optional[str]=None) -> Any:
33
+ return await send_to_dm_get_async(DM_STATE(operation_id, run_id, bind_id, key, index), conn_url=conn_url)
34
+
35
+
36
+ def dm_journal_list(operation_id: str, run_id: str, conn_url: Optional[str]=None) -> List[str]:
37
+ return send_to_dm_get(DM_JOURNAL_LIST(operation_id, run_id), is_text=False, conn_url=conn_url)
38
+
39
+
40
+ async def dm_journal_list_async(operation_id: str, run_id: str, conn_url: Optional[str]=None) -> List[str]:
41
+ return await send_to_dm_get_async(DM_JOURNAL_LIST(operation_id, run_id), is_text=False, conn_url=conn_url)
42
+
43
+
44
+ def dm_journal(operation_id: str, run_id: str, key: str, is_stream: bool, conn_url: Optional[str]=None) -> Union[Any, Iterable]:
45
+ if is_stream:
46
+ return send_to_dm_stream(DM_JOURNAL(operation_id, run_id, key, is_stream), conn_url=conn_url)
47
+ return send_to_dm_get(DM_JOURNAL(operation_id, run_id, key, is_stream), conn_url=conn_url)
48
+
49
+
50
+ async def dm_journal_async(operation_id: str, run_id: str, key: str, is_stream: bool, conn_url: Optional[str]=None) -> Union[Any, AsyncIterable]:
51
+ if is_stream:
52
+ return await send_to_dm_stream_async(DM_JOURNAL(operation_id, run_id, key, is_stream), conn_url=conn_url)
53
+ return await send_to_dm_get_async(DM_JOURNAL(operation_id, run_id, key, is_stream), conn_url=conn_url)
54
+
55
+
56
+ #
57
+
58
+ def __check_response(path: str, response: Response): # noqa: ANN202
59
+ if response.status_code >= 400:
60
+ text = response.text
61
+ msg = f"failed: {text}" if len(text) > 0 else "failed"
62
+ Config.logger.error(f"{path} {msg}")
63
+
64
+ if response.reason is not None and len(response.reason) == 0:
65
+ response.reason = text
66
+ response.raise_for_status()
67
+
68
+
69
+ async def __async_check_response(response: aiohttp.ClientResponse, path: Optional[str] = None): # noqa: ANN202
70
+ if not response.ok:
71
+ text = await response.text()
72
+ if path is not None:
73
+ msg = f"failed: {text}" if len(text) > 0 else "failed"
74
+ Config.logger.error(f"{path} {msg}")
75
+ else:
76
+ Config.logger.error(text)
77
+
78
+ if response.reason is not None and len(response.reason) == 0:
79
+ response.reason = text
80
+ response.raise_for_status()
81
+
82
+
83
+ def send_to_dm_get(path: str, is_text: bool=True, conn_url: Optional[str]=None) -> Optional[Union[str, bytes]]:
84
+ host = Config.DM_HOST_PORT if conn_url is None else conn_url
85
+ assert host is not None, "dm host port not set"
86
+ response = requests.get(f"{host}{path}", headers=HEADERS)
87
+ __check_response(f"{host}{path}", response)
88
+ if response.status_code == HTTPStatus.NO_CONTENT:
89
+ return None
90
+ if is_text is True:
91
+ return response.text
92
+ elif is_text is False:
93
+ return response.json()
94
+ else:
95
+ return response.content
96
+
97
+
98
+ async def send_to_dm_get_async(path: str, is_text: bool=True, conn_url: Optional[str]=None, async_session = None) -> Optional[Union[str, bytes]]:
99
+ host = Config.DM_HOST_PORT if conn_url is None else conn_url
100
+ assert host is not None, "dm host port not set"
101
+ async with async_session or aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False), timeout=aiohttp.ClientTimeout(total=None)) as session:
102
+ async with session.get(f"{host}{path}", headers=HEADERS) as response:
103
+ await __async_check_response(response, f"{host}{path}")
104
+ if response.status == HTTPStatus.NO_CONTENT:
105
+ return None
106
+ if is_text is True:
107
+ return await response.text()
108
+ elif is_text is False:
109
+ return await response.json()
110
+ else:
111
+ return await response.read()
112
+
113
+
114
+ def send_to_dm_post(path: str, operation: Optional[Any] = None, conn_url: Optional[str]=None) -> Optional[str]: # noqa: ANN401
115
+ host = Config.DM_HOST_PORT if conn_url is None else conn_url
116
+ assert host is not None, "dm host port not set"
117
+ response = requests.post(f"{host}{path}", data=operation, headers=HEADERS)
118
+ __check_response(f"{host}{path}", response)
119
+ if response.status_code == HTTPStatus.NO_CONTENT:
120
+ return None
121
+ return response.text
122
+
123
+
124
+ async def send_to_dm_post_async(path: str, operation: Optional[Any] = None, conn_url: Optional[str]=None, async_session=None) -> str: # noqa: ANN401
125
+ host = Config.DM_HOST_PORT if conn_url is None else conn_url
126
+ assert host is not None, "dm host port not set"
127
+ async with async_session or aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False), timeout=aiohttp.ClientTimeout(total=None)) as session:
128
+ async with session.post(f"{host}{path}", data=operation, headers=HEADERS) as response:
129
+ await __async_check_response(response, f"{host}{path}")
130
+ if response.status == HTTPStatus.NO_CONTENT:
131
+ return None
132
+ return response.text()
133
+
134
+
135
+ def send_to_dm_stream(path: str, conn_url: Optional[str]=None) -> Iterable:
136
+ host = Config.DM_HOST_PORT if conn_url is None else conn_url
137
+ assert host is not None, "dm host port not set"
138
+
139
+ def stream_generator() -> None:
140
+ with requests.get(f"{host}{path}", headers=HEADERS, stream=True) as response:
141
+ __check_response(f"{host}{path}", response)
142
+ if response.status_code == HTTPStatus.NO_CONTENT:
143
+ return
144
+ for chunk in response.iter_content(chunk_size=4096):
145
+ if chunk:
146
+ yield chunk.decode("utf-8", errors="ignore")
147
+ return stream_generator()
148
+
149
+
150
+ async def send_to_dm_stream_async(path: str, conn_url: Optional[str]=None, async_session = None) -> AsyncIterable:
151
+ host = Config.DM_HOST_PORT if conn_url is None else conn_url
152
+ assert host is not None, "dm host port not set"
153
+
154
+ async def stream_generator() -> None:
155
+ async with async_session or aiohttp.ClientSession(connector=aiohttp.TCPConnector(verify_ssl=False), timeout=aiohttp.ClientTimeout(total=None)) as session:
156
+ async with session.get(f"{host}{path}", headers=HEADERS) as response:
157
+ await __async_check_response(response, f"{host}{path}")
158
+ if response.status == HTTPStatus.NO_CONTENT:
159
+ return
160
+ async for chunk in response.content.iter_any():
161
+ yield chunk.decode("utf-8", errors="ignore")
162
+ return stream_generator()
@@ -124,12 +124,18 @@ async def get_collections_groupName_async(name: str, operation_id: str, run_id:
124
124
  return model_from_json(await send_to_core_get_async(COLLECTIONS_GROUP_NAME(name, operation_id, run_id), *args, **kwargs), ResultCollections)
125
125
 
126
126
 
127
- def get_collections_id(id: str, offset: int, limit: int, *args, **kwargs) -> ResultCollection:
128
- return model_from_json(send_to_core_get(COLLECTIONS_ID(id, offset, limit), *args, **kwargs), ResultCollection)
127
+ def get_collections_id(id: str, offset: int, limit: int, raw: bool, *args, **kwargs) -> Union[ResultCollection, Alias.Json]:
128
+ res = send_to_core_get(COLLECTIONS_ID(id, offset, limit, raw), *args, is_text=raw, **kwargs)
129
+ if not raw:
130
+ res = model_from_json(res, ResultCollection)
131
+ return res
129
132
 
130
133
 
131
- async def get_collections_id_async(id: str, offset: int, limit: int, *args, **kwargs) -> ResultCollection:
132
- return model_from_json(await send_to_core_get_async(COLLECTIONS_ID(id, offset, limit), *args, **kwargs), ResultCollection)
134
+ async def get_collections_id_async(id: str, offset: int, limit: int, raw: bool, *args, **kwargs) -> Union[ResultCollection, Alias.Json]:
135
+ res = await send_to_core_get_async(COLLECTIONS_ID(id, offset, limit, raw), *args, is_text=raw, **kwargs)
136
+ if not raw:
137
+ res = model_from_json(res, ResultCollection)
138
+ return res
133
139
 
134
140
 
135
141
  def post_collections(data: DocsCollection, wait: bool, *args, **kwargs) -> Alias.Id:
@@ -1280,26 +1286,24 @@ async def post_manager_task_async(data: MainTask, with_show: bool, long: bool, l
1280
1286
  return AppLogs.model_validate_json(res)
1281
1287
 
1282
1288
 
1283
- def post_manager_task_run(data: RunTask, with_show: bool, long: bool, long_timeout: int, wait: bool, auth: Optional[AUTH], conn_url: Optional[str]=None, *args, **kwargs) -> Optional[Union[Alias.Id, AppLogs]]:
1289
+ def post_manager_task_run(data: RunTask, with_show: bool, long: bool, long_timeout: int, wait: bool, auth: Optional[AUTH], conn_url: Optional[str]=None, *args, **kwargs) -> Union[Alias.Id, AppLogs]:
1284
1290
  check_profile_mode(data.profileMode)
1285
1291
  res = send_to_core_modify(MANAGER_TASK_RUN(wait and not long), data, with_show=with_show, show_func=show_logs_func, auth=auth, conn_url=conn_url, *args, **kwargs)
1286
1292
  if wait and long:
1287
1293
  res = asyncio.run(__get_result(res, timeout=long_timeout, auth=auth))
1288
- if data.withLogs or data.schedule is not None:
1289
- if not wait:
1290
- return res
1291
- return AppLogs.model_validate_json(res)
1294
+ if not wait:
1295
+ return res
1296
+ return AppLogs.model_validate_json(res)
1292
1297
 
1293
1298
 
1294
- async def post_manager_task_run_async(data: RunTask, with_show: bool, long: bool, long_timeout: int, wait: bool, auth: Optional[AUTH], conn_url: Optional[str]=None, *args, **kwargs) -> Optional[Union[Alias.Id, AppLogs]]:
1299
+ async def post_manager_task_run_async(data: RunTask, with_show: bool, long: bool, long_timeout: int, wait: bool, auth: Optional[AUTH], conn_url: Optional[str]=None, *args, **kwargs) -> Union[Alias.Id, AppLogs]:
1295
1300
  check_profile_mode(data.profileMode)
1296
1301
  res = await send_to_core_modify_async(MANAGER_TASK_RUN(wait and not long), data, with_show=with_show, show_func=show_logs_func, auth=auth, conn_url=conn_url, *args, **kwargs)
1297
1302
  if wait and long:
1298
1303
  res = await __get_result(res, timeout=long_timeout, auth=auth)
1299
- if data.withLogs or data.schedule is not None:
1300
- if not wait:
1301
- return res
1302
- return AppLogs.model_validate_json(res)
1304
+ if not wait:
1305
+ return res
1306
+ return AppLogs.model_validate_json(res)
1303
1307
 
1304
1308
 
1305
1309
  def post_manager_pipeline(data: MainPipeline, with_show: bool, long: bool, long_timeout: int, return_response: bool, wait: bool, auth: Optional[AUTH], conn_url: Optional[str]=None, *args, **kwargs) -> Union[Alias.Id, AppLogs]:
@@ -8,6 +8,7 @@ class Config:
8
8
  TOKEN = os.environ.get("GITLAB_ACCESS_TOKEN") # FIXME
9
9
 
10
10
  HOST_PORT = None
11
+ DM_HOST_PORT = None
11
12
  KAFKA_HOST_PORT = None
12
13
  CORE_USERNAME = None
13
14
  CORE_PASSWORD = None
@@ -50,7 +50,7 @@ COLLECTIONS_IDS_NAME = lambda name, operation_id, run_id: with_key_values(f"{COL
50
50
  COLLECTIONS_NAME = lambda name, operation_id, run_id, offset, limit: with_key_values(f"{COLLECTIONS_MAIN}/name/{urllib.parse.quote(str(name), safe='')}", {"operationId": operation_id, "runId": run_id, "offset": offset, "limit": limit})
51
51
  COLLECTIONS_IDS_GROUP_NAME = lambda name, operation_id, run_id: with_key_values(f"{COLLECTIONS_MAIN}/ids/groupName/{urllib.parse.quote(str(name), safe='')}", {"operationId": operation_id, "runId": run_id})
52
52
  COLLECTIONS_GROUP_NAME = lambda name, operation_id, run_id: with_key_values(f"{COLLECTIONS_MAIN}/groupName/{urllib.parse.quote(str(name), safe='')}", {"operationId": operation_id, "runId": run_id})
53
- COLLECTIONS_ID = lambda id, offset, limit: with_key_values(f"{COLLECTIONS_MAIN}/{urllib.parse.quote(str(id), safe='')}", {"offset": offset, "limit": limit})
53
+ COLLECTIONS_ID = lambda id, offset, limit, raw: with_key_values(f"{COLLECTIONS_MAIN}/{urllib.parse.quote(str(id), safe='')}", {"offset": offset, "limit": limit, "raw": raw})
54
54
  COLLECTIONS_ID_MODIFY = lambda id, wait: with_wait(f"{COLLECTIONS_MAIN}/{urllib.parse.quote(str(id), safe='')}", wait)
55
55
  COLLECTIONS_ID_S3 = lambda id, wait: with_wait(f"{COLLECTIONS_MAIN}/s3/{urllib.parse.quote(str(id), safe='')}", wait)
56
56
  COLLECTIONS_ID_ADD = lambda id, wait: with_wait(f"{COLLECTIONS_MAIN}/{urllib.parse.quote(str(id), safe='')}/add", wait)
@@ -239,3 +239,10 @@ KAFKA_SEND = f"{MANAGER_MAIN}/kafkaMsg"
239
239
  ## BatchController
240
240
  BATCH_MAIN = f"{API_VERSION}/batch"
241
241
  BATCH = BATCH_MAIN
242
+
243
+ ##### DM
244
+ DM_STREAM = lambda operationId, runId, bindId : f"stream/{operationId}/{runId}/{bindId}"
245
+ DM_CONTINUE = lambda operationId, runId, id: f"continue/{operationId}/{runId}/{id}"
246
+ DM_STATE = lambda operationId, runId, bindId, key, index : with_key_values(f"state/{operationId}/{runId}/{bindId}", {"key": key, "index": index})
247
+ DM_JOURNAL_LIST = lambda operationId, runId : f"journal/{operationId}/{runId}"
248
+ DM_JOURNAL = lambda operationId, runId, key, stream : with_key_values(f"journal/{operationId}/{runId}/{key}", {"stream": stream})
@@ -47,15 +47,24 @@ def set_host_port(host_port: str) -> None:
47
47
  Config.HOST_PORT = host_port
48
48
 
49
49
 
50
+ def set_dm_host_port(host_port: str) -> None:
51
+ """update host and port for malevich-dm, example: `http://localhost:8000/` """
52
+ assert len(host_port) > 0, "empty host port"
53
+ host_port = host_port if host_port[-1] == "/" else f"{host_port}/"
54
+ Config.DM_HOST_PORT = host_port
55
+
56
+
50
57
  def set_kafka_host_port(host_port: str) -> None:
51
58
  """update kafka host and port for malevich-kafka, example: `localhost:9092` """
52
59
  assert len(host_port) > 0, "empty host port"
53
60
  Config.KAFKA_HOST_PORT = host_port
54
61
 
55
62
 
56
- def set_conn_url(conn_url: str) -> None:
63
+ def set_conn_url(conn_url: str, dm_url: Optional[str] = None) -> None:
57
64
  """analogue set_host_port; update `conn_url` for malevich-core, example: `http://localhost:8080/` """
58
65
  set_host_port(conn_url)
66
+ if dm_url is not None:
67
+ set_dm_host_port(dm_url)
59
68
 
60
69
 
61
70
  def set_verbose(verbose: bool) -> None:
@@ -609,6 +618,7 @@ def get_collection(
609
618
  auth: Optional[AUTH] = None,
610
619
  conn_url: Optional[str] = None,
611
620
  batcher: Optional[Batcher] = None,
621
+ raw: Literal[False] = False,
612
622
  is_async: Literal[False] = False,
613
623
  ) -> ResultCollection:
614
624
  pass
@@ -623,11 +633,28 @@ def get_collection(
623
633
  auth: Optional[AUTH] = None,
624
634
  conn_url: Optional[str] = None,
625
635
  batcher: Optional[Batcher] = None,
636
+ raw: Literal[False] = False,
626
637
  is_async: Literal[True],
627
638
  ) -> Coroutine[Any, Any, ResultCollection]:
628
639
  pass
629
640
 
630
641
 
642
+ @overload
643
+ def get_collection(
644
+ id: str,
645
+ offset: int = 0,
646
+ limit: int = -1,
647
+ *,
648
+ auth: Optional[AUTH] = None,
649
+ conn_url: Optional[str] = None,
650
+ batcher: Optional[Batcher] = None,
651
+ raw: Literal[True],
652
+ is_async: Literal[False] = False,
653
+ ) -> Alias.Json:
654
+ pass
655
+
656
+
657
+ @overload
631
658
  def get_collection(
632
659
  id: str,
633
660
  offset: int = 0,
@@ -636,16 +663,32 @@ def get_collection(
636
663
  auth: Optional[AUTH] = None,
637
664
  conn_url: Optional[str] = None,
638
665
  batcher: Optional[Batcher] = None,
666
+ raw: Literal[True],
667
+ is_async: Literal[True],
668
+ ) -> Coroutine[Any, Any, Alias.Json]:
669
+ pass
670
+
671
+
672
+ def get_collection(
673
+ id: str,
674
+ offset: int = 0,
675
+ limit: int = -1,
676
+ *,
677
+ auth: Optional[AUTH] = None,
678
+ conn_url: Optional[str] = None,
679
+ batcher: Optional[Batcher] = None,
680
+ raw: bool = False,
639
681
  is_async: bool = False,
640
- ) -> Union[ResultCollection, Coroutine[Any, Any, ResultCollection]]:
682
+ ) -> Union[ResultCollection, Alias.Json, Coroutine[Any, Any, ResultCollection], Coroutine[Any, Any, Alias.Json]]:
641
683
  """return collection by `id`, pagination: unlimited - `limit` < 0"""
642
684
  if batcher is None:
643
685
  batcher = Config.BATCHER
644
686
  if batcher is not None:
645
- return batcher.add("getCollectionById", vars={"id": id, "offset": offset, "limit": limit}, result_model=ResultCollection)
687
+ result_model = None if raw else ResultCollection
688
+ return batcher.add("getCollectionById", vars={"id": id, "offset": offset, "limit": limit, "raw": raw}, result_model=result_model)
646
689
  if is_async:
647
- return f.get_collections_id_async(id, offset, limit, auth=auth, conn_url=conn_url)
648
- return f.get_collections_id(id, offset, limit, auth=auth, conn_url=conn_url)
690
+ return f.get_collections_id_async(id, offset, limit, raw, auth=auth, conn_url=conn_url)
691
+ return f.get_collections_id(id, offset, limit, raw, auth=auth, conn_url=conn_url)
649
692
 
650
693
 
651
694
  @overload
@@ -7161,7 +7204,7 @@ def task_run(
7161
7204
  conn_url: Optional[str] = None,
7162
7205
  batcher: Optional[Batcher] = None,
7163
7206
  is_async: Literal[False] = False,
7164
- ) -> Optional[Union[Alias.Id, AppLogs]]:
7207
+ ) -> Union[Alias.Id, AppLogs]:
7165
7208
  pass
7166
7209
 
7167
7210
 
@@ -7186,7 +7229,7 @@ def task_run(
7186
7229
  conn_url: Optional[str] = None,
7187
7230
  batcher: Optional[Batcher] = None,
7188
7231
  is_async: Literal[True],
7189
- ) -> Coroutine[Any, Any, Optional[Union[Alias.Id, AppLogs]]]:
7232
+ ) -> Coroutine[Any, Any, Union[Alias.Id, AppLogs]]:
7190
7233
  pass
7191
7234
 
7192
7235
 
@@ -7210,7 +7253,7 @@ def task_run(
7210
7253
  conn_url: Optional[str] = None,
7211
7254
  batcher: Optional[Batcher] = None,
7212
7255
  is_async: bool = False,
7213
- ) -> Union[Optional[Union[Alias.Id, AppLogs]], Coroutine[Any, Any, Optional[Union[Alias.Id, AppLogs]]]]:
7256
+ ) -> Union[Union[Alias.Id, AppLogs], Coroutine[Any, Any, Union[Alias.Id, AppLogs]]]:
7214
7257
  """run prepared task by `operation_id` with `cfg_id` and other overridden parameters
7215
7258
 
7216
7259
  Args:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: malevich-coretools
3
- Version: 0.3.66
3
+ Version: 0.3.68
4
4
  Author: Andrew Pogrebnoj
5
5
  Author-email: andrew@onjulius.co
6
6
  License-File: LICENSE
@@ -6,6 +6,7 @@ pyproject.toml
6
6
  requirements.txt
7
7
  setup.py
8
8
  malevich_coretools/__init__.py
9
+ malevich_coretools/dm_utils.py
9
10
  malevich_coretools/utils.py
10
11
  malevich_coretools.egg-info/PKG-INFO
11
12
  malevich_coretools.egg-info/SOURCES.txt
@@ -23,6 +24,7 @@ malevich_coretools/batch/__init__.py
23
24
  malevich_coretools/batch/utils.py
24
25
  malevich_coretools/funcs/__init__.py
25
26
  malevich_coretools/funcs/checks.py
27
+ malevich_coretools/funcs/dm_funcs.py
26
28
  malevich_coretools/funcs/funcs.py
27
29
  malevich_coretools/funcs/helpers.py
28
30
  malevich_coretools/secondary/__init__.py
@@ -1 +0,0 @@
1
- 0.3.66