datamaker-py 0.10.0__tar.gz → 0.11.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 (42) hide show
  1. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/PKG-INFO +34 -4
  2. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/README.md +33 -3
  3. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/pyproject.toml +1 -1
  4. datamaker_py-0.11.1/src/datamaker/__init__.py +12 -0
  5. datamaker_py-0.11.1/src/datamaker/error.py +94 -0
  6. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/generated/schema.py +954 -30
  7. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/main.py +105 -1
  8. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/__init__.py +2 -0
  9. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/base.py +10 -2
  10. datamaker_py-0.11.1/src/datamaker/routes/tosca.py +276 -0
  11. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/types.py +63 -4
  12. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker_py.egg-info/PKG-INFO +34 -4
  13. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker_py.egg-info/SOURCES.txt +3 -1
  14. datamaker_py-0.11.1/tests/test_tosca.py +438 -0
  15. datamaker_py-0.10.0/src/datamaker/__init__.py +0 -2
  16. datamaker_py-0.10.0/src/datamaker/error.py +0 -2
  17. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/LICENSE +0 -0
  18. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/setup.cfg +0 -0
  19. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/core.py +0 -0
  20. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/generated/__init__.py +0 -0
  21. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/api_keys.py +0 -0
  22. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/connections.py +0 -0
  23. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/custom_types.py +0 -0
  24. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/export_and_validation.py +0 -0
  25. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/folders_and_utils.py +0 -0
  26. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/generation.py +0 -0
  27. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/keymaps.py +0 -0
  28. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/masking_policies.py +0 -0
  29. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/plans.py +0 -0
  30. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/projects.py +0 -0
  31. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/scenario_files.py +0 -0
  32. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/sets.py +0 -0
  33. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/teams.py +0 -0
  34. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/templates.py +0 -0
  35. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/routes/users.py +0 -0
  36. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker/template.py +0 -0
  37. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker_py.egg-info/dependency_links.txt +0 -0
  38. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker_py.egg-info/requires.txt +0 -0
  39. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/src/datamaker_py.egg-info/top_level.txt +0 -0
  40. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/tests/test_integration.py +0 -0
  41. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/tests/test_main.py +0 -0
  42. {datamaker_py-0.10.0 → datamaker_py-0.11.1}/tests/test_routes.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datamaker-py
3
- Version: 0.10.0
3
+ Version: 0.11.1
4
4
  Summary: The official Python library for the Automators DataMaker API.
5
5
  Requires-Python: >=3.11
6
6
  Description-Content-Type: text/markdown
@@ -62,6 +62,35 @@ if __name__ == "__main__":
62
62
 
63
63
  ```
64
64
 
65
+ ## Push a set into Tosca Cloud
66
+
67
+ `push_tosca_dataset` creates or replaces a native Tosca Cloud data set from a saved
68
+ set, an input set version, a dataset or inline rows. A Tosca test step reads it with
69
+ `{TDM[<data set>][<subset>][<column>]}`.
70
+
71
+ ```python
72
+ from datamaker import DataMaker, ToscaDatasetSchemaChangedError
73
+
74
+ dm = DataMaker()
75
+
76
+ try:
77
+ result = dm.push_tosca_dataset(
78
+ integration_id,
79
+ name="Orders",
80
+ input_set_id="is_123", # or set_id=..., dataset_id=..., rows=[...]
81
+ on_existing="overwrite", # "fail" (default) | "overwrite" | "new"
82
+ )
83
+ print(result.dataset_id, result.rows_count, result.outcome, result.example)
84
+ except ToscaDatasetSchemaChangedError as e:
85
+ # The rows dropped a column the data set has. Pass on_schema_change="recreate"
86
+ # to delete and recreate it instead.
87
+ print("removed:", e.removed_columns, "added:", e.added_columns)
88
+ ```
89
+
90
+ An input set gets one Tosca subset per test case by default; `subsets_by` picks another
91
+ column or turns it off with `False`. `get_tosca_datasets(integration_id)` lists what a
92
+ space already holds.
93
+
65
94
  ## Autocomplete Types
66
95
 
67
96
  This SDK automatically generates TypeScript autocomplete definitions for use in the [datamaker application](https://github.com/automators/datamaker).
@@ -108,7 +137,8 @@ python scripts/generate_schema.py
108
137
  CI runs `python scripts/generate_schema.py --check` and fails if the committed
109
138
  types drift from the spec.
110
139
 
111
- Three schemas cannot currently be generated (`SetDetail`, `PackInstallListItem`,
112
- `SchemaGraphNavigation`): they are composed with `allOf`, which the generator
113
- merges away rather than emitting as a named class. Methods returning those keep
140
+ Five schemas cannot currently be generated (`SetDetail`, `DatasetDetail`,
141
+ `InputSetDetail`, `PackInstallListItem`, `SchemaGraphNavigation`): they are composed
142
+ with `allOf`, or only appear inside a union, so the generator does not emit them as a
143
+ named class. Methods returning those keep
114
144
  `Dict`. The generator script lists them explicitly and fails if the set grows.
@@ -51,6 +51,35 @@ if __name__ == "__main__":
51
51
 
52
52
  ```
