Skip to content

Commit 3974a16

Browse files
authored
Merge pull request #6 from RoboFinSystems/release/0.1.14
Release v0.1.14: Add CopyClient with async S3 import and progress tracking
2 parents dc12d30 + b10fd6f commit 3974a16

File tree

9 files changed

+993
-46
lines changed

9 files changed

+993
-46
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "robosystems-client"
3-
version = "0.1.13"
3+
version = "0.1.14"
44
description = "Python Client for RoboSystems financial graph database API"
55
readme = "README.md"
66
requires-python = ">=3.10"

robosystems_client/api/copy/copy_data_to_graph.py

Lines changed: 180 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Optional, Union
2+
from typing import Any, Optional, Union, cast
33

44
import httpx
55

@@ -50,11 +50,32 @@ def _get_kwargs(
5050

5151
def _parse_response(
5252
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
53-
) -> Optional[Union[CopyResponse, HTTPValidationError]]:
53+
) -> Optional[Union[Any, CopyResponse, HTTPValidationError]]:
5454
if response.status_code == 200:
5555
response_200 = CopyResponse.from_dict(response.json())
5656

5757
return response_200
58+
if response.status_code == 202:
59+
response_202 = cast(Any, None)
60+
return response_202
61+
if response.status_code == 400:
62+
response_400 = cast(Any, None)
63+
return response_400
64+
if response.status_code == 403:
65+
response_403 = cast(Any, None)
66+
return response_403
67+
if response.status_code == 408:
68+
response_408 = cast(Any, None)
69+
return response_408
70+
if response.status_code == 429:
71+
response_429 = cast(Any, None)
72+
return response_429
73+
if response.status_code == 500:
74+
response_500 = cast(Any, None)
75+
return response_500
76+
if response.status_code == 503:
77+
response_503 = cast(Any, None)
78+
return response_503
5879
if response.status_code == 422:
5980
response_422 = HTTPValidationError.from_dict(response.json())
6081

@@ -67,7 +88,7 @@ def _parse_response(
6788

6889
def _build_response(
6990
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
70-
) -> Response[Union[CopyResponse, HTTPValidationError]]:
91+
) -> Response[Union[Any, CopyResponse, HTTPValidationError]]:
7192
return Response(
7293
status_code=HTTPStatus(response.status_code),
7394
content=response.content,
@@ -83,7 +104,7 @@ def sync_detailed(
83104
body: Union["DataFrameCopyRequest", "S3CopyRequest", "URLCopyRequest"],
84105
authorization: Union[None, Unset, str] = UNSET,
85106
auth_token: Union[None, Unset, str] = UNSET,
86-
) -> Response[Union[CopyResponse, HTTPValidationError]]:
107+
) -> Response[Union[Any, CopyResponse, HTTPValidationError]]:
87108
"""Copy Data to Graph
88109
89110
Copy data from external sources into the graph database.
@@ -105,10 +126,46 @@ def sync_detailed(
105126
- Premium: 100GB max file size, 60 min timeout
106127
107128
**Copy Options:**
108-
- `ignore_errors`: Skip duplicate/invalid rows (enables upsert-like behavior)
129+
- `ignore_errors`: Skip duplicate/invalid rows (enables upsert-like behavior). Note: When enabled,
130+
row counts may not be accurately reported
109131
- `extended_timeout`: Use extended timeout for large datasets
110132
- `validate_schema`: Validate source schema against target table
111133
134+
**Asynchronous Execution with SSE:**
135+
For large data imports, this endpoint returns immediately with an operation ID
136+
and SSE monitoring endpoint. Connect to the returned stream URL for real-time updates:
137+
138+
```javascript
139+
const eventSource = new EventSource('/v1/operations/{operation_id}/stream');
140+
eventSource.onmessage = (event) => {
141+
const data = JSON.parse(event.data);
142+
console.log('Progress:', data.message);
143+
};
144+
```
145+
146+
**SSE Events Emitted:**
147+
- `operation_started`: Copy operation begins
148+
- `operation_progress`: Progress updates during data transfer
149+
- `operation_completed`: Copy successful with statistics
150+
- `operation_error`: Copy failed with error details
151+
152+
**SSE Connection Limits:**
153+
- Maximum 5 concurrent SSE connections per user
154+
- Rate limited to 10 new connections per minute
155+
- Automatic circuit breaker for Redis failures
156+
- Graceful degradation if event system unavailable
157+
158+
**Error Handling:**
159+
- `403 Forbidden`: Attempted copy to shared repository
160+
- `408 Request Timeout`: Operation exceeded timeout limit
161+
- `429 Too Many Requests`: Rate limit exceeded
162+
- `503 Service Unavailable`: Circuit breaker open or service unavailable
163+
- Clients should implement exponential backoff on errors
164+
165+
**Note:**
166+
Copy operations are FREE - no credit consumption required.
167+
All copy operations are performed asynchronously with progress monitoring.
168+
112169
Args:
113170
graph_id (str): Target graph identifier (user graphs only - shared repositories not
114171
allowed)
@@ -121,7 +178,7 @@ def sync_detailed(
121178
httpx.TimeoutException: If the request takes longer than Client.timeout.
122179
123180
Returns:
124-
Response[Union[CopyResponse, HTTPValidationError]]
181+
Response[Union[Any, CopyResponse, HTTPValidationError]]
125182
"""
126183

