dynamoxy 0.5.0__tar.gz → 0.5.1__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.
Files changed (77) hide show
  1. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/Cargo.lock +2 -2
  2. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/Cargo.toml +2 -2
  3. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/PKG-INFO +1 -1
  4. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-py/src/client.rs +107 -43
  5. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-py/src/convert.rs +384 -102
  6. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-py/src/errors.rs +19 -18
  7. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-py/src/lib.rs +9 -10
  8. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-py/src/runtime.rs +158 -42
  9. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/AGENT_GUIDE.md +59 -7
  10. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/__init__.py +3 -0
  11. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/_pydantic.py +33 -4
  12. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/errors.py +30 -0
  13. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/models.py +156 -46
  14. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/query.py +137 -16
  15. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/repository.py +107 -37
  16. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/schema.py +166 -23
  17. dynamoxy-0.5.1/python/dynamoxy/streams.py +469 -0
  18. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/LICENSE +0 -0
  19. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/README.md +0 -0
  20. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/Cargo.toml +0 -0
  21. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/README.md +0 -0
  22. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/aws/convert.rs +0 -0
  23. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/aws/errors.rs +0 -0
  24. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/aws/mod.rs +0 -0
  25. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/memory/admin.rs +0 -0
  26. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/memory/batch.rs +0 -0
  27. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/memory/items.rs +0 -0
  28. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/memory/mod.rs +0 -0
  29. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/memory/partiql.rs +0 -0
  30. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/memory/query.rs +0 -0
  31. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/memory/table.rs +0 -0
  32. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/memory/tests.rs +0 -0
  33. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/memory/transact.rs +0 -0
  34. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/backend/mod.rs +0 -0
  35. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/client/tests.rs +0 -0
  36. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/client.rs +0 -0
  37. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/config.rs +0 -0
  38. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/error.rs +0 -0
  39. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/events.rs +0 -0
  40. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/expr/ast.rs +0 -0
  41. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/expr/eval.rs +0 -0
  42. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/expr/mod.rs +0 -0
  43. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/expr/parser.rs +0 -0
  44. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/expr/projection.rs +0 -0
  45. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/expr/reserved.rs +0 -0
  46. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/expr/tests.rs +0 -0
  47. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/expr/update.rs +0 -0
  48. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/lib.rs +0 -0
  49. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/metrics.rs +0 -0
  50. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/retry.rs +0 -0
  51. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/types/mod.rs +0 -0
  52. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/types/ops.rs +0 -0
  53. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/types/schema.rs +0 -0
  54. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/value/mod.rs +0 -0
  55. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/value/number.rs +0 -0
  56. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/src/value/size.rs +0 -0
  57. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-core/tests/emulator.rs +0 -0
  58. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/crates/dynamoxy-py/Cargo.toml +0 -0
  59. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/pyproject.toml +0 -0
  60. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/__main__.py +0 -0
  61. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/_core.pyi +0 -0
  62. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/_utils.py +0 -0
  63. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/attributes.py +0 -0
  64. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/batch.py +0 -0
  65. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/client.py +0 -0
  66. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/codecs.py +0 -0
  67. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/collection.py +0 -0
  68. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/constraints.py +0 -0
  69. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/events.py +0 -0
  70. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/expressions.py +0 -0
  71. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/middleware.py +0 -0
  72. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/py.typed +0 -0
  73. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/results.py +0 -0
  74. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/table.py +0 -0
  75. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/telemetry.py +0 -0
  76. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/testing.py +0 -0
  77. {dynamoxy-0.5.0 → dynamoxy-0.5.1}/python/dynamoxy/transactions.py +0 -0
@@ -658,7 +658,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
658
658
 
659
659
  [[package]]
660
660
  name = "dynamoxy-core"