53
53
 
54
+ ## Push a set into Tosca Cloud
55
+
56
+ `push_tosca_dataset` creates or replaces a native Tosca Cloud data set from a saved
57
+ set, an input set version, a dataset or inline rows. A Tosca test step reads it with
58
+ `{TDM[<data set>][<subset>][<column>]}`.
59
+
60
+ ```python
61
+ from datamaker import DataMaker, ToscaDatasetSchemaChangedError
62
+
63
+ dm = DataMaker()
64
+
65
+ try:
66
+ result = dm.push_tosca_dataset(
67
+ integration_id,
68
+ name="Orders",
69
+ input_set_id="is_123", # or set_id=..., dataset_id=..., rows=[...]
70
+ on_existing="overwrite", # "fail" (default) | "overwrite" | "new"
71
+ )
72
+ print(result.dataset_id, result.rows_count, result.outcome, result.example)
73
+ except ToscaDatasetSchemaChangedError as e:
74
+ # The rows dropped a column the data set has. Pass on_schema_change="recreate"
75
+ # to delete and recreate it instead.
76
+ print("removed:", e.removed_columns, "added:", e.added_columns)
77
+ ```
78
+
79
+ An input set gets one Tosca subset per test case by default; `subsets_by` picks another
80
+ column or turns it off with `False`. `get_tosca_datasets(integration_id)` lists what a
81
+ space already holds.
82
+
54
83
  ## Autocomplete Types
55
84
 