127184
kwargs = _get_kwargs(
@@ -145,7 +202,7 @@ def sync(
145202
body: Union["DataFrameCopyRequest", "S3CopyRequest", "URLCopyRequest"],
146203
authorization: Union[None, Unset, str] = UNSET,
147204
auth_token: Union[None, Unset, str] = UNSET,
148-
) -> Optional[Union[CopyResponse, HTTPValidationError]]:
205+
) -> Optional[Union[Any, CopyResponse, HTTPValidationError]]:
149206
"""Copy Data to Graph
150207
151208
Copy data from external sources into the graph database.
@@ -167,10 +224,46 @@ def sync(
167224
- Premium: 100GB max file size, 60 min timeout
168225
169226
**Copy Options:**
170-
- `ignore_errors`: Skip duplicate/invalid rows (enables upsert-like behavior)
227+
- `ignore_errors`: Skip duplicate/invalid rows (enables upsert-like behavior). Note: When enabled,
228+
row counts may not be accurately reported
171229
- `extended_timeout`: Use extended timeout for large datasets
172230
- `validate_schema`: Validate source schema against target table
173231
232+
**Asynchronous Execution with SSE:**
233+
For large data imports, this endpoint returns immediately with an operation ID
234+
and SSE monitoring endpoint. Connect to the returned stream URL for real-time updates:
235+
236+
```javascript
237+
const eventSource = new EventSource('/v1/operations/{operation_id}/stream');
238+
eventSource.onmessage = (event) => {
239+
const data = JSON.parse(event.data);
240+
console.log('Progress:', data.message);
241+
};
242+
```
243+
244+
**SSE Events Emitted:**
245+
- `operation_started`: Copy operation begins
246+
- `operation_progress`: Progress updates during data transfer
247+
- `operation_completed`: Copy successful with statistics
248+
- `operation_error`: Copy failed with error details
249+
250+
**SSE Connection Limits:**
251+
- Maximum 5 concurrent SSE connections per user
252+
- Rate limited to 10 new connections per minute
253+
- Automatic circuit breaker for Redis failures
254+
- Graceful degradation if event system unavailable
255+
256+
**Error Handling:**
257+
- `403 Forbidden`: Attempted copy to shared repository
258+
- `408 Request Timeout`: Operation exceeded timeout limit
259+
- `429 Too Many Requests`: Rate limit exceeded
260+
- `503 Service Unavailable`: Circuit breaker open or service unavailable
261+
- Clients should implement exponential backoff on errors
262+
263+
**Note:**
264+
Copy operations are FREE - no credit consumption required.
265+
All copy operations are performed asynchronously with progress monitoring.
266+
174267
Args:
175268
graph_id (str): Target graph identifier (user graphs only - shared repositories not
176269
allowed)
@@ -183,7 +276,7 @@ def sync(
183276
httpx.TimeoutException: If the request takes longer than Client.timeout.
184277
185278
Returns:
186-
Union[CopyResponse, HTTPValidationError]
279+
Union[Any, CopyResponse, HTTPValidationError]
187280
"""
188281