661
- version = "0.5.0"
661
+ version = "0.5.1"
662
662
  dependencies = [
663
663
  "async-trait",
664
664
  "aws-config",
@@ -675,7 +675,7 @@ dependencies = [
675
675
 
676
676
  [[package]]
677
677
  name = "dynamoxy-py"
678
- version = "0.5.0"
678
+ version = "0.5.1"
679
679
  dependencies = [
680
680
  "dynamoxy-core",
681
681
  "parking_lot",
@@ -4,7 +4,7 @@ members = ["crates/dynamoxy-core", "crates/dynamoxy-py"]
4
4
 
5
5
  # The single version of the project: the Python package takes it from the binding crate.
6
6
  [workspace.package]
7
- version = "0.5.0"
7
+ version = "0.5.1"
8
8
  edition = "2024"
9
9
  rust-version = "1.99"
10
10
  license = "MIT"
@@ -13,7 +13,7 @@ homepage = "https://github.com/kalaspuff/dynamoxy"
13
13
  authors = ["Carl Oscar Aaro <hello@carloscar.com>"]
14
14
 
15
15
  [workspace.dependencies]
16
- dynamoxy-core = { path = "crates/dynamoxy-core", version = "0.5.0" }
16
+ dynamoxy-core = { path = "crates/dynamoxy-core", version = "0.5.1" }
17
17
  async-trait = "0.1"
18
18
  aws-config = { version = "1.12", features = ["behavior-version-latest"] }
19
19
  aws-credential-types = { version = "1.3", features = ["hardcoded-credentials"] }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dynamoxy
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Framework :: AsyncIO
6
6
  Classifier: Framework :: Pydantic :: 2
@@ -7,13 +7,13 @@
7
7
 
8
8
  use std::collections::BTreeMap;
9
9
  use std::future::Future;
10
- use std::time::Duration;
10
+ use std::time::{Duration, Instant};
11
11
 
12
12
  use dynamoxy_core::backend::memory::{Fault, FaultKind, MemoryBackend};
13
13
  use dynamoxy_core::events::{Event, EventKind};
14
14
  use dynamoxy_core::metrics::LATENCY_BUCKETS_MS;
15
15
  use dynamoxy_core::types::*;
16
- use dynamoxy_core::{Call, Client, ClientConfig};
16
+ use dynamoxy_core::{Call, Client, ClientConfig, Item};
17
17
  use pyo3::IntoPyObjectExt;
18
18
  use pyo3::exceptions::PyTypeError;
19
19
  use pyo3::intern;
@@ -22,9 +22,9 @@ use pyo3::types::{PyDict, PyList, PyString};
22
22
  use pythonize::depythonize;
23
23
 
24
24
  use crate::convert::{
25
- PyItem, PyStrMap, PyValueList, PyValues, as_dict, backup_description, backup_details, backup_summary, capacities,
26
- collection_metrics, collection_metrics_map, continuous_backups, items_to_py, keys_and_attributes,
27
- optional_capacity, optional_item, py_to_item, stats, table_description, ttl_to_py, write_request_to_py,
25
+ ItemsInSteps, PyItem, PyStrMap, PyValueList, PyValues, as_dict, backup_description, backup_details, backup_summary,
26
+ capacities, collection_metrics, collection_metrics_map, continuous_backups, keys_and_attributes, optional_capacity,
27
+ optional_item, py_to_item, stats, table_description, ttl_to_py, write_request_to_py,
28
28
  };
29
29
  use crate::errors::{ConfigurationError, ShutdownError, ValidationError, call_error_in, error_in, to_py_err};
30
30
  use crate::runtime::{Deferred, future_into_py, future_into_py_in, future_into_py_inline};
@@ -75,6 +75,32 @@ fn finish<T: Send + 'static>(
75
75
  })
76
76
  }
77
77
 
78
+ /// [`finish`] for outputs that hold lists of items: `lists` takes them out of the output, and
79
+ /// they are converted in steps (see [`Deferred::in_steps`]) before `convert` builds the rest
80
+ /// with the converted lists, in the same order.
81
+ fn finish_in_steps<T: Send + 'static>(
82
+ call: Call<T>,
83
+ lists: impl FnOnce(&mut T) -> Vec<Vec<Item>>,
84
+ convert: impl for<'py> FnOnce(Python<'py>, Vec<Bound<'py, PyList>>, T) -> PyResult<Py<PyAny>> + Send + 'static,
85
+ ) -> Deferred {
86
+ let call_stats = call.stats;
87
+ let mut output = match call.result {
88
+ Ok(output) => output,
89
+ Err(error) => return Deferred::new(move |py| Err(call_error_in(py, error, &call_stats))),
90
+ };
91
+ let mut items = ItemsInSteps::new(lists(&mut output));
92
+ let mut rest = Some((output, convert));
93
+ Deferred::in_steps(move |py: Python<'_>, deadline: Instant| {
94
+ let lists = match items.step(py, deadline) {
95
+ Ok(Some(lists)) => lists,
96
+ Ok(None) => return None,
97
+ Err(error) => return Some(Err(error)),
98
+ };
99
+ let (output, convert) = rest.take()?;
100
+ Some(convert(py, lists, output).and_then(|value| (value, stats(&call_stats)).into_py_any(py)))
101
+ })
102
+ }
103
+
78
104
  /// The error that left requests of a managed batch unprocessed, as an exception object, or `None`.