56
85
  This SDK automatically generates TypeScript autocomplete definitions for use in the [datamaker application](https://github.com/automators/datamaker).
@@ -97,7 +126,8 @@ python scripts/generate_schema.py
97
126
  CI runs `python scripts/generate_schema.py --check` and fails if the committed
98
127
  types drift from the spec.
99
128
 
100
- Three schemas cannot currently be generated (`SetDetail`, `PackInstallListItem`,
101
- `SchemaGraphNavigation`): they are composed with `allOf`, which the generator
102
- merges away rather than emitting as a named class. Methods returning those keep
129
+ Five schemas cannot currently be generated (`SetDetail`, `DatasetDetail`,
130
+ `InputSetDetail`, `PackInstallListItem`, `SchemaGraphNavigation`): they are composed
131
+ with `allOf`, or only appear inside a union, so the generator does not emit them as a
132
+ named class. Methods returning those keep
103
133
  `Dict`. The generator script lists them explicitly and fails if the set grows.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "datamaker-py"
7
- version = "0.10.0"
7
+ version = "0.11.1"
8
8
  description = "The official Python library for the Automators DataMaker API."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -0,0 +1,12 @@
1
+ from .main import DataMaker # noqa
2
+ from .template import Template # noqa
3
+ from .error import ( # noqa
4
+ DataMakerError,
5
+ DataMakerAPIError,
6
+ ReadOnlyConnectionError,
7
+ ToscaDatasetExistsError,
8
+ ToscaDatasetLockedError,
9
+ ToscaDatasetSchemaChangedError,
10
+ ToscaDatasetTooLargeError,
11
+ )
12
+ from .routes.tosca import ToscaDatasetPushResult # noqa
@@ -0,0 +1,94 @@
1
+ from typing import Any, List, Optional
2
+
3
+
4
+ class DataMakerError(Exception):
5
+ pass
6
+
7
+
8
+ class DataMakerAPIError(DataMakerError):
9
+ """The API answered with a non-2xx status.
10
+
11
+ Subclasses ``DataMakerError`` and keeps its message, so existing
12
+ ``except DataMakerError`` handlers are unaffected. Adds the status code and
13
+ the decoded JSON body (``None`` when the body was not JSON).
14
+ """
15
+
16
+ def __init__(self, message: str, status_code: int, body: Any = None):
17
+ super().__init__(message)
18
+ self.status_code = status_code
19
+ self.body = body
20
+
21
+ def _detail(self, key: str) -> Any:
22
+ return self.body.get(key) if isinstance(self.body, dict) else None
23
+
24
+
25
+ class ReadOnlyConnectionError(DataMakerAPIError):
26
+ """403: the connection is read-only, so DataMaker refused the write."""
27
+
28
+
29
+ class ToscaDatasetExistsError(DataMakerAPIError):
30
+ """409: a Tosca data set of that name exists and ``on_existing`` is "fail"."""
31
+
32
+ @property
33
+ def dataset_id(self) -> Optional[str]:
34
+ """The id of the data set that is already there."""
35
+ return self._detail("datasetId")
36
+
37
+
38
+ class ToscaDatasetLockedError(DataMakerAPIError):
39
+ """409: the data set is locked in Tosca Cloud, so it cannot be overwritten.
40
+
41
+ A test run or a "Test data - Expert" step holds it. Retry once it is
42
+ unlocked.
43
+ """
44
+
45
+ @property
46
+ def dataset_id(self) -> Optional[str]:
47
+ return self._detail("datasetId")
48
+
49
+
50
+ class ToscaDatasetSchemaChangedError(DataMakerAPIError):
51
+ """409: an overwrite would drop columns the Tosca data set has.
52
+
53
+ Tosca only overwrites in place when the columns match. Added columns are
54
+ handled by the API; a removed column is refused unless the push asks for
55
+ ``on_schema_change="recreate"``.
56
+ """
57
+
58
+ @property
59
+ def dataset_id(self) -> Optional[str]:
60
+ return self._detail("datasetId")
61
+
62
+ @property
63
+ def added_columns(self) -> List[str]:
64
+ return self._detail("added") or []
65
+
66
+ @property
67
+ def removed_columns(self) -> List[str]:
68
+ return self._detail("removed") or []
69
+
70
+
71
+ class ToscaDatasetTooLargeError(DataMakerAPIError):
72
+ """413: more rows or bytes than one push may write.
73
+
74
+ The row pair (``max_rows``, ``rows``) or the byte pair (``max_bytes``,
75
+ ``bytes``) is set, depending on which cap was hit. A set, input set or
76
+ dataset refused before its rows are loaded carries neither; the message
77
+ names the cap.
78
+ """
79
+
80
+ @property
81
+ def max_rows(self) -> Optional[int]:
82
+ return self._detail("maxRows")
83
+
84
+ @property
85
+ def rows(self) -> Optional[int]:
86
+ return self._detail("rows")
87
+
88
+ @property
89
+ def max_bytes(self) -> Optional[int]:
90
+ return self._detail("maxBytes")
91
+
92
+ @property
93
+ def bytes(self) -> Optional[int]:
94
+ return self._detail("bytes")