189282
return sync_detailed(
@@ -202,7 +295,7 @@ async def asyncio_detailed(
202295
body: Union["DataFrameCopyRequest", "S3CopyRequest", "URLCopyRequest"],
203296
authorization: Union[None, Unset, str] = UNSET,
204297
auth_token: Union[None, Unset, str] = UNSET,
205-
) -> Response[Union[CopyResponse, HTTPValidationError]]:
298+
) -> Response[Union[Any, CopyResponse, HTTPValidationError]]:
206299
"""Copy Data to Graph
207300
208301
Copy data from external sources into the graph database.
@@ -224,10 +317,46 @@ async def asyncio_detailed(
224317
- Premium: 100GB max file size, 60 min timeout
225318
226319
**Copy Options:**
227-
- `ignore_errors`: Skip duplicate/invalid rows (enables upsert-like behavior)
320+
- `ignore_errors`: Skip duplicate/invalid rows (enables upsert-like behavior). Note: When enabled,
321+
row counts may not be accurately reported
228322
- `extended_timeout`: Use extended timeout for large datasets
229323
- `validate_schema`: Validate source schema against target table
230324
325+
**Asynchronous Execution with SSE:**
326+
For large data imports, this endpoint returns immediately with an operation ID
327+
and SSE monitoring endpoint. Connect to the returned stream URL for real-time updates:
328+
329+
```javascript
330+
const eventSource = new EventSource('/v1/operations/{operation_id}/stream');
331+
eventSource.onmessage = (event) => {
332+
const data = JSON.parse(event.data);
333+
console.log('Progress:', data.message);
334+
};
335+
```
336+
337+
**SSE Events Emitted:**
338+
- `operation_started`: Copy operation begins
339+
- `operation_progress`: Progress updates during data transfer
340+
- `operation_completed`: Copy successful with statistics
341+
- `operation_error`: Copy failed with error details
342+
343+
**SSE Connection Limits:**
344+
- Maximum 5 concurrent SSE connections per user
345+
- Rate limited to 10 new connections per minute
346+
- Automatic circuit breaker for Redis failures
347+
- Graceful degradation if event system unavailable
348+
349+
**Error Handling:**
350+
- `403 Forbidden`: Attempted copy to shared repository
351+
- `408 Request Timeout`: Operation exceeded timeout limit
352+
- `429 Too Many Requests`: Rate limit exceeded
353+
- `503 Service Unavailable`: Circuit breaker open or service unavailable
354+
- Clients should implement exponential backoff on errors
355+
356+
**Note:**
357+
Copy operations are FREE - no credit consumption required.
358+
All copy operations are performed asynchronously with progress monitoring.
359+
231360
Args:
232361
graph_id (str): Target graph identifier (user graphs only - shared repositories not
233362
allowed)
@@ -240,7 +369,7 @@ async def asyncio_detailed(
240369
httpx.TimeoutException: If the request takes longer than Client.timeout.
241370
242371
Returns:
243-
Response[Union[CopyResponse, HTTPValidationError]]
372+
Response[Union[Any, CopyResponse, HTTPValidationError]]
244373
"""
245374

246375
kwargs = _get_kwargs(
@@ -262,7 +391,7 @@ async def asyncio(
262391
body: Union["DataFrameCopyRequest", "S3CopyRequest", "URLCopyRequest"],
263392
authorization: Union[None, Unset, str] = UNSET,
264393
auth_token: Union[None, Unset, str] = UNSET,
265-
) -> Optional[Union[CopyResponse, HTTPValidationError]]:
394+
) -> Optional[Union[Any, CopyResponse, HTTPValidationError]]:
266395
"""Copy Data to Graph
267396
268397
Copy data from external sources into the graph database.
@@ -284,10 +413,46 @@ async def asyncio(
284413
- Premium: 100GB max file size, 60 min timeout
285414
286415
**Copy Options:**
287-
- `ignore_errors`: Skip duplicate/invalid rows (enables upsert-like behavior)
416+
- `ignore_errors`: Skip duplicate/invalid rows (enables upsert-like behavior). Note: When enabled,
417+
row counts may not be accurately reported
288418
- `extended_timeout`: Use extended timeout for large datasets
289419
- `validate_schema`: Validate source schema against target table
290420
421+
**Asynchronous Execution with SSE:**
422+
For large data imports, this endpoint returns immediately with an operation ID
423+
and SSE monitoring endpoint. Connect to the returned stream URL for real-time updates:
424+
425+
```javascript
426+
const eventSource = new EventSource('/v1/operations/{operation_id}/stream');
427+
eventSource.onmessage = (event) => {
428+
const data = JSON.parse(event.data);
429+
console.log('Progress:', data.message);
430+
};
431+
```
432+
433+
**SSE Events Emitted:**
434+
- `operation_started`: Copy operation begins
435+
- `operation_progress`: Progress updates during data transfer
436+
- `operation_completed`: Copy successful with statistics
437+
- `operation_error`: Copy failed with error details
438+
439+
**SSE Connection Limits:**
440+
- Maximum 5 concurrent SSE connections per user
441+
- Rate limited to 10 new connections per minute
442+
- Automatic circuit breaker for Redis failures
443+
- Graceful degradation if event system unavailable
444+
445+
**Error Handling:**
446+
- `403 Forbidden`: Attempted copy to shared repository
447+
- `408 Request Timeout`: Operation exceeded timeout limit
448+
- `429 Too Many Requests`: Rate limit exceeded
449+
- `503 Service Unavailable`: Circuit breaker open or service unavailable
450+
- Clients should implement exponential backoff on errors
451+
452+
**Note:**
453+
Copy operations are FREE - no credit consumption required.
454+
All copy operations are performed asynchronously with progress monitoring.
455+
291456
Args:
292457
graph_id (str): Target graph identifier (user graphs only - shared repositories not
293458
allowed)
@@ -300,7 +465,7 @@ async def asyncio(
300465
httpx.TimeoutException: If the request takes longer than Client.timeout.
301466
302467
Returns:
303-
Union[CopyResponse, HTTPValidationError]
468+
Union[Any, CopyResponse, HTTPValidationError]
304469
"""
305470

306471
return (

0 commit comments

Comments
 (0)