79
105
  fn batch_error(py: Python<'_>, error: Option<dynamoxy_core::Error>) -> Bound<'_, PyAny> {
80
106
  match error {
@@ -103,11 +129,17 @@ fn write_output(py: Python<'_>, output: WriteItemOutput) -> PyResult<Py<PyAny>>
103
129
  )
104
130
  }
105
131
 
106
- fn query_output(py: Python<'_>, output: QueryOutput) -> PyResult<Py<PyAny>> {
132
+ /// A `Query` or `Scan` page, its items converted in steps.
133
+ fn finish_query(call: Call<QueryOutput>) -> Deferred {
134
+ finish_in_steps(call, |output| vec![std::mem::take(&mut output.items)], query_output)
135
+ }
136
+
137
+ fn query_output(py: Python<'_>, mut lists: Vec<Bound<'_, PyList>>, output: QueryOutput) -> PyResult<Py<PyAny>> {
138
+ let items = lists.pop().unwrap_or_else(|| PyList::empty(py));
107
139
  dict(
108
140
  py,
109
141
  &[
110
- (intern!(py, "items"), items_to_py(py, &output.items)?.into_any()),
142
+ (intern!(py, "items"), items.into_any()),
111
143
  (intern!(py, "count"), output.count.into_pyobject(py)?.into_any()),
112
144
  (intern!(py, "scanned_count"), output.scanned_count.into_pyobject(py)?.into_any()),
113
145
  (intern!(py, "last_evaluated_key"), optional_item(py, output.last_evaluated_key.as_ref())?),
@@ -326,11 +358,26 @@ fn write_request(kind: &str, item: &Bound<'_, PyAny>) -> PyResult<WriteRequest>
326
358
  }
327
359
  }
328
360
 
329
- fn batch_get_output(py: Python<'_>, output: BatchGetItemOutput) -> PyResult<Py<PyAny>> {
361
+ /// The items of each table of a `BatchGetItem` answer, taken out (to convert in steps).
362
+ fn take_responses(responses: &mut BTreeMap<String, Vec<Item>>) -> Vec<Vec<Item>> {
363
+ responses.values_mut().map(std::mem::take).collect()
364
+ }
365
+
366
+ /// Tables with their converted items (in the order of [`take_responses`]).
367
+ fn responses_dict<'py>(
368
+ py: Python<'py>,
369
+ tables: &BTreeMap<String, Vec<Item>>,
370
+ lists: Vec<Bound<'py, PyList>>,
371
+ ) -> PyResult<Bound<'py, PyDict>> {
330
372
  let responses = PyDict::new(py);
331
- for (table, items) in &output.responses {
332
- responses.set_item(table, items_to_py(py, items)?)?;
373
+ for (table, items) in tables.keys().zip(lists) {
374
+ responses.set_item(table, items)?;
333
375
  }
376
+ Ok(responses)
377
+ }
378
+
379
+ fn batch_get_output(py: Python<'_>, lists: Vec<Bound<'_, PyList>>, output: BatchGetItemOutput) -> PyResult<Py<PyAny>> {
380
+ let responses = responses_dict(py, &output.responses, lists)?;
334
381
  let unprocessed = PyDict::new(py);
335
382
  for (table, keys) in &output.unprocessed_keys {
336
383
  unprocessed.set_item(table, keys_and_attributes(py, keys)?)?;
@@ -705,7 +752,7 @@ impl PyCoreClient {
705
752
  "return_consumed_capacity"
706
753
  )?,
707
754
  };
708
- self.run(py, async move { finish(client.query(input).await, query_output) })
755
+ self.run(py, async move { finish_query(client.query(input).await) })
709
756
  }
710
757
 
711
758
  /// `Scan` (one page).
@@ -748,7 +795,7 @@ impl PyCoreClient {
748
795
  "return_consumed_capacity"
749
796
  )?,
750
797
  };
751
- self.run(py, async move { finish(client.scan(input).await, query_output) })
798
+ self.run(py, async move { finish_query(client.scan(input).await) })
752
799
  }
753
800
 
754
801
  /// `BatchGetItem`: one request (at most 100 keys). See `batch_get` for any number of keys.
@@ -771,7 +818,13 @@ impl PyCoreClient {
771
818
  "return_consumed_capacity"
772
819
  )?,
773
820
  };
774
- self.run(py, async move { finish(client.batch_get_item(input).await, batch_get_output) })
821
+ self.run(py, async move {
822
+ finish_in_steps(
823
+ client.batch_get_item(input).await,
824
+ |output| take_responses(&mut output.responses),
825
+ batch_get_output,
826
+ )
827
+ })
775
828
  }
776
829
 
777
830
  /// `BatchWriteItem`: one request (at most 25 writes) of `("put", item)` / `("delete", key)`
@@ -843,25 +896,27 @@ impl PyCoreClient {
843
896
  let request_items = request_items.into_iter().map(|(table, keys)| (table, keys.into_core())).collect();
844
897
  let capacity = constant!(return_consumed_capacity, ReturnConsumedCapacity, "return_consumed_capacity")?;
845
898
  self.run(py, async move {
846
- finish(client.batch_get(request_items, capacity).await, |py, output| {
847
- let items = PyDict::new(py);
848
- for (table, found) in &output.items {
849
- items.set_item(table, items_to_py(py, found)?)?;
850
- }
851
- let unprocessed = PyDict::new(py);
852
- for (table, keys) in &output.unprocessed {
853
- unprocessed.set_item(table, keys_and_attributes(py, keys)?)?;
854
- }
855
- dict(
856
- py,
857
- &[
858
- (intern!(py, "items"), items.into_any()),
859
- (intern!(py, "unprocessed_keys"), unprocessed.into_any()),
860
- (intern!(py, "consumed_capacity"), capacities(py, &output.consumed_capacity)?.into_any()),
861
- (intern!(py, "error"), batch_error(py, output.error)),
862
- ],
863
- )
864
- })
899
+ let output = client.batch_get(request_items, capacity).await;
900
+ finish_in_steps(
901
+ output,
902
+ |output| take_responses(&mut output.items),
903
+ |py, lists, output| {
904
+ let items = responses_dict(py, &output.items, lists)?;
905
+ let unprocessed = PyDict::new(py);
906
+ for (table, keys) in &output.unprocessed {
907
+ unprocessed.set_item(table, keys_and_attributes(py, keys)?)?;
908
+ }
909
+ dict(
910
+ py,
911
+ &[
912
+ (intern!(py, "items"), items.into_any()),
913
+ (intern!(py, "unprocessed_keys"), unprocessed.into_any()),
914
+ (intern!(py, "consumed_capacity"), capacities(py, &output.consumed_capacity)?.into_any()),
915
+ (intern!(py, "error"), batch_error(py, output.error)),
916
+ ],
917
+ )
918
+ },
919
+ )
865
920
  })
866
921
  }
867
922
 
@@ -1016,17 +1071,26 @@ impl PyCoreClient {
1016
1071
  )?,
1017
1072
  };
