dq-export-connector 0.1.0.dev18__tar.gz → 0.1.0.dev19__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 (65) hide show
  1. dq_export_connector-0.1.0.dev19/.gitignore +63 -0
  2. dq_export_connector-0.1.0.dev19/PKG-INFO +58 -0
  3. dq_export_connector-0.1.0.dev19/README.md +47 -0
  4. dq_export_connector-0.1.0.dev18/dq_export_connector/_models/snap_validation_result.py → dq_export_connector-0.1.0.dev19/dq_export_connector/_models/application_message.py +7 -12
  5. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/_models/bucket_validation_result.py +8 -5
  6. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/_models/export_connector_credentials.py +2 -25
  7. dq_export_connector-0.1.0.dev19/dq_export_connector/_models/export_receipt.py +147 -0
  8. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/_models/export_worker_config.py +8 -100
  9. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/bucket/export.py +3 -3
  10. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/errors.py +7 -32
  11. dq_export_connector-0.1.0.dev19/dq_export_connector/redact.py +52 -0
  12. dq_export_connector-0.1.0.dev19/dq_export_connector/report.py +47 -0
  13. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/runner.py +49 -95
  14. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/pyproject.toml +3 -11
  15. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/scripts/codegen-models.sh +1 -1
  16. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/tests/test_live_buckets.py +19 -13
  17. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/tests/test_runner.py +141 -105
  18. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/uv.lock +4 -227
  19. dq_export_connector-0.1.0.dev18/.gitignore +0 -5
  20. dq_export_connector-0.1.0.dev18/PKG-INFO +0 -151
  21. dq_export_connector-0.1.0.dev18/README.md +0 -138
  22. dq_export_connector-0.1.0.dev18/dq_export_connector/_models/export_report.py +0 -290
  23. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/classify.py +0 -98
  24. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/http.py +0 -237
  25. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/identifiers.py +0 -121
  26. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/inputs.py +0 -80
  27. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/oauth.py +0 -321
  28. dq_export_connector-0.1.0.dev18/dq_export_connector/audience/sync.py +0 -313
  29. dq_export_connector-0.1.0.dev18/dq_export_connector/bucket/__init__.py +0 -0
  30. dq_export_connector-0.1.0.dev18/dq_export_connector/redact.py +0 -105
  31. dq_export_connector-0.1.0.dev18/dq_export_connector/report.py +0 -44
  32. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/__init__.py +0 -0
  33. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/client.py +0 -143
  34. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/destination.py +0 -154
  35. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/export.py +0 -136
  36. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/session.py +0 -70
  37. dq_export_connector-0.1.0.dev18/dq_export_connector/snap/validate.py +0 -38
  38. dq_export_connector-0.1.0.dev18/scripts/_local.py +0 -74
  39. dq_export_connector-0.1.0.dev18/scripts/consent.py +0 -99
  40. dq_export_connector-0.1.0.dev18/scripts/run_local.py +0 -46
  41. dq_export_connector-0.1.0.dev18/tests/__init__.py +0 -0
  42. dq_export_connector-0.1.0.dev18/tests/conftest.py +0 -37
  43. dq_export_connector-0.1.0.dev18/tests/fakes/__init__.py +0 -0
  44. dq_export_connector-0.1.0.dev18/tests/fakes/snap_fake.py +0 -256
  45. dq_export_connector-0.1.0.dev18/tests/test_http_and_oauth.py +0 -398
  46. dq_export_connector-0.1.0.dev18/tests/test_identifiers_and_inputs.py +0 -118
  47. dq_export_connector-0.1.0.dev18/tests/test_live_snap.py +0 -115
  48. dq_export_connector-0.1.0.dev18/tests/test_scripts.py +0 -22
  49. dq_export_connector-0.1.0.dev18/tests/test_snap_runner.py +0 -592
  50. dq_export_connector-0.1.0.dev18/tests/test_sync_input.py +0 -171
  51. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/.python-version +0 -0
  52. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/__init__.py +0 -0
  53. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/_models/__init__.py +0 -0
  54. {dq_export_connector-0.1.0.dev18/dq_export_connector/audience → dq_export_connector-0.1.0.dev19/dq_export_connector/bucket}/__init__.py +0 -0
  55. {dq_export_connector-0.1.0.dev18/dq_export_connector → dq_export_connector-0.1.0.dev19/dq_export_connector/bucket}/datasets.py +0 -0
  56. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/bucket/paths.py +0 -0
  57. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/bucket/store.py +0 -0
  58. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/bucket/upload.py +0 -0
  59. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/bucket/validate.py +0 -0
  60. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/dq_export_connector/log.py +0 -0
  61. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/tests/test_models_are_current.py +0 -0
  62. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/tests/test_paths.py +0 -0
  63. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/tests/test_redact.py +0 -0
  64. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/tests/test_store.py +0 -0
  65. {dq_export_connector-0.1.0.dev18 → dq_export_connector-0.1.0.dev19}/tests/test_upload.py +0 -0