1018
1073
  self.run(py, async move {
1019
- finish(client.execute_statement(input).await, |py, output| {
1020
- dict(
1021
- py,
1022
- &[
1023
- (intern!(py, "items"), items_to_py(py, &output.items)?.into_any()),
1024
- (intern!(py, "next_token"), output.next_token.into_pyobject(py)?.into_any()),
1025
- (intern!(py, "last_evaluated_key"), optional_item(py, output.last_evaluated_key.as_ref())?),
1026
- (intern!(py, "consumed_capacity"), optional_capacity(py, output.consumed_capacity.as_ref())?),
1027
- ],
1028
- )
1029
- })
1074
+ let output = client.execute_statement(input).await;
1075
+ finish_in_steps(
1076
+ output,
1077
+ |output| vec![std::mem::take(&mut output.items)],
1078
+ |py, mut lists, output| {
1079
+ let items = lists.pop().unwrap_or_else(|| PyList::empty(py));
1080
+ dict(
1081
+ py,
1082
+ &[
1083
+ (intern!(py, "items"), items.into_any()),
1084
+ (intern!(py, "next_token"), output.next_token.into_pyobject(py)?.into_any()),
1085
+ (intern!(py, "last_evaluated_key"), optional_item(py, output.last_evaluated_key.as_ref())?),
1086
+ (
1087
+ intern!(py, "consumed_capacity"),
1088
+ optional_capacity(py, output.consumed_capacity.as_ref())?,
1089
+ ),
1090
+ ],
1091
+ )
1092
+ },
1093
+ )
1030
1094
  })
1031
1095
  }
1032
1096