@@ -0,0 +1,63 @@
1
+ .DS_Store
2
+ **/build/
3
+ .idea/
4
+ .vscode/*
5
+ !.vscode/tasks.json
6
+ target/
7
+ node_modules/
8
+ result
9
+ /result-*
10
+ **/*.o
11
+ env
12
+ venv
13
+ .venv
14
+ .direnv
15
+ **/perf.data*
16
+ infra/packages/hadoop/binary.tar.gz
17
+ .terraform
18
+ config.tf.json
19
+ *.tfstate.*
20
+ *.tfstate
21
+ **/.deploy-gc
22
+ .vagrant
23
+ .pnpm-debug.log
24
+ .yarn
25
+ __pycache__
26
+ trusted/dcr-compiler/ddc/src/data_lab/**/*.png
27
+ trusted/dcr-compiler/ddc/src/data_lab/**/*.json
28
+ e2e-tests/frontend/confidence-check-config.json
29
+ .terraform.lock.hcl
30
+ dmp/analysis-scripts/results/*
31
+ .env
32
+ !tools/dqdev/internal/target/
33
+ docusaurus/style-guide.md
34
+ **/.claude/settings.local.json
35
+ **/.claude/agent-memory-local/
36
+ .claude/*.lock
37
+ .claude/worktrees/
38
+ **/CLAUDE.local.md
39
+ **/*.parquet/**
40
+ .pnpm-store/
41
+ .turbo/
42
+
43
+ # Agentic-coding workflow (local, not part of this repo)
44
+ .workflow/
45
+ .workflow-backup-*
46
+
47
+ # Local-only Google Ads/DV360 test scripts (kept out of the PR)
48
+ dmp/dqdmp/scripts/
49
+
50
+ # Playwright MCP screenshots (local only)
51
+ .playwright-mcp/
52
+
53
+ # Claude Design sync build artifacts (local only).
54
+ **/.design-sync/sb-reference/
55
+ **/.design-sync/learnings/
56
+ **/.design-sync/.cache/
57
+ **/.design-sync/node_modules
58
+ .ds-sync/
59
+ ds-bundle/
60
+
61
+ # DMP creation-prefill tests (local only)
62
+ avato-backend/frontend/decentriq-platform/src/features/dmp/models/creationPrefill.test.ts
63
+ avato-backend/frontend/decentriq-platform/src/features/dmp/utils/creationPrefill/*.test.ts
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.5
2
+ Name: dq-export-connector
3
+ Version: 0.1.0.dev19
4
+ Summary: Worker logic for the Export Connector DCR.
5
+ Author: Decentriq
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: pydantic<3,>=2.14
8
+ Provides-Extra: bucket
9
+ Requires-Dist: obstore<0.12,>=0.11.1; extra == 'bucket'
10
+ Description-Content-Type: text/markdown
11
+
12
+ # dq-export-connector
13
+
14
+ Worker logic for the **Export Connector DCR**: one package for every
15
+ Connector Kind, each in its own sub-package with an extra of the same name for
16
+ its dependencies. The **bucket** kind uploads each Input's dataset to S3, Azure
17
+ Blob or GCS through [`obstore`](https://developmentseed.org/obstore/).
18
+
19
+ ddc pins this package by hash in a fully locked `requirements.txt` and runs
20
+ `dq_export_connector.runner.main` in the task's Python environment. It is
21
+ published to PyPI, since the compiled graph installs it from there.
22
+
23
+ - `dq_export_connector.runner`: the entry point. Reads `/input/config.json`
24
+ and `/input/credentials.json`, sets up logging, and dispatches on the
25
+ Connector Kind and the action, then writes what the action reports: a
26
+ connection test's result into `/output`, and an export's receipt and either
27
+ action's warnings and error under `/internal`, as the task's Task Report,
28
+ Application Warnings and Application Error. A run with an error fails.
29
+ - `dq_export_connector.errors`: the codes the worker reports, and
30
+ `ExportConnectorError`, which stops a run with one.
31
+ - `dq_export_connector.report`: collects a run's error, warnings and receipt
32
+ while it runs, and cuts each message to 1,000 characters once redacted.
33
+ - `dq_export_connector.redact`: keeps every value from the sealed half, and
34
+ URL query strings, out of log lines and result messages.
35
+ - `dq_export_connector.bucket`: the bucket kind (`ValidateConnection` and
36
+ `Export`).
37
+ - `dq_export_connector._models`: pydantic models generated from ddc's JSON
38
+ schemas, so the config the worker reads and the receipt, messages and
39
+ validation result it writes match ddc's Rust types. Regenerate them with
40
+ `scripts/codegen-models.sh` after the types change and
41
+ `decentriq_dcr_compiler` has been rebuilt; a test fails while they are
42
+ stale.
43
+
44
+ ```sh
45
+ uv run pytest # unit tests, against obstore's in-memory store
46
+ uv run pytest -m live # against real buckets, credentials from the environment
47
+ uv run mypy dq_export_connector tests
48
+ ```
49
+
50
+ ## Releasing
51
+
52
+ Bump the version with `uv version <version> --no-sync`, which also updates
53
+ `uv.lock`, commit, and push a `dq-export-connector-v<version>` tag on that
54
+ commit; the `Publish dq-export-connector to PyPI` workflow tests, builds and
55
+ uploads it. Use `.devN` versions while developing; PyPI releases can't be replaced.
56
+ ddc then pins the new version, as
57
+ [ddc's export worker README](../../dcr-compiler/ddc/src/archv2/data_room/export_connector/README.md)
58
+ describes.
@@ -0,0 +1,47 @@
1
+ # dq-export-connector
2
+
3
+ Worker logic for the **Export Connector DCR**: one package for every
4
+ Connector Kind, each in its own sub-package with an extra of the same name for
5
+ its dependencies. The **bucket** kind uploads each Input's dataset to S3, Azure
6
+ Blob or GCS through [`obstore`](https://developmentseed.org/obstore/).
7
+
8
+ ddc pins this package by hash in a fully locked `requirements.txt` and runs
9
+ `dq_export_connector.runner.main` in the task's Python environment. It is
10
+ published to PyPI, since the compiled graph installs it from there.
11
+
12
+ - `dq_export_connector.runner`: the entry point. Reads `/input/config.json`
13
+ and `/input/credentials.json`, sets up logging, and dispatches on the
14
+ Connector Kind and the action, then writes what the action reports: a
15
+ connection test's result into `/output`, and an export's receipt and either
16
+ action's warnings and error under `/internal`, as the task's Task Report,
17
+ Application Warnings and Application Error. A run with an error fails.
18
+ - `dq_export_connector.errors`: the codes the worker reports, and
19
+ `ExportConnectorError`, which stops a run with one.
20
+ - `dq_export_connector.report`: collects a run's error, warnings and receipt
21
+ while it runs, and cuts each message to 1,000 characters once redacted.
22
+ - `dq_export_connector.redact`: keeps every value from the sealed half, and
23
+ URL query strings, out of log lines and result messages.
24
+ - `dq_export_connector.bucket`: the bucket kind (`ValidateConnection` and
25
+ `Export`).
26
+ - `dq_export_connector._models`: pydantic models generated from ddc's JSON
27
+ schemas, so the config the worker reads and the receipt, messages and
28
+ validation result it writes match ddc's Rust types. Regenerate them with
29
+ `scripts/codegen-models.sh` after the types change and
30
+ `decentriq_dcr_compiler` has been rebuilt; a test fails while they are
31
+ stale.
32
+
33
+ ```sh
34
+ uv run pytest # unit tests, against obstore's in-memory store
35
+ uv run pytest -m live # against real buckets, credentials from the environment
36
+ uv run mypy dq_export_connector tests
37
+ ```
38
+
39
+ ## Releasing
40
+
41
+ Bump the version with `uv version <version> --no-sync`, which also updates
42
+ `uv.lock`, commit, and push a `dq-export-connector-v<version>` tag on that
43
+ commit; the `Publish dq-export-connector to PyPI` workflow tests, builds and
44
+ uploads it. Use `.devN` versions while developing; PyPI releases can't be replaced.
45
+ ddc then pins the new version, as
46
+ [ddc's export worker README](../../dcr-compiler/ddc/src/archv2/data_room/export_connector/README.md)
47
+ describes.
@@ -1,14 +1,14 @@
1
1
  # generated by datamodel-codegen:
2
- # filename: snap_validation_result.json
2
+ # filename: application_message.json
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
- from typing import Annotated
6
+ from typing import Annotated, Any
7
7
 
8
8
  from pydantic import BaseModel, ConfigDict, Field
9
9
 
10
10
 
11
- class ExportMessage(BaseModel):
11
+ class ApplicationMessage(BaseModel):
12
12
  model_config = ConfigDict(
13
13
  populate_by_name=True,
14
14
  )
@@ -18,17 +18,12 @@ class ExportMessage(BaseModel):
18
18
  description='SCREAMING_SNAKE_CASE, such as `ACCESS_DENIED`. A string rather than an\nenum, so a worker release can add codes that readers built against an\nolder ddc still accept.'
19
19
  ),
20
20
  ]
21
+ details: Annotated[
22
+ dict[str, Any] | None, Field(description='Shaped by the `code`.')
23
+ ] = None
21
24
  message: Annotated[
22
25
  str,
23
26
  Field(
24
- description='Safe to show to the user: no credentials and no dataset values. Writers\ncut it to 1,000 characters, marking the cut with `…`.'
27
+ description='Safe to show to the user: no credentials and no dataset values.'
25
28
  ),
26
29
  ]
27
-
28
-
29
- class SnapValidationResult(BaseModel):
30
- model_config = ConfigDict(
31
- populate_by_name=True,
32
- )
33
- error: ExportMessage | None = None
34
- warnings: list[ExportMessage]
@@ -3,12 +3,12 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
- from typing import Annotated
6
+ from typing import Annotated, Any
7
7
 
8
8
  from pydantic import BaseModel, ConfigDict, Field
9
9
 
10
10
 
11
- class ExportMessage(BaseModel):
11
+ class ApplicationMessage(BaseModel):
12
12
  model_config = ConfigDict(
13
13
  populate_by_name=True,
14
14
  )
@@ -18,10 +18,13 @@ class ExportMessage(BaseModel):
18
18
  description='SCREAMING_SNAKE_CASE, such as `ACCESS_DENIED`. A string rather than an\nenum, so a worker release can add codes that readers built against an\nolder ddc still accept.'
19
19
  ),
20
20
  ]
21
+ details: Annotated[
22
+ dict[str, Any] | None, Field(description='Shaped by the `code`.')
23
+ ] = None
21
24
  message: Annotated[
22
25
  str,
23
26
  Field(
24
- description='Safe to show to the user: no credentials and no dataset values. Writers\ncut it to 1,000 characters, marking the cut with `…`.'
27
+ description='Safe to show to the user: no credentials and no dataset values.'
25
28
  ),
26
29
  ]
27
30
 
@@ -30,5 +33,5 @@ class BucketValidationResult(BaseModel):
30
33
  model_config = ConfigDict(
31
34
  populate_by_name=True,
32
35
  )
33
- error: ExportMessage | None = None
34
- warnings: list[ExportMessage]
36
+ error: ApplicationMessage | None = None
37
+ warnings: list[ApplicationMessage]
@@ -52,19 +52,6 @@ class BucketExportCredentials(
52
52
  ]
53
53
 
54
54
 
55
- class SnapExportCredentials(BaseModel):
56
- model_config = ConfigDict(
57
- populate_by_name=True,
58
- )
59
- refresh_token: Annotated[
60
- str,
61
- Field(
62
- alias='refreshToken',
63
- description="The refresh token of the Snap user who consented. Snap doesn't rotate it.",
64
- ),
65
- ]
66
-
67
-
68
55
  class ExportConnectorCredentials1(BaseModel):
69
56
  model_config = ConfigDict(
70
57
  populate_by_name=True,
@@ -73,19 +60,9 @@ class ExportConnectorCredentials1(BaseModel):
73
60
  type: Literal['bucket']
74
61
 
75
62
 
76
- class ExportConnectorCredentials2(BaseModel):
77
- model_config = ConfigDict(
78
- populate_by_name=True,
79
- )
80
- credentials: SnapExportCredentials
81
- type: Literal['snap']
82
-
83
-
84
- class ExportConnectorCredentials(
85
- RootModel[ExportConnectorCredentials1 | ExportConnectorCredentials2]
86
- ):
63
+ class ExportConnectorCredentials(RootModel[ExportConnectorCredentials1]):
87
64
  root: Annotated[
88
- ExportConnectorCredentials1 | ExportConnectorCredentials2,
65
+ ExportConnectorCredentials1,
89
66
  Field(
90
67
  description='Keyed by Connector Kind, in step with [`ExportConnectorKind`]. The worker\nreads it at `/input/credentials.json`.',
91
68
  title='ExportConnectorCredentials',
@@ -0,0 +1,147 @@
1
+ # generated by datamodel-codegen:
2
+ # filename: export_receipt.json
3
+
4
+ from __future__ import annotations
5
+
6
+ from typing import Annotated, Literal
7
+
8
+ from pydantic import BaseModel, ConfigDict, Field, RootModel
9
+
10
+
11
+ class BucketConnection1(BaseModel):
12
+ model_config = ConfigDict(
13
+ populate_by_name=True,
14
+ )
15
+ bucket: str
16
+ path_prefix: Annotated[str | None, Field(alias='pathPrefix')] = None
17
+ region: str
18
+ type: Literal['s3']
19
+
20
+
21
+ class BucketConnection2(BaseModel):
22
+ model_config = ConfigDict(
23
+ populate_by_name=True,
24
+ )
25
+ account_name: Annotated[str, Field(alias='accountName')]
26
+ container: str
27
+ path_prefix: Annotated[str | None, Field(alias='pathPrefix')] = None
28
+ type: Literal['azureBlob']
29
+
30
+
31
+ class BucketConnection3(BaseModel):
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ )
35
+ bucket: str
36
+ path_prefix: Annotated[str | None, Field(alias='pathPrefix')] = None
37
+ type: Literal['gcs']
38
+
39
+
40
+ class BucketConnection(
41
+ RootModel[BucketConnection1 | BucketConnection2 | BucketConnection3]
42
+ ):
43
+ root: Annotated[
44
+ BucketConnection1 | BucketConnection2 | BucketConnection3,
45
+ Field(
46
+ description='Cloud-bucket addressing (no credentials). Provider-structurally paired with\nthe matching [`BucketCredentials`] variant in the confidential half.'
47
+ ),
48
+ ]
49
+
50
+
51
+ class ExportTotals(BaseModel):
52
+ model_config = ConfigDict(
53
+ populate_by_name=True,
54
+ )
55
+ bytes: Annotated[int, Field(ge=0)]
56
+ files: Annotated[int, Field(ge=0)]
57
+ rows: Annotated[
58
+ int | None,
59
+ Field(
60
+ description='`None` unless the worker counted the rows of every file.', ge=0
61
+ ),
62
+ ] = None
63
+
64
+
65
+ class BucketInputReceipt(BaseModel):
66
+ model_config = ConfigDict(
67
+ populate_by_name=True,
68
+ )
69
+ destination_directory: Annotated[str, Field(alias='destinationDirectory')]
70
+ leaf_id: Annotated[str, Field(alias='leafId')]
71
+ totals: Annotated[
72
+ ExportTotals,
73
+ Field(
74
+ description='What reached the bucket, also from an Input that failed partway.'
75
+ ),
76
+ ]
77
+
78
+
79
+ class ExportReceiptV01(BaseModel):
80
+ model_config = ConfigDict(
81
+ populate_by_name=True,
82
+ )
83
+ connection: Annotated[
84
+ BucketConnection, Field(description='Where the run exported to.')
85
+ ]
86
+ export_prefix: Annotated[
87
+ str | None,
88
+ Field(
89
+ alias='exportPrefix',
90
+ description='The export prefix with its date tokens filled; `None` without one.',
91
+ ),
92
+ ] = None
93
+ inputs: list[BucketInputReceipt]
94
+ totals: ExportTotals
95
+ type: Literal['BUCKET']
96
+
97
+
98
+ class ExportReceiptV0(RootModel[ExportReceiptV01]):
99
+ root: ExportReceiptV01
100
+
101
+
102
+ class ExportReceipt1(BaseModel):
103
+ model_config = ConfigDict(
104
+ populate_by_name=True,
105
+ )
106
+ version: Literal['V0']
107
+ connection: Annotated[
108
+ BucketConnection, Field(description='Where the run exported to.')
109
+ ]
110
+ export_prefix: Annotated[
111
+ str | None,
112
+ Field(
113
+ alias='exportPrefix',
114
+ description='The export prefix with its date tokens filled; `None` without one.',
115
+ ),
116
+ ] = None
117
+ inputs: list[BucketInputReceipt]
118
+ totals: ExportTotals
119
+ type: Literal['BUCKET']
120
+
121
+
122
+ class ExportReceipt(RootModel[ExportReceipt1]):
123
+ root: Annotated[
124
+ ExportReceipt1,
125
+ Field(
126
+ description='What an Export Connector Run sent and where. api-platform reads it in\nplaintext, so it holds only metadata, never dataset values. A released\nversion never changes: a change is a new version, and readers keep reading\nevery version ever written.',
127
+ title='ExportReceipt',
128
+ ),
129
+ ]
130
+
131
+
132
+ class BucketExportReceiptV0(BaseModel):
133
+ model_config = ConfigDict(
134
+ populate_by_name=True,
135
+ )
136
+ connection: Annotated[
137
+ BucketConnection, Field(description='Where the run exported to.')
138
+ ]
139
+ export_prefix: Annotated[
140
+ str | None,
141
+ Field(
142
+ alias='exportPrefix',
143
+ description='The export prefix with its date tokens filled; `None` without one.',
144
+ ),
145
+ ] = None
146
+ inputs: list[BucketInputReceipt]
147
+ totals: ExportTotals
@@ -3,7 +3,6 @@
3
3
 
4
4
  from __future__ import annotations
5
5
 
6
- from enum import Enum
7
6
  from typing import Annotated, Literal
8
7
 
9
8
  from pydantic import AwareDatetime, BaseModel, ConfigDict, Field, RootModel
@@ -73,38 +72,19 @@ class ExportConnectorKind1(BaseModel):
73
72
  type: Literal['bucket']
74
73
 
75
74
 
76
- class ExportParams1(BaseModel):
77
- model_config = ConfigDict(
78
- populate_by_name=True,
79
- )
80
- type: Literal['bucket']
75
+ class ExportConnectorKind(RootModel[ExportConnectorKind1]):
76
+ root: ExportConnectorKind1
81
77
 
82
78
 
83
- class ExportParams2(BaseModel):
79
+ class ExportParams1(BaseModel):
84
80
  model_config = ConfigDict(
85
81
  populate_by_name=True,
86
82
  )
87
- type: Literal['snap']
88
-
89
-
90
- class ExportParams(RootModel[ExportParams1 | ExportParams2]):
91
- root: ExportParams1 | ExportParams2
92
-
93
-
94
- class IdentifierType(Enum):
95
- email = 'EMAIL'
96
- email_sha256 = 'EMAIL_SHA256'
97
- phone = 'PHONE'
98
- phone_sha256 = 'PHONE_SHA256'
99
- idfa = 'IDFA'
100
- idfa_sha256 = 'IDFA_SHA256'
101
- gaid = 'GAID'
102
- gaid_sha256 = 'GAID_SHA256'
83
+ type: Literal['bucket']
103
84
 
104
85
 
105
- class MergeMode(Enum):
106
- add = 'ADD'
107
- replace = 'REPLACE'
86
+ class ExportParams(RootModel[ExportParams1]):
87
+ root: ExportParams1
108
88
 
109
89
 
110
90
  class ProvisionedPolicy(BaseModel):
@@ -125,30 +105,6 @@ class ProvisionedPolicy(BaseModel):
125
105
  ]
126
106
 
127
107
 
128
- class SnapInput(BaseModel):
129
- model_config = ConfigDict(
130
- populate_by_name=True,
131
- )
132
- identifier_type: Annotated[IdentifierType, Field(alias='identifierType')]
133
- leaf_id: Annotated[str, Field(alias='leafId')]
134
- merge_mode: Annotated[MergeMode, Field(alias='mergeMode')]
135
- retention_days: Annotated[
136
- int | None,
137
- Field(
138
- alias='retentionDays',
139
- description='Applied when the Segment is created.',
140
- ge=0,
141
- ),
142
- ] = None
143
- segment_name: Annotated[
144
- str,
145
- Field(
146
- alias='segmentName',
147
- description='The Segment is found by this name in the ad account, or created.',
148
- ),
149
- ]
150
-
151
-
152
108
  class ValidateConnectionParams1(BaseModel):
153
109
  model_config = ConfigDict(
154
110
  populate_by_name=True,
@@ -156,17 +112,8 @@ class ValidateConnectionParams1(BaseModel):
156
112
  type: Literal['bucket']
157
113
 
158
114
 
159
- class ValidateConnectionParams2(BaseModel):
160
- model_config = ConfigDict(
161
- populate_by_name=True,
162
- )
163
- type: Literal['snap']
164
-
165
-
166
- class ValidateConnectionParams(
167
- RootModel[ValidateConnectionParams1 | ValidateConnectionParams2]
168
- ):
169
- root: ValidateConnectionParams1 | ValidateConnectionParams2
115
+ class ValidateConnectionParams(RootModel[ValidateConnectionParams1]):
116
+ root: ValidateConnectionParams1
170
117
 
171
118
 
172
119
  class BucketExportConfig(BaseModel):
@@ -227,45 +174,6 @@ class ExportConnectorDcrComputeAction(
227
174
  ]
228
175
 
229
176
 
230
- class ExportConnectorKind2(BaseModel):
231
- model_config = ConfigDict(
232
- populate_by_name=True,
233
- )
234
- ad_account_id: Annotated[
235
- str, Field(alias='adAccountId', description='A canonical, lowercase UUID.')
236
- ]
237
- grant_expires_at: Annotated[
238
- str | None,
239
- Field(
240
- alias='grantExpiresAt',
241
- description='RFC 3339. When the grant behind the credentials expires; runs warn as\nit nears.',
242
- ),
243
- ] = None
244
- inputs: list[SnapInput]
245
- type: Literal['snap']
246
-
247
-
248
- class ExportConnectorKind(RootModel[ExportConnectorKind1 | ExportConnectorKind2]):
249
- root: ExportConnectorKind1 | ExportConnectorKind2
250
-
251
-
252
- class SnapExportConfig(BaseModel):
253
- model_config = ConfigDict(
254
- populate_by_name=True,
255
- )
256
- ad_account_id: Annotated[
257
- str, Field(alias='adAccountId', description='A canonical, lowercase UUID.')
258
- ]
259
- grant_expires_at: Annotated[
260
- str | None,
261
- Field(
262
- alias='grantExpiresAt',
263
- description='RFC 3339. When the grant behind the credentials expires; runs warn as\nit nears.',
264
- ),
265
- ] = None
266
- inputs: list[SnapInput]
267
-
268
-
269
177
  class ExportWorkerConfig(BaseModel):
270
178
  model_config = ConfigDict(
271
179
  populate_by_name=True,
@@ -13,15 +13,15 @@ from pathlib import Path
13
13
  from typing import Any
14
14
 
15
15
  from dq_export_connector._models.export_connector_credentials import BucketExportCredentials
16
- from dq_export_connector._models.export_report import BucketConnection as ReceiptConnection
17
- from dq_export_connector._models.export_report import (
16
+ from dq_export_connector._models.export_receipt import BucketConnection as ReceiptConnection
17
+ from dq_export_connector._models.export_receipt import (
18
18
  BucketInputReceipt,
19
19
  ExportReceiptV0,
20
20
  ExportReceiptV01,
21
21
  ExportTotals,
22
22
  )
23
23
  from dq_export_connector._models.export_worker_config import BucketInput, ExportConnectorKind1, ProvisionedPolicy
24
- from dq_export_connector.datasets import DatasetFile, open_dataset
24
+ from dq_export_connector.bucket.datasets import DatasetFile, open_dataset
25
25
  from dq_export_connector.bucket.paths import InvalidPathError, check_dataset_path, check_key, fill_date_tokens, join_key
26
26
  from dq_export_connector.bucket.store import StorageError, classify_error, failure_sentence, location
27
27
  from dq_export_connector.bucket.upload import plan_upload, upload
@@ -1,11 +1,10 @@
1
1
  """The codes the worker reports, and the error that stops a run with one. A
2
- code is named for the situation, not the Connector Kind, so any kind can
3
- report it; the `BUCKET_` codes predate that rule."""
2
+ code shared by every Connector Kind has no prefix; one only a kind can report
3
+ carries the kind's prefix, such as `BUCKET_`."""
4
4
 
5
5
  from __future__ import annotations
6
6
 
7
7
  import traceback
8
- from dataclasses import dataclass
9
8
  from enum import Enum
10
9
 
11
10
 
@@ -20,28 +19,13 @@ class ErrorCode(str, Enum):
20
19
  READ_FAILED = "READ_FAILED"
21
20
  INTERNAL_ERROR = "INTERNAL_ERROR"
22
21
  BUCKET_INVALID_PATH = "BUCKET_INVALID_PATH"
23
- # Decentriq's own app credentials for the platform were rejected.
24
- APP_CREDENTIALS_REJECTED = "APP_CREDENTIALS_REJECTED"
25
- RATE_LIMITED = "RATE_LIMITED"
26
- AMBIGUOUS_SEGMENT = "AMBIGUOUS_SEGMENT"
27
- TOO_MANY_INVALID_ROWS = "TOO_MANY_INVALID_ROWS"
28
- # A request that isn't safe to repeat may or may not have been applied.
29
- OUTCOME_UNKNOWN = "OUTCOME_UNKNOWN"
30
- # The platform issued a new refresh token, which the worker can't store.
31
- REFRESH_TOKEN_ROTATED = "REFRESH_TOKEN_ROTATED"
32
22
  # Warnings
33
23
  EMPTY_DATASET = "EMPTY_DATASET"
34
24
  BUCKET_PROBE_NOT_DELETED = "BUCKET_PROBE_NOT_DELETED"
35
25
  BUCKET_PARTS_MAY_REMAIN = "BUCKET_PARTS_MAY_REMAIN"
36
- REAUTHORISATION_DUE = "REAUTHORISATION_DUE"
37
- INVALID_ROWS = "INVALID_ROWS"
38
- SEGMENT_SETTINGS_DIFFER = "SEGMENT_SETTINGS_DIFFER"
39
- # The run wrote into a Segment this connector didn't create.
40
- SEGMENT_NOT_MANAGED = "SEGMENT_NOT_MANAGED"
41
- REJECTED_ROWS = "REJECTED_ROWS"
42
26
 
43
27
 
44
- # ddc's limit on a report message, in characters.
28
+ # The most characters a message the worker writes has, so the UI can rely on a bound.
45
29
  MAX_MESSAGE_LENGTH = 1000
46
30
 
47
31
 
@@ -50,23 +34,14 @@ def truncate(text: str, limit: int) -> str:
50
34
 
51
35
 
52
36
  class ExportConnectorError(Exception):
53
- """Stops the run and becomes its report's error. `message` is shown to the
54
- user, so it must not hold dataset values; credentials are redacted."""
37
+ """Stops the run and becomes its Application Error, or a connection test's
38
+ result's error. `message` is shown to the user, so it must not hold dataset
39
+ values; credentials are redacted."""
55
40
 
56
- def __init__(self, code: ErrorCode, message: str, possibly_applied: bool = False) -> None:
41
+ def __init__(self, code: ErrorCode, message: str) -> None:
57
42
  super().__init__(message)
58
43
  self.code = code
59
44
  self.message = message
60
- # Whether the failed call may still have changed the destination.
61
- self.possibly_applied = possibly_applied or code is ErrorCode.OUTCOME_UNKNOWN
62
-
63
-
64
- @dataclass(frozen=True)
65
- class Issue:
66
- """A warning or error collected while a run goes on."""
67
-
68
- code: ErrorCode
69
- message: str
70
45
 
71
46
 
72
47
  def internal_error_message(error: BaseException, activity: str) -> str: